From 4e15f8bfee416684d27f1c4a27930a5a38d12260 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sun, 5 May 2024 21:11:34 -0400 Subject: [PATCH 1/4] ENH: updated HDF5 1.12.1 to 1.12.3 --- Modules/ThirdParty/HDF5/UpdateFromUpstream.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/ThirdParty/HDF5/UpdateFromUpstream.sh b/Modules/ThirdParty/HDF5/UpdateFromUpstream.sh index 6cd2c9f4b5f..1bedecf87e8 100755 --- a/Modules/ThirdParty/HDF5/UpdateFromUpstream.sh +++ b/Modules/ThirdParty/HDF5/UpdateFromUpstream.sh @@ -8,14 +8,13 @@ readonly name="HDF5" readonly ownership="HDF5 Maintainers " readonly subtree="Modules/ThirdParty/HDF5/src/itkhdf5" readonly repo="https://github.com/HDFGroup/hdf5.git" -readonly tag="hdf5-1_12_1" +readonly tag="hdf5-1_12_3" readonly shortlog=false readonly paths=" ACKNOWLEDGMENTS CTestConfig.cmake - README.txt + README.md config/cmake - config/cmake_ext_mod config/clang-warnings config/gnu-warnings config/intel-warnings From 3f96eed6ab768136536542b53334f1fa2933f161 Mon Sep 17 00:00:00 2001 From: HDF5 Maintainers Date: Mon, 6 Nov 2023 19:46:28 -0600 Subject: [PATCH 2/4] HDF5 2023-11-06 (106fb569) Code extracted from: https://github.com/HDFGroup/hdf5.git at commit 106fb56936d1d785ca96147601a3608e433ddc3b (hdf5-1_12_3). --- .clang-format | 32 +- CMakeFilters.cmake | 178 +- CMakeInstallation.cmake | 165 +- CMakeLists.txt | 187 +- COPYING | 2 +- CTestConfig.cmake | 4 +- README.md | 86 + README.txt | 80 - c++/src/CMakeLists.txt | 39 +- c++/src/H5AbstractDs.cpp | 3 +- c++/src/H5AbstractDs.h | 1 - c++/src/H5Alltypes.h | 1 - c++/src/H5ArrayType.cpp | 1 - c++/src/H5ArrayType.h | 7 +- c++/src/H5AtomType.cpp | 1 - c++/src/H5AtomType.h | 5 +- c++/src/H5Attribute.cpp | 23 +- c++/src/H5Attribute.h | 19 +- c++/src/H5Classes.h | 1 - c++/src/H5CommonFG.cpp | 2 - c++/src/H5CommonFG.h | 1 - c++/src/H5CompType.cpp | 1 - c++/src/H5CompType.h | 7 +- c++/src/H5Cpp.h | 11 - c++/src/H5CppDoc.h | 1 - c++/src/H5DaccProp.cpp | 4 +- c++/src/H5DaccProp.h | 5 +- c++/src/H5DataSet.cpp | 11 +- c++/src/H5DataSet.h | 27 +- c++/src/H5DataSpace.cpp | 6 +- c++/src/H5DataSpace.h | 3 +- c++/src/H5DataType.cpp | 21 +- c++/src/H5DataType.h | 11 +- c++/src/H5DcreatProp.cpp | 6 +- c++/src/H5DcreatProp.h | 5 +- c++/src/H5DxferProp.cpp | 12 +- c++/src/H5DxferProp.h | 5 +- c++/src/H5EnumType.cpp | 5 +- c++/src/H5EnumType.h | 7 +- c++/src/H5Exception.cpp | 1 - c++/src/H5Exception.h | 5 +- c++/src/H5FaccProp.cpp | 8 +- c++/src/H5FaccProp.h | 5 +- c++/src/H5FcreatProp.cpp | 4 +- c++/src/H5FcreatProp.h | 5 +- c++/src/H5File.cpp | 3 +- c++/src/H5File.h | 11 +- c++/src/H5FloatType.cpp | 1 - c++/src/H5FloatType.h | 7 +- c++/src/H5Group.cpp | 3 +- c++/src/H5Group.h | 1 - c++/src/H5IdComponent.cpp | 12 +- c++/src/H5IdComponent.h | 1 - c++/src/H5Include.h | 4 +- c++/src/H5IntType.cpp | 1 - c++/src/H5IntType.h | 9 +- c++/src/H5LaccProp.cpp | 4 +- c++/src/H5LaccProp.h | 5 +- c++/src/H5LcreatProp.cpp | 8 +- c++/src/H5LcreatProp.h | 5 +- c++/src/H5Library.cpp | 3 +- c++/src/H5Library.h | 1 - c++/src/H5Location.cpp | 27 +- c++/src/H5Location.h | 43 +- c++/src/H5Object.cpp | 28 +- c++/src/H5Object.h | 9 +- c++/src/H5OcreatProp.cpp | 4 +- c++/src/H5OcreatProp.h | 5 +- c++/src/H5PredType.cpp | 225 +- c++/src/H5PredType.h | 78 +- c++/src/H5PropList.cpp | 21 +- c++/src/H5PropList.h | 11 +- c++/src/H5StrType.cpp | 7 +- c++/src/H5StrType.h | 7 +- c++/src/H5VarLenType.cpp | 1 - c++/src/H5VarLenType.h | 7 +- c++/src/cpp_doc_config | 2 +- c++/src/footer.html | 2 - c++/src/h5c++.in | 7 +- c++/src/header.html | 3 +- config/clang-warnings/developer-general | 1 - config/clang-warnings/error-general | 3 - config/clang-warnings/general | 16 +- config/clang-warnings/noerror-general | 82 - config/cmake/CTestCustom.cmake | 28 + config/cmake/ConfigureChecks.cmake | 911 ++- config/cmake/ConversionTests.c | 290 +- .../GetTimeOfDayTest.cpp | 0 config/cmake/H5cxx_config.h.in | 16 - config/cmake/H5pubconf.h.in | 37 +- config/cmake/HDF5DeveloperBuild.cmake | 196 + config/cmake/HDF5Macros.cmake | 41 + config/cmake/HDF5PluginCache.cmake | 40 +- config/cmake/HDF5PluginMacros.cmake | 73 +- config/cmake/HDF5UseFortran.cmake | 92 +- config/cmake/HDFCXXCompilerFlags.cmake | 309 +- config/cmake/HDFCompilerFlags.cmake | 350 +- config/cmake/HDFFortranCompilerFlags.cmake | 25 +- config/cmake/HDFLibMacros.cmake | 80 + .../{cmake_ext_mod => cmake}/HDFMacros.cmake | 141 +- config/{cmake_ext_mod => cmake}/HDFTests.c | 4 +- .../HDFUseFortran.cmake | 2 +- config/cmake/LIBAEC/CMakeLists.txt | 513 ++ config/cmake/LIBAEC/CPack.Info.plist.in | 26 + config/cmake/LIBAEC/config.h.in | 36 + .../LIBAEC/libaec-config-version.cmake.in | 42 + config/cmake/LIBAEC/libaec-config.cmake.in | 59 + .../NSIS.InstallOptions.ini.in | 0 .../{cmake_ext_mod => cmake}/NSIS.template.in | 4 +- ...README.txt.cmake.in => README.md.cmake.in} | 8 +- config/cmake/UseJava.cmake | 841 +-- config/cmake/UseJavaClassFilelist.cmake | 17 +- config/cmake/UseJavaSymlinks.cmake | 16 +- config/cmake/UserMacros/Windows_MT.cmake | 1 + config/cmake/ZLIB/CMakeLists.txt | 572 ++ config/cmake/ZLIB/CPack.Info.plist.in | 26 + config/cmake/ZLIB/zconf.h.in | 536 ++ .../cmake/ZLIB/zlib-config-version.cmake.in | 42 + config/cmake/ZLIB/zlib-config.cmake.in | 58 + config/cmake/cacheinit.cmake | 152 +- config/cmake/{ => examples}/CTestScript.cmake | 29 +- .../{ => examples}/HDF5_Examples.cmake.in | 15 +- .../HDF5_Examples_options.cmake | 17 +- config/cmake/fileCompareTest.cmake | 4 +- .../{cmake_ext_mod => cmake}/grepTest.cmake | 18 + config/{cmake_ext_mod => cmake}/hdf.bmp | Bin config/{cmake_ext_mod => cmake}/hdf.icns | Bin config/{cmake_ext_mod => cmake}/hdf.ico | Bin config/cmake/hdf5-config.cmake.in | 26 +- config/cmake/javaTargets.cmake.in | 39 + config/cmake/jrunTest.cmake | 25 +- config/cmake/jvolTest.cmake | 301 - config/cmake/libh5cc.in | 26 +- config/cmake/libhdf5.settings.cmake.in | 82 +- config/cmake/mccacheinit.cmake | 24 +- config/cmake/{patch.xml => patch.xml.in} | 2 +- config/{cmake_ext_mod => cmake}/runTest.cmake | 38 +- config/cmake/scripts/CTestScript.cmake | 51 +- config/cmake/scripts/HDF5config.cmake | 36 +- config/cmake/scripts/HDF5options.cmake | 14 +- .../{cmake_ext_mod => cmake}/version.plist.in | 0 config/cmake/vfdTest.cmake | 16 + config/cmake/volTest.cmake | 16 + config/cmake_ext_mod/CTestCustom.cmake | 17 - config/cmake_ext_mod/ConfigureChecks.cmake | 697 --- config/cmake_ext_mod/FindSZIP.cmake | 129 - config/cmake_ext_mod/HDFCXXTests.cpp | 46 - config/cmake_ext_mod/HDFLibMacros.cmake | 242 - config/cmake_ext_mod/HDFUseCXX.cmake | 110 - config/gnu-warnings/4.8 | 7 - config/gnu-warnings/7 | 1 - config/gnu-warnings/cxx-4.8 | 7 - config/gnu-warnings/cxx-developer-4.8 | 21 + config/gnu-warnings/cxx-general | 1 - config/gnu-warnings/cxx-noerror-5 | 11 - config/gnu-warnings/cxx-noerror-general | 32 - config/gnu-warnings/developer-12 | 4 + config/gnu-warnings/developer-4.8 | 7 + config/gnu-warnings/developer-general | 12 +- config/gnu-warnings/error-5 | 1 + config/gnu-warnings/error-7 | 1 + config/gnu-warnings/error-8 | 20 +- config/gnu-warnings/error-general | 37 +- config/gnu-warnings/general | 14 +- config/gnu-warnings/gfort-4.8 | 1 - config/gnu-warnings/gfort-developer-4.8 | 3 + .../{gfort-5 => gfort-developer-5} | 0 config/gnu-warnings/gfort-developer-general | 3 + config/gnu-warnings/gfort-no-developer-4.8 | 3 + .../gnu-warnings/gfort-no-developer-general | 3 + config/gnu-warnings/no-cxx-developer-4.8 | 12 + config/gnu-warnings/no-developer-4.8 | 3 +- config/gnu-warnings/noerror-5 | 12 - config/gnu-warnings/noerror-8 | 25 - config/gnu-warnings/noerror-general | 92 - config/intel-warnings/18 | 6 - config/intel-warnings/developer-general | 9 +- config/intel-warnings/general-19 | 2 - config/intel-warnings/ifort-general | 2 +- config/intel-warnings/win-developer-general | 1 + config/intel-warnings/win-general | 1 + config/intel-warnings/win-ifort-general | 1 + hl/CMakeLists.txt | 10 +- hl/c++/src/CMakeLists.txt | 28 +- hl/c++/src/H5PacketTable.cpp | 16 +- hl/c++/src/H5PacketTable.h | 8 +- hl/src/CMakeLists.txt | 57 +- hl/src/H5DO.c | 7 +- hl/src/H5DOpublic.h | 203 +- hl/src/H5DS.c | 911 ++- hl/src/H5DSprivate.h | 9 +- hl/src/H5DSpublic.h | 364 +- hl/src/H5HLprivate2.h | 1 - hl/src/H5IM.c | 7 +- hl/src/H5IMprivate.h | 1 - hl/src/H5IMpublic.h | 297 +- hl/src/H5LD.c | 83 +- hl/src/H5LDprivate.h | 1 - hl/src/H5LDpublic.h | 139 +- hl/src/H5LT.c | 211 +- hl/src/H5LTanalyze.c | 2 +- hl/src/H5LTanalyze.l | 1 - hl/src/H5LTparse.c | 1 + hl/src/H5LTparse.y | 1 - hl/src/H5LTprivate.h | 1 - hl/src/H5LTpublic.h | 1412 ++++- hl/src/H5PT.c | 16 +- hl/src/H5PTprivate.h | 1 - hl/src/H5PTpublic.h | 420 +- hl/src/H5TB.c | 31 +- hl/src/H5TBprivate.h | 1 - hl/src/H5TBpublic.h | 548 +- hl/src/hdf5_hl.h | 1 - src/CMakeLists.txt | 210 +- src/H5.c | 271 +- src/H5A.c | 97 +- src/H5AC.c | 113 +- src/H5ACdbg.c | 11 +- src/H5ACmpio.c | 166 +- src/H5ACpkg.h | 9 +- src/H5ACprivate.h | 39 +- src/H5ACproxy_entry.c | 5 +- src/H5ACpublic.h | 24 +- src/H5Abtree2.c | 21 +- src/H5Adense.c | 141 +- src/H5Adeprec.c | 17 +- src/H5Aint.c | 127 +- src/H5Amodule.h | 350 +- src/H5Apkg.h | 15 +- src/H5Aprivate.h | 13 +- src/H5Apublic.h | 270 +- src/H5Atest.c | 3 +- src/H5B.c | 65 +- src/H5B2.c | 23 +- src/H5B2cache.c | 45 +- src/H5B2dbg.c | 7 +- src/H5B2hdr.c | 5 +- src/H5B2int.c | 80 +- src/H5B2internal.c | 15 +- src/H5B2leaf.c | 11 +- src/H5B2pkg.h | 55 +- src/H5B2private.h | 3 +- src/H5B2stat.c | 3 +- src/H5B2test.c | 11 +- src/H5Bcache.c | 23 +- src/H5Bdbg.c | 23 +- src/H5Bpkg.h | 7 +- src/H5Bprivate.h | 7 +- src/H5C.c | 611 +- src/H5CS.c | 11 +- src/H5CSprivate.h | 5 - src/H5CX.c | 34 +- src/H5CXprivate.h | 7 +- src/H5Cdbg.c | 9 +- src/H5Cepoch.c | 5 +- src/H5Cimage.c | 53 +- src/H5Clog.c | 1 - src/H5Clog.h | 3 +- src/H5Clog_json.c | 3 +- src/H5Clog_trace.c | 3 +- src/H5Cmpio.c | 23 +- src/H5Cpkg.h | 264 +- src/H5Cprefetched.c | 7 +- src/H5Cprivate.h | 43 +- src/H5Cpublic.h | 8 - src/H5Cquery.c | 5 +- src/H5Ctag.c | 54 +- src/H5Ctest.c | 5 +- src/H5D.c | 65 +- src/H5Dbtree.c | 30 +- src/H5Dbtree2.c | 51 +- src/H5Dchunk.c | 875 ++- src/H5Dcompact.c | 47 +- src/H5Dcontig.c | 94 +- src/H5Ddbg.c | 1 - src/H5Ddeprec.c | 11 +- src/H5Dearray.c | 37 +- src/H5Defl.c | 41 +- src/H5Dfarray.c | 37 +- src/H5Dfill.c | 13 +- src/H5Dint.c | 285 +- src/H5Dio.c | 179 +- src/H5Dlayout.c | 28 +- src/H5Dmodule.h | 2669 +++++++- src/H5Dmpio.c | 5515 ++++++++++++----- src/H5Dnone.c | 5 +- src/H5Doh.c | 17 +- src/H5Dpkg.h | 134 +- src/H5Dprivate.h | 23 +- src/H5Dpublic.h | 620 +- src/H5Dscatgath.c | 41 +- src/H5Dselect.c | 208 +- src/H5Dsingle.c | 11 +- src/H5Dtest.c | 1 - src/H5Dvirtual.c | 139 +- src/H5E.c | 62 +- src/H5EA.c | 421 +- src/H5EAcache.c | 738 ++- src/H5EAdbg.c | 152 +- src/H5EAdblkpage.c | 129 +- src/H5EAdblock.c | 180 +- src/H5EAhdr.c | 322 +- src/H5EAiblock.c | 170 +- src/H5EAint.c | 33 +- src/H5EApkg.h | 31 +- src/H5EAprivate.h | 10 +- src/H5EAsblock.c | 167 +- src/H5EAstat.c | 15 +- src/H5EAtest.c | 192 +- src/H5ESpublic.h | 14 +- src/H5Edefin.h | 1 - src/H5Edeprec.c | 15 +- src/H5Einit.h | 1 - src/H5Eint.c | 31 +- src/H5Emodule.h | 549 +- src/H5Epkg.h | 7 +- src/H5Eprivate.h | 48 - src/H5Epubgen.h | 1 - src/H5Epublic.h | 73 +- src/H5Eterm.h | 1 - src/H5F.c | 19 +- src/H5FA.c | 348 +- src/H5FAcache.c | 423 +- src/H5FAdbg.c | 80 +- src/H5FAdblkpage.c | 126 +- src/H5FAdblock.c | 156 +- src/H5FAhdr.c | 266 +- src/H5FAint.c | 33 +- src/H5FApkg.h | 21 +- src/H5FAprivate.h | 14 +- src/H5FAstat.c | 15 +- src/H5FAtest.c | 136 +- src/H5FD.c | 19 +- src/H5FDcore.c | 35 +- src/H5FDcore.h | 1 - src/H5FDdirect.c | 32 +- src/H5FDdirect.h | 1 - src/H5FDfamily.c | 41 +- src/H5FDfamily.h | 1 - src/H5FDhdfs.c | 62 +- src/H5FDhdfs.h | 15 +- src/H5FDint.c | 1 - src/H5FDlog.c | 35 +- src/H5FDlog.h | 1 - src/H5FDmirror.c | 118 +- src/H5FDmirror.h | 2 +- src/H5FDmirror_priv.h | 10 +- src/H5FDmpi.c | 1 - src/H5FDmpi.h | 1 - src/H5FDmpio.c | 152 +- src/H5FDmpio.h | 7 +- src/H5FDmulti.c | 57 +- src/H5FDmulti.h | 1 - src/H5FDpkg.h | 1 - src/H5FDprivate.h | 17 +- src/H5FDpublic.h | 39 +- src/H5FDros3.c | 50 +- src/H5FDs3comms.c | 58 +- src/H5FDs3comms.h | 48 +- src/H5FDsec2.c | 7 +- src/H5FDsec2.h | 17 +- src/H5FDspace.c | 16 +- src/H5FDsplitter.c | 56 +- src/H5FDsplitter.h | 2 +- src/H5FDstdio.c | 23 +- src/H5FDstdio.h | 3 +- src/H5FDtest.c | 7 - src/H5FDwindows.c | 1 - src/H5FDwindows.h | 1 - src/H5FL.c | 214 +- src/H5FLprivate.h | 59 +- src/H5FO.c | 5 +- src/H5FOprivate.h | 3 +- src/H5FS.c | 46 +- src/H5FScache.c | 53 +- src/H5FSdbg.c | 5 +- src/H5FSint.c | 1 - src/H5FSpkg.h | 9 +- src/H5FSprivate.h | 5 +- src/H5FSsection.c | 82 +- src/H5FSstat.c | 1 - src/H5FStest.c | 1 - src/H5Faccum.c | 3 +- src/H5Fcwfs.c | 1 - src/H5Fdbg.c | 3 +- src/H5Fdeprec.c | 1 - src/H5Fefc.c | 27 +- src/H5Ffake.c | 1 - src/H5Fint.c | 214 +- src/H5Fio.c | 1 - src/H5Fmodule.h | 1176 +++- src/H5Fmount.c | 17 +- src/H5Fmpi.c | 199 +- src/H5Fpkg.h | 47 +- src/H5Fprivate.h | 54 +- src/H5Fpublic.h | 22 +- src/H5Fquery.c | 1 - src/H5Fsfile.c | 5 +- src/H5Fspace.c | 1 - src/H5Fsuper.c | 41 +- src/H5Fsuper_cache.c | 135 +- src/H5Ftest.c | 5 +- src/H5G.c | 19 +- src/H5Gbtree2.c | 17 +- src/H5Gcache.c | 15 +- src/H5Gcompact.c | 11 +- src/H5Gdense.c | 85 +- src/H5Gdeprec.c | 45 +- src/H5Gent.c | 8 +- src/H5Gint.c | 59 +- src/H5Glink.c | 1 - src/H5Gloc.c | 27 +- src/H5Gmodule.h | 854 ++- src/H5Gname.c | 31 +- src/H5Gnode.c | 61 +- src/H5Gobj.c | 13 +- src/H5Goh.c | 15 +- src/H5Gpkg.h | 31 +- src/H5Gprivate.h | 35 +- src/H5Gpublic.h | 33 +- src/H5Groot.c | 1 - src/H5Gstab.c | 31 +- src/H5Gtest.c | 25 +- src/H5Gtraverse.c | 11 +- src/H5HF.c | 9 +- src/H5HFbtree2.c | 23 +- src/H5HFcache.c | 79 +- src/H5HFdbg.c | 19 +- src/H5HFdblock.c | 9 +- src/H5HFdtable.c | 1 - src/H5HFhdr.c | 5 +- src/H5HFhuge.c | 7 +- src/H5HFiblock.c | 7 +- src/H5HFiter.c | 1 - src/H5HFman.c | 7 +- src/H5HFpkg.h | 31 +- src/H5HFprivate.h | 1 - src/H5HFsection.c | 69 +- src/H5HFspace.c | 5 +- src/H5HFstat.c | 3 +- src/H5HFtest.c | 1 - src/H5HFtiny.c | 1 - src/H5HG.c | 15 +- src/H5HGcache.c | 9 +- src/H5HGdbg.c | 3 +- src/H5HGpkg.h | 5 +- src/H5HGprivate.h | 5 +- src/H5HGquery.c | 1 - src/H5HL.c | 407 +- src/H5HLcache.c | 127 +- src/H5HLdbg.c | 33 +- src/H5HLdblk.c | 83 +- src/H5HLint.c | 61 +- src/H5HLpkg.h | 5 +- src/H5HLprfx.c | 34 +- src/H5HLprivate.h | 15 +- src/H5HP.c | 904 --- src/H5HPprivate.h | 68 - src/H5I.c | 13 +- src/H5Idbg.c | 13 +- src/H5Iint.c | 61 +- src/H5Imodule.h | 88 +- src/H5Ipkg.h | 22 +- src/H5Iprivate.h | 9 +- src/H5Ipublic.h | 36 +- src/H5Itest.c | 1 - src/H5L.c | 81 +- src/H5Ldeprec.c | 15 +- src/H5Lexternal.c | 27 +- src/H5Lmodule.h | 34 +- src/H5Lpkg.h | 1 - src/H5Lprivate.h | 9 +- src/H5Lpublic.h | 39 +- src/H5M.c | 23 +- src/H5MF.c | 150 +- src/H5MFaggr.c | 45 +- src/H5MFdbg.c | 7 +- src/H5MFpkg.h | 9 +- src/H5MFprivate.h | 1 - src/H5MFsection.c | 51 +- src/H5MM.c | 3 +- src/H5MMprivate.h | 17 +- src/H5MMpublic.h | 3 - src/H5MP.c | 446 -- src/H5MPmodule.h | 32 - src/H5MPpkg.h | 99 - src/H5MPprivate.h | 57 - src/H5MPtest.c | 213 - src/H5Mmodule.h | 18 +- src/H5Mpkg.h | 1 - src/H5Mprivate.h | 1 - src/H5Mpublic.h | 8 +- src/H5O.c | 53 +- src/H5Oainfo.c | 19 +- src/H5Oalloc.c | 41 +- src/H5Oattr.c | 18 +- src/H5Oattribute.c | 55 +- src/H5Obogus.c | 9 +- src/H5Obtreek.c | 13 +- src/H5Ocache.c | 46 +- src/H5Ocache_image.c | 11 +- src/H5Ochunk.c | 5 +- src/H5Ocont.c | 5 +- src/H5Ocopy.c | 60 +- src/H5Ocopy_ref.c | 30 +- src/H5Odbg.c | 5 +- src/H5Odeprec.c | 29 +- src/H5Odrvinfo.c | 13 +- src/H5Odtype.c | 560 +- src/H5Oefl.c | 128 +- src/H5Ofill.c | 52 +- src/H5Oflush.c | 37 +- src/H5Ofsinfo.c | 30 +- src/H5Oginfo.c | 15 +- src/H5Oint.c | 53 +- src/H5Olayout.c | 299 +- src/H5Olinfo.c | 55 +- src/H5Olink.c | 19 +- src/H5Omessage.c | 46 +- src/H5Omodule.h | 48 +- src/H5Omtime.c | 27 +- src/H5Oname.c | 11 +- src/H5Onull.c | 3 +- src/H5Opkg.h | 25 +- src/H5Opline.c | 40 +- src/H5Oprivate.h | 79 +- src/H5Opublic.h | 715 +-- src/H5Orefcount.c | 13 +- src/H5Osdspace.c | 71 +- src/H5Oshared.c | 13 +- src/H5Oshared.h | 1 - src/H5Oshmesg.c | 13 +- src/H5Ostab.c | 21 +- src/H5Otest.c | 41 +- src/H5Ounknown.c | 3 +- src/H5P.c | 21 +- src/H5PB.c | 21 +- src/H5PBpkg.h | 3 +- src/H5PBprivate.h | 6 - src/H5PL.c | 16 +- src/H5PLextern.h | 2 +- src/H5PLint.c | 42 +- src/H5PLmodule.h | 37 +- src/H5PLpath.c | 47 +- src/H5PLpkg.h | 1 - src/H5PLplugin_cache.c | 8 +- src/H5PLprivate.h | 2 +- src/H5PLpublic.h | 11 +- src/H5Pacpl.c | 1 - src/H5Pdapl.c | 29 +- src/H5Pdcpl.c | 37 +- src/H5Pdeprec.c | 1 - src/H5Pdxpl.c | 35 +- src/H5Pencdec.c | 29 +- src/H5Pfapl.c | 109 +- src/H5Pfcpl.c | 15 +- src/H5Pfmpl.c | 1 - src/H5Pgcpl.c | 9 +- src/H5Pint.c | 107 +- src/H5Plapl.c | 21 +- src/H5Plcpl.c | 1 - src/H5Pmapl.c | 1 - src/H5Pmcpl.c | 1 - src/H5Pmodule.h | 1060 +++- src/H5Pocpl.c | 23 +- src/H5Pocpypl.c | 19 +- src/H5Ppkg.h | 27 +- src/H5Pprivate.h | 19 +- src/H5Ppublic.h | 458 +- src/H5Pstrcpl.c | 5 +- src/H5Ptest.c | 3 +- src/H5R.c | 35 +- src/H5RS.c | 17 +- src/H5RSprivate.h | 3 +- src/H5Rdeprec.c | 33 +- src/H5Rint.c | 48 +- src/H5Rmodule.h | 14 +- src/H5Rpkg.h | 9 +- src/H5Rprivate.h | 1 - src/H5Rpublic.h | 23 +- src/H5S.c | 28 +- src/H5SL.c | 699 +-- src/H5SLprivate.h | 23 +- src/H5SM.c | 85 +- src/H5SMbtree2.c | 7 +- src/H5SMcache.c | 27 +- src/H5SMmessage.c | 7 +- src/H5SMpkg.h | 11 +- src/H5SMprivate.h | 1 - src/H5SMtest.c | 3 +- src/H5Sall.c | 53 +- src/H5Sdbg.c | 1 - src/H5Sdeprec.c | 1 - src/H5Shyper.c | 341 +- src/H5Smodule.h | 1533 ++++- src/H5Smpio.c | 120 +- src/H5Snone.c | 52 +- src/H5Spkg.h | 40 +- src/H5Spoint.c | 139 +- src/H5Sprivate.h | 77 +- src/H5Spublic.h | 114 +- src/H5Sselect.c | 132 +- src/H5Stest.c | 13 +- src/H5T.c | 271 +- src/H5TS.c | 15 +- src/H5TSprivate.h | 9 +- src/H5Tarray.c | 11 +- src/H5Tbit.c | 14 +- src/H5Tcommit.c | 39 +- src/H5Tcompound.c | 3 +- src/H5Tconv.c | 243 +- src/H5Tcset.c | 3 +- src/H5Tdbg.c | 1 - src/H5Tdeprec.c | 13 +- src/H5Tenum.c | 11 +- src/H5Tfields.c | 7 +- src/H5Tfixed.c | 3 +- src/H5Tfloat.c | 5 +- src/H5Tmodule.h | 3869 +++++++++++- src/H5Tnative.c | 52 +- src/H5Toffset.c | 3 +- src/H5Toh.c | 13 +- src/H5Topaque.c | 5 +- src/H5Torder.c | 3 +- src/H5Tpad.c | 1 - src/H5Tpkg.h | 39 +- src/H5Tprecis.c | 3 +- src/H5Tprivate.h | 83 +- src/H5Tpublic.h | 34 +- src/H5Tref.c | 63 +- src/H5Tstrpad.c | 3 +- src/H5Tvisit.c | 1 - src/H5Tvlen.c | 31 +- src/H5UC.c | 1 - src/H5UCprivate.h | 3 +- src/H5VL.c | 39 +- src/H5VLcallback.c | 104 +- src/H5VLconnector.h | 42 +- src/H5VLconnector_passthru.h | 28 +- src/H5VLint.c | 50 +- src/H5VLmodule.h | 100 +- src/H5VLnative.c | 10 +- src/H5VLnative.h | 21 +- src/H5VLnative_attr.c | 46 +- src/H5VLnative_blob.c | 8 +- src/H5VLnative_dataset.c | 69 +- src/H5VLnative_datatype.c | 12 +- src/H5VLnative_file.c | 86 +- src/H5VLnative_group.c | 18 +- src/H5VLnative_introspect.c | 2 +- src/H5VLnative_link.c | 16 +- src/H5VLnative_object.c | 10 +- src/H5VLnative_private.h | 20 +- src/H5VLnative_token.c | 4 +- src/H5VLpassthru.c | 101 +- src/H5VLprivate.h | 36 +- src/H5VLpublic.h | 15 +- src/H5VM.c | 19 +- src/H5VMprivate.h | 5 +- src/H5WB.c | 11 +- src/H5WBprivate.h | 5 +- src/H5Z.c | 21 +- src/H5Zdeflate.c | 5 +- src/H5Zfletcher32.c | 5 +- src/H5Zmodule.h | 112 +- src/H5Znbit.c | 46 +- src/H5Zpkg.h | 1 - src/H5Zprivate.h | 19 +- src/H5Zpublic.h | 12 +- src/H5Zscaleoffset.c | 128 +- src/H5Zshuffle.c | 5 +- src/H5Zszip.c | 5 +- src/H5Ztrans.c | 125 +- src/H5api_adpt.h | 1 - src/H5checksum.c | 1 - src/H5config.h.in | 37 +- src/H5dbg.c | 1 - src/H5detect.c | 23 +- src/H5err.txt | 1 - src/H5make_libsettings.c | 6 +- src/H5module.h | 1437 ++++- src/H5mpi.c | 244 +- src/H5overflow.h | 1 - src/H5overflow.txt | 1 - src/H5private.h | 1356 ++-- src/H5public.h | 110 +- src/H5system.c | 281 +- src/H5timer.c | 16 +- src/H5trace.c | 26 +- src/H5vers.txt | 1 - src/H5version.h | 1 - src/H5win32defs.h | 91 +- src/hdf5.h | 1 - src/libhdf5.settings.in | 51 +- src/uthash.h | 121 +- 695 files changed, 41339 insertions(+), 19970 deletions(-) create mode 100644 README.md delete mode 100644 README.txt delete mode 100644 config/clang-warnings/noerror-general rename config/{cmake_ext_mod => cmake}/GetTimeOfDayTest.cpp (100%) delete mode 100644 config/cmake/H5cxx_config.h.in create mode 100644 config/cmake/HDF5DeveloperBuild.cmake create mode 100644 config/cmake/HDFLibMacros.cmake rename config/{cmake_ext_mod => cmake}/HDFMacros.cmake (79%) rename config/{cmake_ext_mod => cmake}/HDFTests.c (98%) rename config/{cmake_ext_mod => cmake}/HDFUseFortran.cmake (99%) create mode 100644 config/cmake/LIBAEC/CMakeLists.txt create mode 100644 config/cmake/LIBAEC/CPack.Info.plist.in create mode 100644 config/cmake/LIBAEC/config.h.in create mode 100644 config/cmake/LIBAEC/libaec-config-version.cmake.in create mode 100644 config/cmake/LIBAEC/libaec-config.cmake.in rename config/{cmake_ext_mod => cmake}/NSIS.InstallOptions.ini.in (100%) rename config/{cmake_ext_mod => cmake}/NSIS.template.in (99%) rename config/cmake/{README.txt.cmake.in => README.md.cmake.in} (94%) create mode 100644 config/cmake/ZLIB/CMakeLists.txt create mode 100644 config/cmake/ZLIB/CPack.Info.plist.in create mode 100644 config/cmake/ZLIB/zconf.h.in create mode 100644 config/cmake/ZLIB/zlib-config-version.cmake.in create mode 100644 config/cmake/ZLIB/zlib-config.cmake.in rename config/cmake/{ => examples}/CTestScript.cmake (87%) rename config/cmake/{ => examples}/HDF5_Examples.cmake.in (86%) rename config/cmake/{ => examples}/HDF5_Examples_options.cmake (78%) rename config/{cmake_ext_mod => cmake}/grepTest.cmake (93%) rename config/{cmake_ext_mod => cmake}/hdf.bmp (100%) rename config/{cmake_ext_mod => cmake}/hdf.icns (100%) rename config/{cmake_ext_mod => cmake}/hdf.ico (100%) create mode 100644 config/cmake/javaTargets.cmake.in delete mode 100644 config/cmake/jvolTest.cmake rename config/cmake/{patch.xml => patch.xml.in} (80%) rename config/{cmake_ext_mod => cmake}/runTest.cmake (93%) rename config/{cmake_ext_mod => cmake}/version.plist.in (100%) delete mode 100644 config/cmake_ext_mod/CTestCustom.cmake delete mode 100644 config/cmake_ext_mod/ConfigureChecks.cmake delete mode 100644 config/cmake_ext_mod/FindSZIP.cmake delete mode 100644 config/cmake_ext_mod/HDFCXXTests.cpp delete mode 100644 config/cmake_ext_mod/HDFLibMacros.cmake delete mode 100644 config/cmake_ext_mod/HDFUseCXX.cmake create mode 100644 config/gnu-warnings/cxx-developer-4.8 delete mode 100644 config/gnu-warnings/cxx-noerror-5 delete mode 100644 config/gnu-warnings/cxx-noerror-general create mode 100644 config/gnu-warnings/developer-12 create mode 100644 config/gnu-warnings/error-7 create mode 100644 config/gnu-warnings/gfort-developer-4.8 rename config/gnu-warnings/{gfort-5 => gfort-developer-5} (100%) create mode 100644 config/gnu-warnings/gfort-developer-general create mode 100644 config/gnu-warnings/gfort-no-developer-4.8 create mode 100644 config/gnu-warnings/gfort-no-developer-general create mode 100644 config/gnu-warnings/no-cxx-developer-4.8 delete mode 100644 config/gnu-warnings/noerror-5 delete mode 100644 config/gnu-warnings/noerror-8 delete mode 100644 config/gnu-warnings/noerror-general delete mode 100644 config/intel-warnings/general-19 create mode 100644 config/intel-warnings/win-developer-general create mode 100644 config/intel-warnings/win-general create mode 100644 config/intel-warnings/win-ifort-general delete mode 100644 src/H5HP.c delete mode 100644 src/H5HPprivate.h delete mode 100644 src/H5MP.c delete mode 100644 src/H5MPmodule.h delete mode 100644 src/H5MPpkg.h delete mode 100644 src/H5MPprivate.h delete mode 100644 src/H5MPtest.c diff --git a/.clang-format b/.clang-format index 62dc6b584b2..b51da2ad353 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,20 @@ --- -Language: Cpp BasedOnStyle: LLVM AlignConsecutiveAssignments: true +BraceWrapping: + AfterFunction: true + #llvm10-11: AfterControlStatement: false - Never + BeforeCatch: true + BeforeElse: true + #llvm11: BeforeLambdaBody: false + #llvm11: BeforeWhile: false +BreakBeforeBraces: Stroustrup +BreakAfterJavaFieldAnnotations: true +BreakStringLiterals: true +ColumnLimit: 110 # Update $max_trace_macro_line_len in bin/trace also +IndentWidth: 4 +--- +Language: Cpp #llvm11: AlignConsecutiveBitFields: false AlignConsecutiveDeclarations: true AlignConsecutiveMacros: true @@ -22,17 +35,6 @@ AlwaysBreakAfterReturnType: AllDefinitions # - H5_ATTR_CONST # - H5_ATTR_PURE # - H5_ATTR_FALLTHROUGH -BraceWrapping: - AfterFunction: true - #llvm10-11: AfterControlStatement: false - Never - BeforeCatch: true - BeforeElse: true - #llvm11: BeforeLambdaBody: false - #llvm11: BeforeWhile: false -BreakBeforeBraces: Stroustrup -BreakAfterJavaFieldAnnotations: true -BreakStringLiterals: true -ColumnLimit: 110 # Update $max_trace_macro_line_len in bin/trace also ForEachMacros: ['ALL_MEMBERS', 'UNIQUE_MEMBERS'] IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' @@ -55,7 +57,6 @@ IndentCaseLabels: true #llvm11: IndentCaseBlocks: false IndentGotoLabels: false #llvm11: IndentExternBlock: AfterExternBlock -IndentWidth: 4 #llvm11: InsertTrailingCommas: None MacroBlockBegin: "^BEGIN_FUNC" MacroBlockEnd: "^END_FUNC" @@ -92,5 +93,8 @@ StatementMacros: #llvm11: WhitespaceSensitiveMacros: #llvm11: - STRINGIZE #llvm11: - PP_STRINGIZE +--- +Language: Java +BreakAfterJavaFieldAnnotations: true +JavaImportGroups: ['java', 'hdf', 'hdf.hdf5lib', 'org'] ... - diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake index d5f801e2895..31643b7d792 100644 --- a/CMakeFilters.cmake +++ b/CMakeFilters.cmake @@ -9,17 +9,35 @@ # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # -option (USE_LIBAEC "Use AEC library as SZip Filter" OFF) +option (USE_LIBAEC_STATIC "Use static AEC library " OFF) +option (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" OFF) +option (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" OFF) -include (ExternalProject) -include (FetchContent) +if (NOT ZLIB_USE_LOCALCONTENT) + set (ZLIB_URL ${ZLIB_TGZ_ORIGPATH}/${ZLIB_TGZ_NAME}) +else () + set (ZLIB_URL ${TGZPATH}/${ZLIB_TGZ_NAME}) +endif () +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter ZLIB file is ${ZLIB_URL}") +endif () + +if (NOT LIBAEC_USE_LOCALCONTENT) + set (SZIP_URL ${LIBAEC_TGZ_ORIGPATH}/${LIBAEC_TGZ_NAME}) +else () + set (SZIP_URL ${TGZPATH}/${LIBAEC_TGZ_NAME}) +endif () +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter SZIP file is ${SZIP_URL}") +endif () +include (ExternalProject) #option (HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building (NO GIT TGZ)" "NO") set (HDF5_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building (NO GIT TGZ)") set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT TGZ) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") - option (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" 1) - option (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 1) + set (ZLIB_USE_EXTERNAL ON CACHE BOOL "Use External Library Building for ZLIB" FORCE) + set (SZIP_USE_EXTERNAL ON CACHE BOOL "Use External Library Building for SZIP" FORCE) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT") set (ZLIB_URL ${ZLIB_GIT_URL} CACHE STRING "Path to zlib git repository") set (ZLIB_BRANCH ${ZLIB_GIT_BRANCH}) @@ -29,62 +47,54 @@ if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MAT if (NOT TGZPATH) set (TGZPATH ${HDF5_SOURCE_DIR}) endif () - set (ZLIB_URL ${TGZPATH}/${ZLIB_TGZ_NAME}) - if (NOT EXISTS "${ZLIB_URL}") - set (HDF5_ENABLE_Z_LIB_SUPPORT OFF CACHE BOOL "" FORCE) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Filter ZLIB file ${ZLIB_URL} not found") + if (ZLIB_USE_LOCALCONTENT) + if (NOT EXISTS "${ZLIB_URL}") + set (HDF5_ENABLE_Z_LIB_SUPPORT OFF CACHE BOOL "" FORCE) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter ZLIB file ${ZLIB_URL} not found") + endif () endif () endif () - set (SZIP_URL ${TGZPATH}/${SZIP_TGZ_NAME}) - if (USE_LIBAEC) - set (SZIP_URL ${TGZPATH}/${SZAEC_TGZ_NAME}) - endif () - if (NOT EXISTS "${SZIP_URL}") - set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Filter SZIP file ${SZIP_URL} not found") + if (LIBAEC_USE_LOCALCONTENT) + if (NOT EXISTS "${SZIP_URL}") + set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter SZIP file ${SZIP_URL} not found") + endif () endif () endif () else () - set (ZLIB_USE_EXTERNAL 0) - set (SZIP_USE_EXTERNAL 0) + set (HDF5_ENABLE_Z_LIB_SUPPORT OFF CACHE BOOL "" FORCE) + set (ZLIB_USE_EXTERNAL OFF CACHE BOOL "Use External Library Building for ZLIB") + set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE) + set (SZIP_USE_EXTERNAL OFF CACHE BOOL "Use External Library Building for SZIP") endif () endif () #----------------------------------------------------------------------------- # Option for ZLib support #----------------------------------------------------------------------------- -option (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF) +option (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" ON) if (HDF5_ENABLE_Z_LIB_SUPPORT) if (NOT H5_ZLIB_HEADER) if (NOT ZLIB_USE_EXTERNAL) find_package (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared) if (NOT ZLIB_FOUND) find_package (ZLIB) # Legacy find - if (ZLIB_FOUND) - set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_LIBRARIES}) - endif () endif () - endif () - if (ZLIB_FOUND) - set (H5_HAVE_FILTER_DEFLATE 1) - set (H5_HAVE_ZLIB_H 1) - set (H5_HAVE_LIBZ 1) - set (H5_ZLIB_HEADER "zlib.h") - set (ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR}) - set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) + if (ZLIB_FOUND) + set (H5_ZLIB_HEADER "zlib.h") + set (ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR}) + set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_LIBRARIES}) + endif () else () if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") EXTERNAL_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT}) - set (H5_HAVE_FILTER_DEFLATE 1) - set (H5_HAVE_ZLIB_H 1) - set (H5_HAVE_LIBZ 1) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Filter ZLIB is built") + message (VERBOSE "Filter HDF5_ZLIB is built") endif () - else () - message (FATAL_ERROR " ZLib is Required for ZLib support in HDF5") + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_STATIC_LIBRARY}) endif () endif () else () @@ -93,13 +103,20 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) set (H5_HAVE_ZLIB_H 1) set (H5_HAVE_LIBZ 1) endif () - if (H5_HAVE_FILTER_DEFLATE) - set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DEFLATE") - endif () - set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_STATIC_LIBRARY}) - INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS}) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Filter ZLIB is ON") + if (ZLIB_FOUND) + set (H5_HAVE_FILTER_DEFLATE 1) + set (H5_HAVE_ZLIB_H 1) + set (H5_HAVE_LIBZ 1) + if (H5_HAVE_FILTER_DEFLATE) + set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DEFLATE") + endif () + INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter HDF5_ZLIB is ON") + endif () + else () + set (HDF5_ENABLE_Z_LIB_SUPPORT OFF CACHE BOOL "" FORCE) + message (WARNING " ZLib support in HDF5 was enabled but not found") endif () endif () @@ -108,53 +125,52 @@ endif () #----------------------------------------------------------------------------- option (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF) if (HDF5_ENABLE_SZIP_SUPPORT) - option (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) + option (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" ON) if (NOT SZIP_USE_EXTERNAL) - find_package (SZIP NAMES ${SZIP_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared) + set(SZIP_FOUND FALSE) + set(libaec_USE_STATIC_LIBS ${USE_LIBAEC_STATIC}) + find_package (libaec 1.0.5 CONFIG) + if (SZIP_FOUND) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) + endif () if (NOT SZIP_FOUND) - find_package (SZIP) # Legacy find - if (SZIP_FOUND) - set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) + find_package (SZIP NAMES ${LIBAEC_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared) + if (NOT SZIP_FOUND) + find_package (SZIP) # Legacy find endif () endif () - endif () - if (SZIP_FOUND) - set (H5_HAVE_FILTER_SZIP 1) - set (H5_HAVE_SZLIB_H 1) - set (H5_HAVE_LIBSZ 1) - set (SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR}) - set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR}) + if (SZIP_FOUND) + set (SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR}) + set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR}) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) + endif () else () if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") EXTERNAL_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT} ${HDF5_ENABLE_SZIP_ENCODING}) - set (H5_HAVE_FILTER_SZIP 1) - set (H5_HAVE_SZLIB_H 1) - set (H5_HAVE_LIBSZ 1) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") message (VERBOSE "Filter SZIP is built") + message (VERBOSE "... with library AEC") endif () - if (USE_LIBAEC) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "... with library AEC") - endif () - set (SZ_PACKAGE_NAME ${LIBAEC_PACKAGE_NAME}) - else () - set (SZ_PACKAGE_NAME ${SZIP_PACKAGE_NAME}) - endif () - else () - message (FATAL_ERROR "SZIP is Required for SZIP support in HDF5") + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_STATIC_LIBRARY}) endif () endif () - set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_STATIC_LIBRARY}) - INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "Filter SZIP is ON") - endif () - if (H5_HAVE_FILTER_SZIP) - set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DECODE") - endif () - if (HDF5_ENABLE_SZIP_ENCODING) - set (H5_HAVE_SZIP_ENCODER 1) - set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} ENCODE") + if (SZIP_FOUND) + set (H5_HAVE_FILTER_SZIP 1) + set (H5_HAVE_SZLIB_H 1) + set (H5_HAVE_LIBSZ 1) + INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter SZIP is ON") + endif () + if (H5_HAVE_FILTER_SZIP) + set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DECODE") + endif () + if (HDF5_ENABLE_SZIP_ENCODING) + set (H5_HAVE_SZIP_ENCODER 1) + set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} ENCODE") + endif () + else () + set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE) + message (WARNING "SZIP support in HDF5 was enabled but not found") endif () endif () diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 65be97154f3..df12edb5ded 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -31,7 +31,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) if (HDF5_EXPORTED_TARGETS) install ( EXPORT ${HDF5_EXPORTED_TARGETS} - DESTINATION ${HDF5_INSTALL_CMAKE_DIR}/hdf5 + DESTINATION ${HDF5_INSTALL_CMAKE_DIR} FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake NAMESPACE ${HDF_PACKAGE_NAMESPACE} COMPONENT configinstall @@ -52,7 +52,7 @@ endif () # Set includes needed for build #----------------------------------------------------------------------------- set (HDF5_INCLUDES_BUILD_TIME - ${HDF5_SRC_DIR} ${HDF5_CPP_SRC_DIR} ${HDF5_HL_SRC_DIR} + ${HDF5_SRC_INCLUDE_DIRS} ${HDF5_CPP_SRC_DIR} ${HDF5_HL_SRC_DIR} ${HDF5_TOOLS_SRC_DIR} ${HDF5_SRC_BINARY_DIR} ) @@ -72,7 +72,7 @@ set (CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" ) configure_package_config_file ( ${HDF_RESOURCES_DIR}/hdf5-config.cmake.in "${HDF5_BINARY_DIR}/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake" - INSTALL_DESTINATION "${HDF5_INSTALL_CMAKE_DIR}/hdf5" + INSTALL_DESTINATION "${HDF5_INSTALL_CMAKE_DIR}" PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}" ) @@ -86,14 +86,14 @@ set (CURRENT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}" ) configure_package_config_file ( ${HDF_RESOURCES_DIR}/hdf5-config.cmake.in "${HDF5_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake" - INSTALL_DESTINATION "${HDF5_INSTALL_CMAKE_DIR}/hdf5" + INSTALL_DESTINATION "${HDF5_INSTALL_CMAKE_DIR}" PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR ) if (NOT HDF5_EXTERNALLY_CONFIGURED) install ( FILES ${HDF5_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake - DESTINATION ${HDF5_INSTALL_CMAKE_DIR}/hdf5 + DESTINATION ${HDF5_INSTALL_CMAKE_DIR} COMPONENT configinstall ) endif () @@ -109,7 +109,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) ) install ( FILES ${HDF5_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config-version.cmake - DESTINATION ${HDF5_INSTALL_CMAKE_DIR}/hdf5 + DESTINATION ${HDF5_INSTALL_CMAKE_DIR} COMPONENT configinstall ) endif () @@ -138,7 +138,7 @@ install ( option (HDF5_PACK_EXAMPLES "Package the HDF5 Library Examples Compressed File" OFF) if (HDF5_PACK_EXAMPLES) configure_file ( - ${HDF_RESOURCES_DIR}/HDF5_Examples.cmake.in + ${HDF_RESOURCES_DIR}/examples/HDF5_Examples.cmake.in ${HDF5_BINARY_DIR}/HDF5_Examples.cmake @ONLY ) install ( @@ -146,17 +146,58 @@ if (HDF5_PACK_EXAMPLES) DESTINATION ${HDF5_INSTALL_DATA_DIR} COMPONENT hdfdocuments ) - if (EXISTS "${HDF5_EXAMPLES_COMPRESSED_DIR}/${HDF5_EXAMPLES_COMPRESSED}") - execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${HDF5_EXAMPLES_COMPRESSED_DIR}/${HDF5_EXAMPLES_COMPRESSED} - ) - install ( - DIRECTORY ${HDF5_BINARY_DIR}/HDF5Examples - DESTINATION ${HDF5_INSTALL_DATA_DIR} - USE_SOURCE_PERMISSIONS - COMPONENT hdfdocuments - ) + + option (EXAMPLES_DOWNLOAD "Download to use released examples files" OFF) + if (EXAMPLES_DOWNLOAD) + option (EXAMPLES_USE_RELEASE_NAME "Use the released examples artifact name" OFF) + if (EXAMPLES_USE_RELEASE_NAME) + set (EXAMPLES_NAME ${EXAMPLES_TGZ_ORIGNAME}) + else () + set (EXAMPLES_NAME ${HDF5_EXAMPLES_COMPRESSED}) + endif () + if (NOT EXAMPLES_USE_LOCALCONTENT) + set (EXAMPLES_URL ${EXAMPLES_TGZ_ORIGPATH}/${EXAMPLES_NAME}) + file (DOWNLOAD ${EXAMPLES_URL} ${HDF5_BINARY_DIR}/${HDF5_EXAMPLES_COMPRESSED} STATUS EX_DL) + message (STATUS "Examples file is ${EXAMPLES_URL} STATUS=${EX_DL}") + else () + set (EXAMPLES_URL ${TGZPATH}/${EXAMPLES_NAME}) + file (COPY_FILE ${EXAMPLES_URL} ${HDF5_BINARY_DIR}/${HDF5_EXAMPLES_COMPRESSED} RESULT EX_DL) + message (STATUS "Examples file is ${EXAMPLES_URL} RESULT=${EX_DL}") + endif () + if (EXISTS "${HDF5_BINARY_DIR}/${HDF5_EXAMPLES_COMPRESSED}") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf ${HDF5_EXAMPLES_COMPRESSED} + WORKING_DIRECTORY ${HDF5_BINARY_DIR} + COMMAND_ECHO STDOUT + ) + endif () + else () + if (EXISTS "${HDF5_EXAMPLES_COMPRESSED_DIR}/${HDF5_EXAMPLES_COMPRESSED}") + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf ${HDF5_EXAMPLES_COMPRESSED_DIR}/${HDF5_EXAMPLES_COMPRESSED} + WORKING_DIRECTORY ${HDF5_BINARY_DIR} + COMMAND_ECHO STDOUT + ) + endif () + endif () + get_filename_component (EX_LAST_EXT ${HDF5_EXAMPLES_COMPRESSED} LAST_EXT) + if (${EX_LAST_EXT} STREQUAL ".zip") + get_filename_component (EX_DIR_NAME ${HDF5_EXAMPLES_COMPRESSED} NAME_WLE) + else () + get_filename_component (EX_DIR_NAME ${HDF5_EXAMPLES_COMPRESSED} NAME_WLE) + get_filename_component (EX_DIR_NAME ${EX_DIR_NAME} NAME_WLE) endif () + execute_process( + COMMAND ${CMAKE_COMMAND} -E rename ${EX_DIR_NAME} HDF5Examples + WORKING_DIRECTORY ${HDF5_BINARY_DIR} + COMMAND_ECHO STDOUT + ) + install ( + DIRECTORY ${HDF5_BINARY_DIR}/HDF5Examples + DESTINATION ${HDF5_INSTALL_DATA_DIR} + USE_SOURCE_PERMISSIONS + COMPONENT hdfdocuments + ) install ( FILES ${HDF5_SOURCE_DIR}/release_docs/USING_CMake_Examples.txt @@ -165,20 +206,20 @@ if (HDF5_PACK_EXAMPLES) ) install ( FILES - ${HDF_RESOURCES_DIR}/CTestScript.cmake + ${HDF_RESOURCES_DIR}/examples/CTestScript.cmake DESTINATION ${HDF5_INSTALL_DATA_DIR} COMPONENT hdfdocuments ) install ( FILES - ${HDF_RESOURCES_DIR}/HDF5_Examples_options.cmake + ${HDF_RESOURCES_DIR}/examples/HDF5_Examples_options.cmake DESTINATION ${HDF5_INSTALL_DATA_DIR} COMPONENT hdfdocuments ) endif () #----------------------------------------------------------------------------- -# Configure the README.txt file for the binary package +# Configure the README.md file for the binary package #----------------------------------------------------------------------------- HDF_README_PROPERTIES(HDF5_BUILD_FORTRAN) @@ -238,7 +279,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED) endif () install ( FILES ${release_files} - DESTINATION ${HDF5_INSTALL_DATA_DIR} + DESTINATION ${HDF5_INSTALL_DOC_DIR} COMPONENT hdfdocuments ) endif () @@ -269,7 +310,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) else () set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}/${CPACK_PACKAGE_NAME}/${CPACK_PACKAGE_VERSION}") endif () - set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_EXT_DIR}/hdf.bmp") + set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_DIR}/hdf.bmp") set (CPACK_GENERATOR "TGZ") if (WIN32) @@ -290,12 +331,12 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") endif () - # set the install/unistall icon used for the installer itself + # set the install/uninstall icon used for the installer itself # There is a bug in NSI that does not handle full unix paths properly. - set (CPACK_NSIS_MUI_ICON "${HDF_RESOURCES_EXT_DIR}\\\\hdf.ico") - set (CPACK_NSIS_MUI_UNIICON "${HDF_RESOURCES_EXT_DIR}\\\\hdf.ico") + set (CPACK_NSIS_MUI_ICON "${HDF_RESOURCES_DIR}\\\\hdf.ico") + set (CPACK_NSIS_MUI_UNIICON "${HDF_RESOURCES_DIR}\\\\hdf.ico") # set the package header icon for MUI - set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_EXT_DIR}\\\\hdf.bmp") + set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_DIR}\\\\hdf.bmp") set (CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_PACKAGE_NAME}") if (OVERRIDE_INSTALL_VERSION) set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}\\\\${CPACK_PACKAGE_NAME}\\\\${OVERRIDE_INSTALL_VERSION}") @@ -325,7 +366,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_RESOURCE_FILE_LICENSE "${HDF5_BINARY_DIR}/COPYING.txt") # .. variable:: CPACK_WIX_PRODUCT_ICON # The Icon shown next to the program name in Add/Remove programs. - set(CPACK_WIX_PRODUCT_ICON "${HDF_RESOURCES_EXT_DIR}\\\\hdf.ico") + set(CPACK_WIX_PRODUCT_ICON "${HDF_RESOURCES_DIR}\\\\hdf.ico") # # .. variable:: CPACK_WIX_UI_BANNER # @@ -349,21 +390,27 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "${HDF5_PACKAGE_URL}") set(CPACK_WIX_PROPERTY_ARPHELPLINK "${HDF5_PACKAGE_BUGREPORT}") if (BUILD_SHARED_LIBS) - set(CPACK_WIX_PATCH_FILE "${HDF_RESOURCES_DIR}/patch.xml") + if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer") + set (WIX_CMP_NAME "${HDF5_LIB_NAME}${CMAKE_DEBUG_POSTFIX}") + else () + set (WIX_CMP_NAME "${HDF5_LIB_NAME}") + endif () + configure_file (${HDF_RESOURCES_DIR}/patch.xml.in ${HDF5_BINARY_DIR}/patch.xml @ONLY) + set(CPACK_WIX_PATCH_FILE "${HDF5_BINARY_DIR}/patch.xml") endif () elseif (APPLE) list (APPEND CPACK_GENERATOR "STGZ") list (APPEND CPACK_GENERATOR "DragNDrop") set (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) set (CPACK_PACKAGING_INSTALL_PREFIX "/${CPACK_PACKAGE_INSTALL_DIRECTORY}") - set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_EXT_DIR}/hdf.icns") + set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_DIR}/hdf.icns") option (HDF5_PACK_MACOSX_FRAMEWORK "Package the HDF5 Library in a Frameworks" OFF) if (HDF5_PACK_MACOSX_FRAMEWORK AND HDF5_BUILD_FRAMEWORKS) set (CPACK_BUNDLE_NAME "${HDF5_PACKAGE_STRING}") set (CPACK_BUNDLE_LOCATION "/") # make sure CMAKE_INSTALL_PREFIX ends in / set (CMAKE_INSTALL_PREFIX "/${CPACK_BUNDLE_NAME}.framework/Versions/${CPACK_PACKAGE_VERSION}/${CPACK_PACKAGE_NAME}/") - set (CPACK_BUNDLE_ICON "${HDF_RESOURCES_EXT_DIR}/hdf.icns") + set (CPACK_BUNDLE_ICON "${HDF_RESOURCES_DIR}/hdf.icns") set (CPACK_BUNDLE_PLIST "${HDF5_BINARY_DIR}/CMakeFiles/Info.plist") set (CPACK_SHORT_VERSION_STRING "${CPACK_PACKAGE_VERSION}") #----------------------------------------------------------------------------- @@ -378,7 +425,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) ${HDF5_BINARY_DIR}/CMakeFiles/PkgInfo @ONLY ) configure_file ( - ${HDF_RESOURCES_EXT_DIR}/version.plist.in + ${HDF_RESOURCES_DIR}/version.plist.in ${HDF5_BINARY_DIR}/CMakeFiles/version.plist @ONLY ) install ( @@ -391,18 +438,29 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_PACKAGING_INSTALL_PREFIX "/${CPACK_PACKAGE_INSTALL_DIRECTORY}") set (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) - set (CPACK_DEBIAN_PACKAGE_SECTION "Libraries") - set (CPACK_DEBIAN_PACKAGE_MAINTAINER "${HDF5_PACKAGE_BUGREPORT}") - -# list (APPEND CPACK_GENERATOR "RPM") - set (CPACK_RPM_PACKAGE_RELEASE "1") - set (CPACK_RPM_COMPONENT_INSTALL ON) - set (CPACK_RPM_PACKAGE_RELOCATABLE ON) - set (CPACK_RPM_PACKAGE_LICENSE "BSD-style") - set (CPACK_RPM_PACKAGE_GROUP "Development/Libraries") - set (CPACK_RPM_PACKAGE_URL "${HDF5_PACKAGE_URL}") - set (CPACK_RPM_PACKAGE_SUMMARY "HDF5 is a unique technology suite that makes possible the management of extremely large and complex data collections.") - set (CPACK_RPM_PACKAGE_DESCRIPTION + find_program (DPKGSHLIB_EXE dpkg-shlibdeps) + if (DPKGSHLIB_EXE) + list (APPEND CPACK_GENERATOR "DEB") + set (CPACK_DEBIAN_PACKAGE_SECTION "Libraries") + set (CPACK_DEBIAN_PACKAGE_MAINTAINER "${HDF5_PACKAGE_BUGREPORT}") + endif () + + find_program (RPMBUILD_EXE rpmbuild) + if (RPMBUILD_EXE) + list (APPEND CPACK_GENERATOR "RPM") + set (CPACK_RPM_PACKAGE_RELEASE "1") + set (CPACK_RPM_PACKAGE_RELEASE_DIST ON) + set (CPACK_RPM_COMPONENT_INSTALL ON) + set (CPACK_RPM_PACKAGE_RELOCATABLE ON) + set (CPACK_RPM_FILE_NAME "RPM-DEFAULT") + set (CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") + set (CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") + set (CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}") + set (CPACK_RPM_PACKAGE_LICENSE "BSD-style") + set (CPACK_RPM_PACKAGE_GROUP "Development/Libraries") + set (CPACK_RPM_PACKAGE_URL "${HDF5_PACKAGE_URL}") + set (CPACK_RPM_PACKAGE_SUMMARY "HDF5 is a unique technology suite that makes possible the management of extremely large and complex data collections.") + set (CPACK_RPM_PACKAGE_DESCRIPTION "The HDF5 technology suite includes: * A versatile data model that can represent very complex data objects and a wide variety of metadata. @@ -417,13 +475,14 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) The HDF5 data model, file format, API, library, and tools are open and distributed without charge. " - ) + ) - #----------------------------------------------------------------------------- - # Configure the spec file for the install RPM - #----------------------------------------------------------------------------- -# configure_file ("${HDF5_RESOURCES_DIR}/hdf5.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/${HDF5_PACKAGE_NAME}.spec" @ONLY IMMEDIATE) -# set (CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/${HDF5_PACKAGE_NAME}.spec") + #----------------------------------------------------------------------------- + # Configure the spec file for the install RPM + #----------------------------------------------------------------------------- +# configure_file ("${HDF5_RESOURCES_DIR}/hdf5.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/${HDF5_PACKAGE_NAME}.spec" @ONLY IMMEDIATE) +# set (CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/${HDF5_PACKAGE_NAME}.spec") + endif () endif () # By default, do not warn when built on machines using only VS Express: @@ -438,11 +497,11 @@ The HDF5 data model, file format, API, library, and tools are open and distribut if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") if (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) if (WIN32) - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;ALL;/") + set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;ALL;/") else () - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;libraries;/") - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;headers;/") - set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};ZLIB;configinstall;/") + set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;libraries;/") + set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;headers;/") + set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;configinstall;/") endif () endif () if (SZIP_FOUND AND SZIP_USE_EXTERNAL) diff --git a/CMakeLists.txt b/CMakeLists.txt index b75fdd2ce3b..7cd344b6052 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,13 +2,21 @@ cmake_minimum_required (VERSION 3.12) project (HDF5 C) if (POLICY CMP0074) + # find_package() uses _ROOT variables. cmake_policy (SET CMP0074 NEW) endif () if (POLICY CMP0083) + # To control generation of Position Independent Executable (PIE) or not, + # some flags are required at link time. cmake_policy (SET CMP0083 NEW) endif () +# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24: +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + cmake_policy(SET CMP0135 NEW) +endif() + #----------------------------------------------------------------------------- # Instructions for use : Normal Build # @@ -212,9 +220,9 @@ set (HDF5_HL_F90_C_LIBSH_TARGET "${HDF5_HL_F90_C_LIB_CORENAME}-shared") #----------------------------------------------------------------------------- set (HDF_CONFIG_DIR ${HDF5_SOURCE_DIR}/config) set (HDF_RESOURCES_DIR ${HDF5_SOURCE_DIR}/config/cmake) -set (HDF_RESOURCES_EXT_DIR ${HDF5_SOURCE_DIR}/config/cmake_ext_mod) set (HDF5_SRC_DIR ${HDF5_SOURCE_DIR}/src) set (HDF5_TEST_SRC_DIR ${HDF5_SOURCE_DIR}/test) +set (HDF5_TEST_PAR_DIR ${HDF5_SOURCE_DIR}/testpar) set (HDF5_CPP_SRC_DIR ${HDF5_SOURCE_DIR}/c++) set (HDF5_CPP_TST_DIR ${HDF5_SOURCE_DIR}/c++/test) set (HDF5_HL_SRC_DIR ${HDF5_SOURCE_DIR}/hl) @@ -229,11 +237,13 @@ set (HDF5_JAVA_JNI_SRC_DIR ${HDF5_SOURCE_DIR}/java/src/jni) set (HDF5_JAVA_HDF5_SRC_DIR ${HDF5_SOURCE_DIR}/java/src/hdf) set (HDF5_JAVA_TEST_SRC_DIR ${HDF5_SOURCE_DIR}/java/test) set (HDF5_JAVA_LIB_DIR ${HDF5_SOURCE_DIR}/java/lib) -set (HDF5_JAVA_LOGGING_JAR ${HDF5_SOURCE_DIR}/java/lib/slf4j-api-1.7.25.jar) -set (HDF5_JAVA_LOGGING_NOP_JAR ${HDF5_SOURCE_DIR}/java/lib/ext/slf4j-nop-1.7.25.jar) -set (HDF5_JAVA_LOGGING_SIMPLE_JAR ${HDF5_SOURCE_DIR}/java/lib/ext/slf4j-simple-1.7.25.jar) +set (HDF5_JAVA_LOGGING_JAR ${HDF5_SOURCE_DIR}/java/lib/slf4j-api-2.0.6.jar) +set (HDF5_JAVA_LOGGING_NOP_JAR ${HDF5_SOURCE_DIR}/java/lib/ext/slf4j-nop-2.0.6.jar) +set (HDF5_JAVA_LOGGING_SIMPLE_JAR ${HDF5_SOURCE_DIR}/java/lib/ext/slf4j-simple-2.0.6.jar) set (HDF5_DOXYGEN_DIR ${HDF5_SOURCE_DIR}/doxygen) +set (HDF5_SRC_INCLUDE_DIRS ${HDF5_SRC_DIR}) + #----------------------------------------------------------------------------- # parse the full version number from H5public.h and include in H5_VERS_INFO #----------------------------------------------------------------------------- @@ -427,14 +437,21 @@ set (HDF5_PACKAGE_TARNAME "${HDF5_PACKAGE}${HDF_PACKAGE_EXT}") set (HDF5_PACKAGE_URL "http://www.hdfgroup.org") set (HDF5_PACKAGE_BUGREPORT "help@hdfgroup.org") +#----------------------------------------------------------------------------- +# Set variables needed for installation +#----------------------------------------------------------------------------- +set (HDF5_VERSION_STRING ${HDF5_PACKAGE_VERSION}) +set (HDF5_VERSION_MAJOR ${HDF5_PACKAGE_VERSION_MAJOR}) +set (HDF5_VERSION_MINOR ${HDF5_PACKAGE_VERSION_MINOR}) + #----------------------------------------------------------------------------- # Include some macros for reusable code #----------------------------------------------------------------------------- -include (${HDF_RESOURCES_EXT_DIR}/HDFMacros.cmake) +include (${HDF_RESOURCES_DIR}/HDFMacros.cmake) HDF_DIR_PATHS(${HDF5_PACKAGE_NAME}) -include (${HDF_RESOURCES_EXT_DIR}/HDFLibMacros.cmake) +include (${HDF_RESOURCES_DIR}/HDFLibMacros.cmake) include (${HDF_RESOURCES_DIR}/HDF5PluginMacros.cmake) include (${HDF_RESOURCES_DIR}/HDF5Macros.cmake) @@ -465,6 +482,12 @@ include (${HDF_RESOURCES_DIR}/ConfigureChecks.cmake) set (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) +#----------------------------------------------------------------------------- +# Include directories in the source or build tree should come before other +# directories to prioritize headers in the sources over installed ones. +#----------------------------------------------------------------------------- +set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) + #----------------------------------------------------------------------------- # Mac OS X Options #----------------------------------------------------------------------------- @@ -475,28 +498,30 @@ endif () #----------------------------------------------------------------------------- # Option to Build Shared and Static libs, default is both #----------------------------------------------------------------------------- +option (ONLY_SHARED_LIBS "Only Build Shared Libraries" OFF) +mark_as_advanced (ONLY_SHARED_LIBS) option (BUILD_STATIC_LIBS "Build Static Libraries" ON) set (H5_ENABLE_STATIC_LIB NO) option (BUILD_SHARED_LIBS "Build Shared Libraries" ON) set (H5_ENABLE_SHARED_LIB NO) -option (ONLY_SHARED_LIBS "Only Build Shared Libraries" OFF) -mark_as_advanced (ONLY_SHARED_LIBS) - -if (BUILD_STATIC_LIBS) - set (H5_ENABLE_STATIC_LIB YES) -endif () -if (BUILD_SHARED_LIBS) - set (H5_ENABLE_SHARED_LIB YES) -endif () -# Force only shared libraries if all OFF -if (NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS) +# only shared libraries is true if user forces static OFF +if (NOT BUILD_STATIC_LIBS) set (ONLY_SHARED_LIBS ON CACHE BOOL "Only Build Shared Libraries" FORCE) endif () +# only shared libraries is set ON by user then force settings if (ONLY_SHARED_LIBS) set (H5_ENABLE_STATIC_LIB NO) - set (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries") + set (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries" FORCE) + set (BUILD_STATIC_LIBS OFF CACHE BOOL "Build Static Libraries" FORCE) +endif () + +if (BUILD_STATIC_LIBS) + set (H5_ENABLE_STATIC_LIB YES) +endif () +if (BUILD_SHARED_LIBS) + set (H5_ENABLE_SHARED_LIB YES) endif () set (CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -562,29 +587,6 @@ if (HDF5_ENABLE_COVERAGE) endif () endif () -#----------------------------------------------------------------------------- -# Option to indicate using dmalloc -#----------------------------------------------------------------------------- -# option (HDF5_ENABLE_USING_DMALLOC "Indicate that dmalloc is used" OFF) -# if (HDF5_ENABLE_USING_DMALLOC) -# find_package (DMALLOC) -# set (H5_HAVE_DMALLOC DMALLOC_FOUND) -# endif () - -#----------------------------------------------------------------------------- -# Option to build documentation -#----------------------------------------------------------------------------- -option (HDF5_BUILD_DOC "Build documentation" OFF) -if (HDF5_BUILD_DOC AND EXISTS "${HDF5_DOXYGEN_DIR}" AND IS_DIRECTORY "${HDF5_DOXYGEN_DIR}") -# check if Doxygen is installed - find_package(Doxygen) - if (DOXYGEN_FOUND) - message(STATUS "Doxygen version: ${DOXYGEN_VERSION}") - else () - message(STATUS "Doxygen needs to be installed to generate the doxygen documentation") - endif () -endif () - #----------------------------------------------------------------------------- # Option to indicate using a memory checker #----------------------------------------------------------------------------- @@ -641,16 +643,6 @@ if (MSVC) set (WIN_LINK_FLAGS "") endif () -set (MAKE_SYSTEM) -if (CMAKE_MAKE_PROGRAM MATCHES "make") - set (MAKE_SYSTEM 1) -endif () - -set (CFG_INIT "/${CMAKE_CFG_INTDIR}") -if (MAKE_SYSTEM) - set (CFG_INIT "") -endif () - # Do not generate test programs by default option (HDF5_BUILD_GENERATORS "Build Test Generators" OFF) @@ -659,15 +651,28 @@ option (HDF5_BUILD_GENERATORS "Build Test Generators" OFF) #----------------------------------------------------------------------------- option (HDF5_ENABLE_TRACE "Enable API tracing capability" OFF) mark_as_advanced (HDF5_ENABLE_TRACE) -if (${HDF_CFG_NAME} MATCHES "Debug") +if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer") # Enable instrumenting of the library's internal operations option (HDF5_ENABLE_INSTRUMENT "Instrument The library" OFF) + + # Instrumenting is enabled by default for parallel debug builds + if (HDF5_ENABLE_PARALLEL) + set (HDF5_ENABLE_INSTRUMENT ON CACHE BOOL "Instrument The library" FORCE) + endif () + if (HDF5_ENABLE_INSTRUMENT) set (H5_HAVE_INSTRUMENTED_LIBRARY 1) endif () mark_as_advanced (HDF5_ENABLE_INSTRUMENT) endif () +#----------------------------------------------------------------------------- +# Add some definitions for Developer Builds +#----------------------------------------------------------------------------- +if (${HDF_CFG_NAME} MATCHES "Developer") + include (${HDF_RESOURCES_DIR}/HDF5DeveloperBuild.cmake) +endif () + #----------------------------------------------------------------------------- # Option to embed library info into executables #----------------------------------------------------------------------------- @@ -681,7 +686,7 @@ else () endif () include (${HDF_RESOURCES_DIR}/HDFCompilerFlags.cmake) -set (CMAKE_MODULE_PATH ${HDF_RESOURCES_DIR} ${HDF_RESOURCES_EXT_DIR} ${CMAKE_MODULE_PATH}) +set (CMAKE_MODULE_PATH ${HDF_RESOURCES_DIR} ${CMAKE_MODULE_PATH}) #----------------------------------------------------------------------------- # Option to Enable HDFS @@ -722,10 +727,14 @@ if (HDF5_ENABLE_PARALLEL) # Used by Parallel Compression feature set (PARALLEL_FILTERED_WRITES ON) - CHECK_SYMBOL_EXISTS (MPI_Mprobe "mpi.h" H5_HAVE_MPI_Mprobe) - CHECK_SYMBOL_EXISTS (MPI_Imrecv "mpi.h" H5_HAVE_MPI_Imrecv) - if (NOT H5_HAVE_MPI_Mprobe OR NOT H5_HAVE_MPI_Imrecv) - message (WARNING "The MPI_Mprobe and/or MPI_Imrecv functions could not be located. + CHECK_SYMBOL_EXISTS (MPI_Ibarrier "mpi.h" H5_HAVE_MPI_Ibarrier) + CHECK_SYMBOL_EXISTS (MPI_Issend "mpi.h" H5_HAVE_MPI_Issend) + CHECK_SYMBOL_EXISTS (MPI_Iprobe "mpi.h" H5_HAVE_MPI_Iprobe) + CHECK_SYMBOL_EXISTS (MPI_Irecv "mpi.h" H5_HAVE_MPI_Irecv) + if (H5_HAVE_MPI_Ibarrier AND H5_HAVE_MPI_Issend AND H5_HAVE_MPI_Iprobe AND H5_HAVE_MPI_Irecv) + set (H5_HAVE_PARALLEL_FILTERED_WRITES 1) + else () + message (WARNING "The MPI_Ibarrier/MPI_Issend/MPI_Iprobe/MPI_Irecv functions could not be located. Parallel writes of filtered data will be disabled.") set (PARALLEL_FILTERED_WRITES OFF) endif () @@ -807,13 +816,6 @@ option (HDF5_PACKAGE_EXTLIBS "CPACK - include external libraries" OFF) if (NOT HDF5_EXTERNALLY_CONFIGURED) if (HDF5_PACKAGE_EXTLIBS) set (HDF5_NO_PACKAGES OFF CACHE BOOL "CPACK - Disable packaging" FORCE) - if (HDF5_ENABLE_Z_LIB_SUPPORT AND ZLIB_FOUND) - PACKAGE_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT}) - endif () - - if (HDF5_ENABLE_SZIP_SUPPORT AND SZIP_FOUND) - PACKAGE_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT}) - endif () endif () endif () @@ -824,9 +826,8 @@ option (HDF5_ENABLE_THREADSAFE "Enable thread-safety" OFF) if (HDF5_ENABLE_THREADSAFE) # check for unsupported options if (WIN32) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE " **** thread-safety option not supported with static library **** ") - message (VERBOSE " **** thread-safety option will not be used building static library **** ") + if (BUILD_STATIC_LIBS) + message (FATAL_ERROR " **** thread-safety option not supported with static library **** ") endif () endif () if (HDF5_ENABLE_PARALLEL) @@ -896,21 +897,28 @@ endif () add_subdirectory (src) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") - if (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) - if (NOT ONLY_SHARED_LIBS) - add_dependencies (${HDF5_LIB_TARGET} ZLIB) + if ((ZLIB_FOUND AND ZLIB_USE_EXTERNAL) OR (SZIP_FOUND AND SZIP_USE_EXTERNAL)) + if (BUILD_STATIC_LIBS) + add_dependencies (${HDF5_LIB_TARGET} ${LINK_COMP_LIBS}) endif () if (BUILD_SHARED_LIBS) - add_dependencies (${HDF5_LIBSH_TARGET} ZLIB) + add_dependencies (${HDF5_LIBSH_TARGET} ${LINK_COMP_LIBS}) endif () endif () - if (SZIP_FOUND AND SZIP_USE_EXTERNAL) - if (NOT ONLY_SHARED_LIBS) - add_dependencies (${HDF5_LIB_TARGET} SZIP) - endif () - if (BUILD_SHARED_LIBS) - add_dependencies (${HDF5_LIBSH_TARGET} SZIP) - endif () +endif () + +#----------------------------------------------------------------------------- +# Option to build documentation +#----------------------------------------------------------------------------- +option (HDF5_BUILD_DOC "Build documentation" OFF) +if (HDF5_BUILD_DOC AND EXISTS "${HDF5_DOXYGEN_DIR}" AND IS_DIRECTORY "${HDF5_DOXYGEN_DIR}") +# check if Doxygen is installed + find_package(Doxygen) + if (DOXYGEN_FOUND) + message(STATUS "Doxygen version: ${DOXYGEN_VERSION}") + add_subdirectory (doxygen) + else () + message(STATUS "Doxygen needs to be installed to generate the doxygen documentation") endif () endif () @@ -934,6 +942,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) @@ -943,8 +954,13 @@ if (BUILD_TESTING) mark_as_advanced (HDF5_TEST_FHEAP_PASSTHROUGH VOL) endif () - option (HDF_TEST_EXPRESS "Control testing framework (0-3)" "0") + set (H5_TEST_EXPRESS_LEVEL_DEFAULT "3") + set (HDF_TEST_EXPRESS "${H5_TEST_EXPRESS_LEVEL_DEFAULT}" + CACHE STRING "Control testing framework (0-3) (0 = exhaustive testing; 3 = quicker testing)") mark_as_advanced (HDF_TEST_EXPRESS) + if (NOT "${HDF_TEST_EXPRESS}" STREQUAL "") + set (H5_TEST_EXPRESS_LEVEL_DEFAULT "${HDF_TEST_EXPRESS}") + endif () enable_testing () include (CTest) @@ -977,11 +993,11 @@ if (BUILD_TESTING) mark_as_advanced (HDF5_TEST_JAVA) if (NOT HDF5_EXTERNALLY_CONFIGURED) - if (EXISTS "${HDF5_SOURCE_DIR}/test" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/test") + if (EXISTS "${HDF5_TEST_SRC_DIR}" AND IS_DIRECTORY "${HDF5_TEST_SRC_DIR}") add_subdirectory (test) endif () if (H5_HAVE_PARALLEL) - if (EXISTS "${HDF5_SOURCE_DIR}/testpar" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/testpar") + if (EXISTS "${HDF5_TEST_PAR_DIR}" AND IS_DIRECTORY "${HDF5_TEST_PAR_DIR}") add_subdirectory (testpar) endif () endif () @@ -992,10 +1008,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 () #----------------------------------------------------------------------------- @@ -1055,7 +1068,7 @@ set (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) name ## _") if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/fortran") option (HDF5_BUILD_FORTRAN "Build FORTRAN support" OFF) if (HDF5_BUILD_FORTRAN) - include (${HDF_RESOURCES_EXT_DIR}/HDFUseFortran.cmake) + include (${HDF_RESOURCES_DIR}/HDFUseFortran.cmake) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") message (VERBOSE "Fortran compiler ID is ${CMAKE_Fortran_COMPILER_ID}") @@ -1070,6 +1083,7 @@ if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/for # Parallel IO usage requires MPI to be Linked and Included if (H5_HAVE_PARALLEL) + find_package(MPI REQUIRED COMPONENTS Fortran) set (LINK_Fortran_LIBS ${LINK_Fortran_LIBS} ${MPI_Fortran_LIBRARIES}) if (MPI_Fortran_LINK_FLAGS) set (CMAKE_Fortran_EXE_LINKER_FLAGS "${MPI_Fortran_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") @@ -1114,7 +1128,6 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") endif () endif () - include (${HDF_RESOURCES_EXT_DIR}/HDFUseCXX.cmake) include (${HDF_RESOURCES_DIR}/HDFCXXCompilerFlags.cmake) add_subdirectory (c++) diff --git a/COPYING b/COPYING index 9d32232bdf2..9bd04025250 100644 --- a/COPYING +++ b/COPYING @@ -49,7 +49,7 @@ works thereof, in binary and source code form. Limited portions of HDF5 were developed by Lawrence Berkeley National Laboratory (LBNL). LBNL's Copyright Notice and Licensing Terms can be found here: COPYING_LBNL_HDF5 file in this directory or at -http://support.hdfgroup.org/ftp/HDF5/releases/COPYING_LBNL_HDF5. +https://raw.githubusercontent.com/hdfgroup/hdf5/develop/COPYING_LBNL_HDF5. ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 7066376715d..4ac801da2e5 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -12,7 +12,7 @@ ## This file should be placed in the root directory of your project. ## Then modify the CMakeLists.txt file in the root directory of your ## project to incorporate the testing dashboard. -## # The following are required to uses Dart and the Cdash dashboard +## # The following are required to use Dart and the CDash dashboard ## ENABLE_TESTING() ## INCLUDE(CTest) set (CTEST_PROJECT_NAME "HDF5") @@ -34,7 +34,7 @@ else () if (CDASH_LOCAL) set (CTEST_DROP_LOCATION "/submit.php?project=HDF5112") else () - set (CTEST_DROP_LOCATION "/submit.php?project=HDF5") + set (CTEST_DROP_LOCATION "/submit.php?project=HDF5112") endif () endif () set (CTEST_DROP_SITE_CDASH TRUE) diff --git a/README.md b/README.md new file mode 100644 index 00000000000..2a44114d2c0 --- /dev/null +++ b/README.md @@ -0,0 +1,86 @@ +HDF5 version 1.12.3 released on 2023-11-06 + + +![HDF5 Logo](doxygen/img/HDF5.png) + +[![1.12 build status](https://img.shields.io/github/actions/workflow/status/HDFGroup/hdf5/main.yml?branch=hdf5_1_12&label=1.12)](https://github.com/HDFGroup/hdf5/actions?query=branch%3Ahdf5_1_12) +[![BSD](https://img.shields.io/badge/License-BSD-blue.svg)](https://github.com/HDFGroup/hdf5/blob/develop/COPYING) + +*Please refer to the release_docs/INSTALL file for installation instructions.* + +This repository contains a high-performance library's source code and a file format +specification that implement the HDF5® data model. The model has been adopted across +many industries and this implementation has become a de facto data management standard +in science, engineering, and research communities worldwide. + +The HDF Group is the developer, maintainer, and steward of HDF5 software. Find more +information about The HDF Group, the HDF5 Community, and other HDF5 software projects, +tools, and services at [The HDF Group's website](https://www.hdfgroup.org/). + +DOCUMENTATION +------------- +This release is fully functional for the API described in the documentation. + + https://portal.hdfgroup.org/display/HDF5/The+HDF5+API + +Full Documentation and Programming Resources for this release can be found at + + https://portal.hdfgroup.org/display/HDF5 + +The latest doxygen documentation generated on changes to develop is available at: + + https://hdfgroup.github.io/hdf5/ + +See the [RELEASE.txt](/release_docs/RELEASE.txt) file in the [release_docs/](/release_docs/) directory for information specific +to the features and updates included in this release of the library. + +Several more files are located within the [release_docs/](/release_docs/) directory with specific +details for several common platforms and configurations. + + INSTALL - Start Here. General instructions for compiling and installing the library + INSTALL_CMAKE - instructions for building with CMake (Kitware.com) + INSTALL_parallel - instructions for building and configuring Parallel HDF5 + INSTALL_Windows and INSTALL_Cygwin - MS Windows installations. + + + +HELP AND SUPPORT +---------------- +Information regarding Help Desk and Support services is available at + + https://portal.hdfgroup.org/display/support/The+HDF+Help+Desk + + + +FORUM and NEWS +-------------- +The [HDF Forum](https://forum.hdfgroup.org) is provided for public announcements and discussions +of interest to the general HDF5 Community. + + - News and Announcements + https://forum.hdfgroup.org/c/news-and-announcements-from-the-hdf-group + + - HDF5 Topics + https://forum.hdfgroup.org/c/hdf5 + +These forums are provided as an open and public service for searching and reading. +Posting requires completing a simple registration and allows one to join in the +conversation. Please read the [instructions](https://forum.hdfgroup.org/t/quickstart-guide-welcome-to-the-new-hdf-forum +) pertaining to the Forum's use and configuration. + + + +SNAPSHOTS, PREVIOUS RELEASES AND SOURCE CODE +-------------------------------------------- +Periodically development code snapshots are provided at the following URL: + + https://github.com/HDFGroup/hdf5/releases/tag/snapshot-1.12 + +Source packages for current and previous releases are located at: + + https://portal.hdfgroup.org/display/support/Downloads + +Development code is available at our Github location: + + https://github.com/HDFGroup/hdf5.git + diff --git a/README.txt b/README.txt deleted file mode 100644 index 1162b5fd802..00000000000 --- a/README.txt +++ /dev/null @@ -1,80 +0,0 @@ -HDF5 version 1.12.1 released on 2021-07-01 - ------------------------------------------------------------------------------- -Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------- - -THE HDF GROUP ---------------- - -The HDF Group is the developer of HDF5®, a high-performance software library and -data format that has been adopted across multiple industries and has become a -de facto standard in scientific and research communities. - -More information about The HDF Group, the HDF5 Community and the HDF5 software -project, tools and services can be found at the Group's website. - - https://www.hdfgroup.org/ - - -DOCUMENTATION -------------- -This release is fully functional for the API described in the documentation. - https://portal.hdfgroup.org/display/HDF5/The+HDF5+API - -Full Documentation and Programming Resources for this release can be found at - https://portal.hdfgroup.org/display/HDF5 - -See the RELEASE.txt file in the release_docs/ directory for information specific -to the features and updates included in this release of the library. - -Several more files are located within the release_docs/ directory with specific -details for several common platforms and configurations. - - INSTALL - Start Here. General instructions for compiling and installing the library - INSTALL_CMAKE - instructions for building with CMake (Kitware.com) - INSTALL_parallel - instructions for building and configuring Parallel HDF5 - INSTALL_Windows and INSTALL_Cygwin - MS Windows installations. - - - -HELP AND SUPPORT ----------------- -Information regarding Help Desk and Support services is available at - - https://portal.hdfgroup.org/display/support/The+HDF+Help+Desk - - - -FORUM and NEWS --------------- -The following public forums are provided for public announcements and discussions -of interest to the general HDF5 Community. - - Homepage of the Forum - https://forum.hdfgroup.org - - News and Announcement - https://forum.hdfgroup.org/c/news-and-announcements-from-the-hdf-group - - HDF5 and HDF4 Topics - https://forum.hdfgroup.org/c/hdf5 - -These forums are provided as an open and public service for searching and reading. -Posting requires completing a simple registration and allows one to join in the -conversation. Please read the following instructions pertaining to the Forum's -use and configuration - https://forum.hdfgroup.org/t/quickstart-guide-welcome-to-the-new-hdf-forum - - -SNAPSHOTS, PREVIOUS RELEASES AND SOURCE CODE --------------------------------------------- -Periodically development code snapshots are provided at the following URL: - https://gamma.hdfgroup.org/ftp/pub/outgoing/hdf5/snapshots/ - -Source packages for current and previous releases are located at: - https://portal.hdfgroup.org/display/support/Downloads - -Development code is available at our Github location: - https://github.com/HDFGroup/hdf5.git - diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 835d422c71e..f8ac7296097 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -1,13 +1,6 @@ cmake_minimum_required (VERSION 3.12) project (HDF5_CPP_SRC CXX) -#----------------------------------------------------------------------------- -# Generate configure file -#----------------------------------------------------------------------------- -configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in - ${HDF5_SRC_BINARY_DIR}/H5cxx_pubconf.h -) - #----------------------------------------------------------------------------- # Define cpp Library #----------------------------------------------------------------------------- @@ -84,15 +77,15 @@ set (CPP_HDRS ${HDF5_CPP_SRC_SOURCE_DIR}/H5VarLenType.h ) -if (NOT ONLY_SHARED_LIBS) +if (BUILD_STATIC_LIBS) add_library (${HDF5_CPP_LIB_TARGET} STATIC ${CPP_SOURCES} ${CPP_HDRS}) target_include_directories (${HDF5_CPP_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) target_compile_options(${HDF5_CPP_LIB_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_compile_definitions(${HDF5_CPP_LIB_TARGET} - PRIVATE $<$:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings + PRIVATE "$<$:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK>"# Parallel/MPI, prevent spurious cpp/cxx warnings ) TARGET_C_PROPERTIES (${HDF5_CPP_LIB_TARGET} STATIC) target_link_libraries (${HDF5_CPP_LIB_TARGET} PUBLIC ${HDF5_LIB_TARGET}) @@ -105,13 +98,13 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF5_CPP_LIBSH_TARGET} SHARED ${CPP_SOURCES} ${CPP_HDRS}) target_include_directories (${HDF5_CPP_LIBSH_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$/include>" ) target_compile_options(${HDF5_CPP_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_compile_definitions(${HDF5_CPP_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - PRIVATE $<$:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings + PRIVATE "$<$:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK>"# Parallel/MPI, prevent spurious cpp/cxx warnings ) TARGET_C_PROPERTIES (${HDF5_CPP_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_CPP_LIBSH_TARGET} @@ -132,7 +125,7 @@ endif () # Add Target to clang-format #----------------------------------------------------------------------------- if (HDF5_ENABLE_FORMATTERS) - if (NOT ONLY_SHARED_LIBS) + if (BUILD_STATIC_LIBS) clang_format (HDF5_CPP_SRC_FORMAT ${HDF5_CPP_LIB_TARGET}) else () clang_format (HDF5_CPP_SRC_FORMAT ${HDF5_CPP_LIBSH_TARGET}) @@ -158,7 +151,7 @@ if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) INSTALL_TARGET_PDB (${HDF5_CPP_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} cpplibraries) endif () - if (NOT ONLY_SHARED_LIBS) + if (BUILD_STATIC_LIBS) INSTALL_TARGET_PDB (${HDF5_CPP_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} cpplibraries) endif () @@ -180,22 +173,26 @@ endif () #----------------------------------------------------------------------------- set (_PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) set (_PKG_CONFIG_EXEC_PREFIX \${prefix}) -set (_PKG_CONFIG_LIBDIR \${exec_prefix}/lib) -set (_PKG_CONFIG_INCLUDEDIR \${prefix}/include) +set (_PKG_CONFIG_LIBDIR \${exec_prefix}/${HDF5_INSTALL_LIB_DIR}) +set (_PKG_CONFIG_INCLUDEDIR \${prefix}/${HDF5_INSTALL_INCLUDE_DIR}) set (_PKG_CONFIG_LIBNAME "${HDF5_CPP_LIB_CORENAME}") set (_PKG_CONFIG_VERSION "${HDF5_PACKAGE_VERSION}") +set (PKG_CONFIG_LIBNAME "${HDF5_CPP_LIB_CORENAME}") +if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer") + set (PKG_CONFIG_LIBNAME "${PKG_CONFIG_LIBNAME}${CMAKE_DEBUG_POSTFIX}") +endif () set (_PKG_CONFIG_LIBS_PRIVATE) -if (NOT ONLY_SHARED_LIBS) - set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${HDF5_CPP_LIB_CORENAME}") +if (BUILD_STATIC_LIBS) + set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${PKG_CONFIG_LIBNAME}") endif () if (BUILD_SHARED_LIBS) - set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_CPP_LIB_CORENAME}") + set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${PKG_CONFIG_LIBNAME}") endif () -set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") -set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME}-${HDF5_PACKAGE_VERSION}") +set (_PKG_CONFIG_REQUIRES "${HDF5_LIB_CORENAME} = ${HDF5_PACKAGE_VERSION}") +set (_PKG_CONFIG_REQUIRES_PRIVATE "${HDF5_LIB_CORENAME} = ${HDF5_PACKAGE_VERSION}") configure_file ( ${HDF_CONFIG_DIR}/libhdf5.pc.in diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index eeb015584b1..3eeb1971644 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -302,7 +301,7 @@ AbstractDs::getStrType() const //-------------------------------------------------------------------------- // Function: AbstractDs::getVarLenType -///\brief Returns the floating-point datatype of this abstract dataset, +///\brief Returns the variable length datatype of this abstract dataset, /// which can be a dataset or an attribute. ///\return VarLenType instance ///\exception H5::DataTypeIException diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index b84867b2cb9..49bcfebea09 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5Alltypes.h b/c++/src/H5Alltypes.h index 7a14774f8ff..b18add8d1fb 100644 --- a/c++/src/H5Alltypes.h +++ b/c++/src/H5Alltypes.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 6999f1bf70e..afa1c560057 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index 4302352c851..0b80042a37c 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -37,7 +36,7 @@ class H5_DLLCPP ArrayType : public DataType { // Returns an ArrayType object via DataType* by decoding the // binary object description of this type. - virtual DataType *decode() const; + virtual DataType *decode() const H5_OVERRIDE; // Returns the number of dimensions of this array datatype. int getArrayNDims() const; @@ -49,7 +48,7 @@ class H5_DLLCPP ArrayType : public DataType { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("ArrayType"); } @@ -61,7 +60,7 @@ class H5_DLLCPP ArrayType : public DataType { ArrayType(const hid_t existing_id); // Noop destructor - virtual ~ArrayType(); + virtual ~ArrayType() H5_OVERRIDE; // Default constructor ArrayType(); diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 0b480464c96..8f50317cf33 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index 84da5e98ff0..4418a38518b 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -58,7 +57,7 @@ class H5_DLLCPP AtomType : public DataType { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("AtomType"); } @@ -68,7 +67,7 @@ class H5_DLLCPP AtomType : public DataType { AtomType(const AtomType &original); // Noop destructor - virtual ~AtomType(); + virtual ~AtomType() H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS protected: diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 0e37c2b3247..55d158d1692 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,10 +10,11 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include +#include #include #include -#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -313,7 +313,7 @@ Attribute::getName() const H5std_string attr_name; // attribute name to return // Preliminary call to get the size of the attribute name - ssize_t name_size = H5Aget_name(id, static_cast(0), NULL); + ssize_t name_size = H5Aget_name(id, 0, NULL); // If H5Aget_name failed, throw exception if (name_size < 0) { @@ -324,8 +324,9 @@ Attribute::getName() const } // Attribute's name exists, retrieve it else if (name_size > 0) { - char *name_C = new char[name_size + 1]; // temporary C-string - HDmemset(name_C, 0, name_size + 1); // clear buffer + // Create buffer for C string + char *name_C = new char[name_size + 1]; + memset(name_C, 0, name_size + 1); // Use overloaded function name_size = getName(name_C, name_size + 1); @@ -336,6 +337,7 @@ Attribute::getName() const // Clean up resource delete[] name_C; } + // Return attribute's name return (attr_name); } @@ -393,8 +395,9 @@ Attribute::getName(H5std_string &attr_name, size_t len) const } // If length is provided, get that number of characters in name else { - char *name_C = new char[len + 1]; // temporary C-string - HDmemset(name_C, 0, len + 1); // clear buffer + // Create buffer for C string + char *name_C = new char[len + 1]; + memset(name_C, 0, len + 1); // Use overloaded function name_size = getName(name_C, len + 1); @@ -511,7 +514,7 @@ Attribute::p_read_fixed_len(const DataType &mem_type, H5std_string &strg) const // If there is data, allocate buffer and read it. if (attr_size > 0) { - char * strg_C = new char[attr_size + 1]; + char *strg_C = new char[attr_size + 1]; herr_t ret_value = H5Aread(id, mem_type.getId(), strg_C); if (ret_value < 0) { delete[] strg_C; // de-allocate for fixed-len string @@ -551,7 +554,7 @@ Attribute::p_read_variable_len(const DataType &mem_type, H5std_string &strg) con // Get string from the C char* and release resource allocated by C API strg = strg_C; - HDfree(strg_C); + free(strg_C); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -562,7 +565,7 @@ Attribute::p_read_variable_len(const DataType &mem_type, H5std_string &strg) con ///\exception H5::IdComponentException when the attempt to close the HDF5 /// object fails // Description: -// The underlaying reference counting in the C library ensures +// The underlying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index 41e5a313a3f..80e6db97a5d 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -38,7 +37,7 @@ class H5_DLLCPP Attribute : public AbstractDs, public H5Location { Attribute(const hid_t attr_id); // Closes this attribute. - virtual void close(); + virtual void close() H5_OVERRIDE; // Gets the name of this attribute. ssize_t getName(char *attr_name, size_t buf_size = 0) const; @@ -50,13 +49,13 @@ class H5_DLLCPP Attribute : public AbstractDs, public H5Location { ssize_t getName(size_t buf_size, H5std_string &attr_name) const; // Gets a copy of the dataspace for this attribute. - virtual DataSpace getSpace() const; + virtual DataSpace getSpace() const H5_OVERRIDE; // Returns the amount of storage size required for this attribute. - virtual hsize_t getStorageSize() const; + virtual hsize_t getStorageSize() const H5_OVERRIDE; // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; + virtual size_t getInMemDataSize() const H5_OVERRIDE; // Reads data from this attribute. void read(const DataType &mem_type, void *buf) const; @@ -68,21 +67,21 @@ class H5_DLLCPP Attribute : public AbstractDs, public H5Location { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("Attribute"); } // Gets the attribute id. - virtual hid_t getId() const; + virtual hid_t getId() const H5_OVERRIDE; // Destructor: properly terminates access to this attribute. - virtual ~Attribute(); + virtual ~Attribute() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS protected: // Sets the attribute id. - virtual void p_setId(const hid_t new_id); + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS private: @@ -92,7 +91,7 @@ class H5_DLLCPP Attribute : public AbstractDs, public H5Location { // getTypeClass and various API functions getXxxType // defined in AbstractDs for generic datatype and specific // sub-types - virtual hid_t p_get_type() const; + virtual hid_t p_get_type() const H5_OVERRIDE; // Reads variable or fixed len strings from this attribute. void p_read_variable_len(const DataType &mem_type, H5std_string &strg) const; diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h index 7820ce2564e..b4a0670d468 100644 --- a/c++/src/H5Classes.h +++ b/c++/src/H5Classes.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index fb602d93319..adbd61a0304 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -13,7 +12,6 @@ #include -#include "H5private.h" // for HDstrcpy #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index d87f9ca1348..e6756177a72 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 3b38c6d81cd..1f7755e16ce 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index 6a4c093decc..edc0d154861 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -45,7 +44,7 @@ class H5_DLLCPP CompType : public DataType { // Returns a CompType object via DataType* by decoding the binary // object description of this type. - virtual DataType *decode() const; + virtual DataType *decode() const H5_OVERRIDE; // Returns the type class of the specified member of this compound // datatype. It provides to the user a way of knowing what type @@ -108,13 +107,13 @@ class H5_DLLCPP CompType : public DataType { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("CompType"); } // Noop destructor. - virtual ~CompType(); + virtual ~CompType() H5_OVERRIDE; private: // Contains common code that is used by the member functions diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 9272bdb1f5a..34fdef2032d 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -48,14 +47,4 @@ #include "H5File.h" #include "H5Library.h" -/* Some C++ compilers do not have offsetof macro; define to bypass the problem - - BMR- -EIP- 2007/08/01 -*/ -#ifndef H5_CXX_HAVE_OFFSETOF -#ifdef HOFFSET -#undef HOFFSET -#endif -#define HOFFSET(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) -#endif - #endif // H5Cpp_H diff --git a/c++/src/H5CppDoc.h b/c++/src/H5CppDoc.h index 4337a6fe911..37bd8a5cd07 100644 --- a/c++/src/H5CppDoc.h +++ b/c++/src/H5CppDoc.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5DaccProp.cpp b/c++/src/H5DaccProp.cpp index 35c071ac7c8..70430794a80 100644 --- a/c++/src/H5DaccProp.cpp +++ b/c++/src/H5DaccProp.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -72,8 +71,7 @@ DSetAccPropList::getConstant() void DSetAccPropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- diff --git a/c++/src/H5DaccProp.h b/c++/src/H5DaccProp.h index 7d6b25051c1..679fd704f0d 100644 --- a/c++/src/H5DaccProp.h +++ b/c++/src/H5DaccProp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -38,7 +37,7 @@ class H5_DLLCPP DSetAccPropList : public LinkAccPropList { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("DSetAccPropList"); } @@ -51,7 +50,7 @@ class H5_DLLCPP DSetAccPropList : public LinkAccPropList { DSetAccPropList(const hid_t plist_id); // Noop destructor. - virtual ~DSetAccPropList(); + virtual ~DSetAccPropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 47031dbfaec..e3d196d8d57 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,10 +10,11 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include +#include #include #include -#include "H5private.h" // for HDfree #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -717,8 +717,9 @@ DataSet::p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, con // If there is data, allocate buffer and read it. if (data_size > 0) { + // Create buffer for C string char *strg_C = new char[data_size + 1]; - HDmemset(strg_C, 0, data_size + 1); // clear buffer + memset(strg_C, 0, data_size + 1); herr_t ret_value = H5Dread(id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, strg_C); @@ -759,7 +760,7 @@ DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, // Get string from the C char* and release resource allocated by C API strg = strg_C; - HDfree(strg_C); + free(strg_C); } #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -770,7 +771,7 @@ DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, ///\exception H5::IdComponentException when the attempt to close the HDF5 /// object fails // Description: -// The underlaying reference counting in the C library ensures +// The underlying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. //-------------------------------------------------------------------------- diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index 333ed7a999f..64ccabeb92a 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -28,7 +27,7 @@ namespace H5 { class H5_DLLCPP DataSet : public H5Object, public AbstractDs { public: // Close this dataset. - virtual void close(); + virtual void close() H5_OVERRIDE; // Extends the dataset with unlimited dimension. void extend(const hsize_t *size) const; @@ -53,16 +52,16 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { haddr_t getOffset() const; // Gets the dataspace of this dataset. - virtual DataSpace getSpace() const; + virtual DataSpace getSpace() const H5_OVERRIDE; // Determines whether space has been allocated for a dataset. void getSpaceStatus(H5D_space_status_t &status) const; // Returns the amount of storage size required for this dataset. - virtual hsize_t getStorageSize() const; + virtual hsize_t getStorageSize() const H5_OVERRIDE; // Returns the in memory size of this attribute's data. - virtual size_t getInMemDataSize() const; + virtual size_t getInMemDataSize() const H5_OVERRIDE; // Returns the number of bytes required to store VL data. hsize_t getVlenBufSize(const DataType &type, const DataSpace &space) const; @@ -78,20 +77,20 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { // The memory and file dataspaces and the transferring property list // can be defaults. void read(void *buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, - const DataSpace & file_space = DataSpace::ALL, + const DataSpace &file_space = DataSpace::ALL, const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; void read(H5std_string &buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, - const DataSpace & file_space = DataSpace::ALL, + const DataSpace &file_space = DataSpace::ALL, const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; // Writes the buffered data to this dataset. // The memory and file dataspaces and the transferring property list // can be defaults. void write(const void *buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, - const DataSpace & file_space = DataSpace::ALL, + const DataSpace &file_space = DataSpace::ALL, const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; void write(const H5std_string &buf, const DataType &mem_type, const DataSpace &mem_space = DataSpace::ALL, - const DataSpace & file_space = DataSpace::ALL, + const DataSpace &file_space = DataSpace::ALL, const DSetMemXferPropList &xfer_plist = DSetMemXferPropList::DEFAULT) const; // Iterates the selected elements in the specified dataspace - not implemented in C++ style yet @@ -100,7 +99,7 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("DataSet"); } @@ -124,15 +123,15 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { DataSet(const hid_t existing_id); // Gets the dataset id. - virtual hid_t getId() const; + virtual hid_t getId() const H5_OVERRIDE; // Destructor: properly terminates access to this dataset. - virtual ~DataSet(); + virtual ~DataSet() H5_OVERRIDE; protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS // Sets the dataset id. - virtual void p_setId(const hid_t new_id); + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; #endif // DOXYGEN_SHOULD_SKIP_THIS private: @@ -142,7 +141,7 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { // getTypeClass and various API functions getXxxType // defined in AbstractDs for generic datatype and specific // sub-types - virtual hid_t p_get_type() const; + virtual hid_t p_get_type() const H5_OVERRIDE; // Reads variable or fixed len strings from this dataset. void p_read_fixed_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 0485530d785..bd48383f336 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -69,8 +68,7 @@ DataSpace::getConstant() void DataSpace::deleteConstants() { - if (ALL_ != 0) - delete ALL_; + delete ALL_; } //-------------------------------------------------------------------------- @@ -631,7 +629,7 @@ DataSpace::getId() const ///\exception H5::IdComponentException when the attempt to close the HDF5 /// object fails // Description: -// The underlaying reference counting in the C library ensures +// The underlying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index 470de74cc7c..ff0f7b7976f 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -127,7 +126,7 @@ class H5_DLLCPP DataSpace : public IdComponent { static void deleteConstants(); // Destructor: properly terminates access to this dataspace. - virtual ~DataSpace(); + virtual ~DataSpace() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 3228dcbf175..45cf9d74f4a 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,6 +10,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include #include @@ -32,7 +32,6 @@ #include "H5DataType.h" #include "H5AtomType.h" #include "H5PredType.h" -#include "H5private.h" #include "H5AbstractDs.h" #include "H5DataSet.h" #include "H5Attribute.h" @@ -78,7 +77,6 @@ DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id), encod //-------------------------------------------------------------------------- DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), encoded_buf(NULL), buf_size(0) { - // Call C routine to create the new datatype id = H5Tcreate(type_class, size); if (id < 0) { throw DataTypeIException("DataType constructor", "H5Tcreate failed"); @@ -148,7 +146,6 @@ DataType::DataType(const DataType &original) : H5Object(), id(original.id), enco //-------------------------------------------------------------------------- DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), buf_size(0) { - // Call C routine to copy the datatype id = H5Tcopy(pred_type.getId()); if (id < 0) throw DataTypeIException("DataType constructor", "H5Tcopy failed"); @@ -318,8 +315,9 @@ DataType::encode() // Allocate buffer and call C function again to encode if (buf_size > 0) { - encoded_buf = (unsigned char *)HDcalloc((size_t)1, buf_size); - ret_value = H5Tencode(id, encoded_buf, &buf_size); + encoded_buf = (unsigned char *)calloc((size_t)1, buf_size); + + ret_value = H5Tencode(id, encoded_buf, &buf_size); if (ret_value < 0) { throw DataTypeIException("DataType::encode", "H5Tencode failed"); } @@ -340,10 +338,7 @@ DataType::encode() bool DataType::hasBinaryDesc() const { - if (encoded_buf != NULL) - return true; - else - return false; + return encoded_buf != NULL; } //-------------------------------------------------------------------------- @@ -932,7 +927,7 @@ DataType::p_opentype(const H5Location &loc, const char *dtype_name) const ///\exception H5::IdComponentException when the attempt to close the HDF5 /// object fails // Description: -// The underlaying reference counting in the C library ensures +// The underlying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 @@ -972,7 +967,7 @@ DataType::close() // Free and reset buffer of encoded object description if it's been used if (encoded_buf != NULL) { - HDfree(encoded_buf); + free(encoded_buf); buf_size = 0; } } @@ -988,7 +983,7 @@ DataType::close() // - Replaced decRefCount with close() to let the C library // handle the reference counting - BMR, Jun 1, 2006 // - Added the use of H5CPP_EXITED to terminate the HDF5 library -// and elimiate previous memory leaks. See comments in the +// and eliminate previous memory leaks. See comments in the // header file "H5PredType.h" for details. - BMR, Mar 30, 2012 // - Major re-implementation of the global constants was done // to avoid relying on the order of the creation and deletion diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 49f534859fa..339064b2619 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -47,7 +46,7 @@ class H5_DLLCPP DataType : public H5Object { // PropList& plist = PropList::DEFAULT); // Closes this datatype. - virtual void close(); + virtual void close() H5_OVERRIDE; // Copies an existing datatype to this datatype object. void copy(const DataType &like_type); @@ -133,7 +132,7 @@ class H5_DLLCPP DataType : public H5Object { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("DataType"); } @@ -148,10 +147,10 @@ class H5_DLLCPP DataType : public H5Object { bool hasBinaryDesc() const; // Gets the datatype id. - virtual hid_t getId() const; + virtual hid_t getId() const H5_OVERRIDE; // Destructor: properly terminates access to this datatype. - virtual ~DataType(); + virtual ~DataType() H5_OVERRIDE; protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -162,7 +161,7 @@ class H5_DLLCPP DataType : public H5Object { hid_t p_decode() const; // Sets the datatype id. - virtual void p_setId(const hid_t new_id); + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; // Opens a datatype and returns the id. hid_t p_opentype(const H5Location &loc, const char *dtype_name) const; diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 4c71d5ece90..b6e68aab266 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -78,8 +77,7 @@ DSetCreatPropList::getConstant() void DSetCreatPropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- @@ -553,7 +551,7 @@ DSetCreatPropList::setShuffle() const ///\exception H5::PropListIException ///\par Description /// The values of space allocation time can be one of the -/// followings: +/// following: /// \li \c H5D_ALLOC_TIME_DEFAULT /// \li \c H5D_ALLOC_TIME_EARLY /// \li \c H5D_ALLOC_TIME_LATE diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 3c032ee5c6d..dfe963506e1 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -128,7 +127,7 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("DSetCreatPropList"); } @@ -141,7 +140,7 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { DSetCreatPropList(const hid_t plist_id); // Noop destructor. - virtual ~DSetCreatPropList(); + virtual ~DSetCreatPropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index 2b50de42333..0b5a5778b00 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,9 +10,9 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include -#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -72,8 +71,7 @@ DSetMemXferPropList::getConstant() void DSetMemXferPropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- @@ -176,7 +174,7 @@ DSetMemXferPropList::getBuffer(void **tconv, void **bkg) const void DSetMemXferPropList::setPreserve(bool status) const { - herr_t ret_value = H5Pset_preserve(id, (hbool_t)status); + herr_t ret_value = H5Pset_preserve(id, static_cast(status)); if (ret_value < 0) { throw PropListIException("DSetMemXferPropList::setPreserve", "H5Pset_preserve failed"); } @@ -315,7 +313,7 @@ DSetMemXferPropList::getDataTransform() const H5std_string expression; // Preliminary call to get the expression's length - ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0); + ssize_t exp_len = H5Pget_data_transform(id, NULL, 0); // If H5Pget_data_transform returns a negative value, raise an exception if (exp_len < 0) { @@ -326,7 +324,7 @@ DSetMemXferPropList::getDataTransform() const else if (exp_len > 0) { // Temporary buffer for char* expression char *exp_C = new char[exp_len + 1]; - HDmemset(exp_C, 0, exp_len + 1); // clear buffer + memset(exp_C, 0, exp_len + 1); // Used overloaded function exp_len = getDataTransform(exp_C, exp_len + 1); diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 1e4d66824f8..dfdad5acf81 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -100,7 +99,7 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("DSetMemXferPropList"); } @@ -113,7 +112,7 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { DSetMemXferPropList(const hid_t plist_id); // Noop destructor - virtual ~DSetMemXferPropList(); + virtual ~DSetMemXferPropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index 6c7b53384f5..4ec4369855b 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,9 +10,9 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include -#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -220,7 +219,7 @@ H5std_string EnumType::nameOf(void *value, size_t size) const { char *name_C = new char[size + 1]; // temporary C-string for C API - HDmemset(name_C, 0, size + 1); // clear buffer + memset(name_C, 0, size + 1); // Calls C routine H5Tenum_nameof to get the name of the specified enum type herr_t ret_value = H5Tenum_nameof(id, value, name_C, size); diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index 484405a0b76..e8d0ff92e36 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -41,7 +40,7 @@ class H5_DLLCPP EnumType : public DataType { // Returns an EnumType object via DataType* by decoding the // binary object description of this type. - virtual DataType *decode() const; + virtual DataType *decode() const H5_OVERRIDE; // Returns the number of members in this enumeration datatype. int getNmembers() const; @@ -68,7 +67,7 @@ class H5_DLLCPP EnumType : public DataType { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("EnumType"); } @@ -82,7 +81,7 @@ class H5_DLLCPP EnumType : public DataType { // Copy constructor: same as the original EnumType. EnumType(const EnumType &original); - virtual ~EnumType(); + virtual ~EnumType() H5_OVERRIDE; }; // end of EnumType } // namespace H5 diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 67694390f11..81aca941cd2 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 9970d2229b0..d55fba509f7 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -41,9 +40,9 @@ class H5_DLLCPP Exception { // Returns the detailed message set at the time the exception is thrown H5std_string getDetailMsg() const; - const char * getCDetailMsg() const; // C string of detailed message + const char *getCDetailMsg() const; // C string of detailed message H5std_string getFuncName() const; // function name as a string object - const char * getCFuncName() const; // function name as a char string + const char *getCFuncName() const; // function name as a char string // Turns on the automatic error printing. static void setAutoPrint(H5E_auto2_t &func, void *client_data); diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index 005e5997c01..c1c0ef2c8bd 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -17,8 +16,6 @@ using std::cerr; using std::endl; -//#include - #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -76,8 +73,7 @@ FileAccPropList::getConstant() void FileAccPropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- @@ -157,7 +153,7 @@ FileAccPropList::getDriver() const // Function: FileAccPropList::setDriver ///\brief Set file driver for this property list. ///\param new_driver_id - IN: File driver -///\param new_driver_info - IN: Struct containing the driver-specific properites +///\param new_driver_info - IN: Struct containing the driver-specific properties ///\exception H5::PropListIException ///\par Description /// For information, please refer to the H5Pset_driver API in diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index 998f870bea1..b3fb371a6aa 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -137,7 +136,7 @@ class H5_DLLCPP FileAccPropList : public PropList { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("FileAccPropList"); } @@ -150,7 +149,7 @@ class H5_DLLCPP FileAccPropList : public PropList { FileAccPropList(const hid_t plist_id); // Noop destructor - virtual ~FileAccPropList(); + virtual ~FileAccPropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index b9be5634f27..3b8fd949383 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -68,8 +67,7 @@ FileCreatPropList::getConstant() void FileCreatPropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index 00ae0b1500b..42595e48c51 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -78,7 +77,7 @@ class H5_DLLCPP FileCreatPropList : public PropList { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("FileCreatPropList"); } @@ -91,7 +90,7 @@ class H5_DLLCPP FileCreatPropList : public PropList { FileCreatPropList(const hid_t plist_id); // Noop destructor - virtual ~FileCreatPropList(); + virtual ~FileCreatPropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 9a6f191f70f..f1cd137e6c9 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -667,7 +666,7 @@ H5File::getLocId() const ///\exception H5::IdComponentException when the attempt to close the HDF5 /// object fails // Description -// The underlaying reference counting in the C library ensures +// The underlying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. // December 2000 diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 6126eec455c..442eb536be7 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -27,10 +26,10 @@ class H5_DLLCPP H5File : public Group { // Creates or opens an HDF5 file. H5File(const char *name, unsigned int flags, const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList & access_plist = FileAccPropList::DEFAULT); + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); H5File(const H5std_string &name, unsigned int flags, const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT, - const FileAccPropList & access_plist = FileAccPropList::DEFAULT); + const FileAccPropList &access_plist = FileAccPropList::DEFAULT); // Open the file void openFile(const H5std_string &name, unsigned int flags, @@ -77,9 +76,9 @@ class H5_DLLCPP H5File : public Group { static bool isHdf5(const H5std_string &name); // Determines if a file, specified by its name, can be accessed as HDF5 - static bool isAccessible(const char * name, + static bool isAccessible(const char *name, const FileAccPropList &access_plist = FileAccPropList::DEFAULT); - static bool isAccessible(const H5std_string & name, + static bool isAccessible(const H5std_string &name, const FileAccPropList &access_plist = FileAccPropList::DEFAULT); // Reopens this file. @@ -117,7 +116,7 @@ class H5_DLLCPP H5File : public Group { virtual hid_t getId() const H5_OVERRIDE; // H5File destructor. - virtual ~H5File(); + virtual ~H5File() H5_OVERRIDE; protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index 33f83770844..9d43dbf17fc 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index c76be955a68..25bbccbf8f5 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -36,7 +35,7 @@ class H5_DLLCPP FloatType : public AtomType { // Returns an FloatType object via DataType* by decoding the // binary object description of this type. - virtual DataType *decode() const; + virtual DataType *decode() const H5_OVERRIDE; // Retrieves the exponent bias of a floating-point type. size_t getEbias() const; @@ -64,7 +63,7 @@ class H5_DLLCPP FloatType : public AtomType { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("FloatType"); } @@ -79,7 +78,7 @@ class H5_DLLCPP FloatType : public AtomType { FloatType(const FloatType &original); // Noop destructor. - virtual ~FloatType(); + virtual ~FloatType() H5_OVERRIDE; }; // end of FloatType } // namespace H5 diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index fe791dae9df..0fe8ff3cbcf 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -208,7 +207,7 @@ Group::getId() const ///\exception H5::IdComponentException when the attempt to close the HDF5 /// object fails // Description: -// The underlaying reference counting in the C library ensures +// The underlying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index b5f7e51110d..efbb07111e3 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 18bcbd3c870..2a801249ca0 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,9 +10,9 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include -#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5Library.h" @@ -399,8 +398,8 @@ IdComponent::p_get_file_name() const } // Call H5Fget_name again to get the actual file name - char *name_C = new char[name_size + 1]; // temporary C-string for C API - HDmemset(name_C, 0, name_size + 1); // clear buffer + char *name_C = new char[name_size + 1]; + memset(name_C, 0, name_size + 1); name_size = H5Fget_name(temp_id, name_C, name_size + 1); @@ -434,10 +433,7 @@ IdComponent::p_valid_id(const hid_t obj_id) return false; H5I_type_t id_type = H5Iget_type(obj_id); - if (id_type <= H5I_BADID || id_type >= H5I_NTYPES) - return false; - else - return true; + return (id_type > H5I_BADID && id_type < H5I_NTYPES); } // Notes about IdComponent::id diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 383d42d333f..d64bdb5ab7d 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5Include.h b/c++/src/H5Include.h index 0dc930dbef5..6062e9a6edd 100644 --- a/c++/src/H5Include.h +++ b/c++/src/H5Include.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -25,7 +24,8 @@ */ #define H5O_VERSION_2 2 -// Define H5_OVERRIDE to override for C++11. +// H5_OVERRIDE enables using the override keyword with C++11 +// (HDF5 1.12.x and earlier do not require C++11) #if defined(__cplusplus) && (201103L <= __cplusplus) #define H5_OVERRIDE override #else diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index 27c449165bb..194ae21b0a4 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index 185c8f0da50..7f4f89b1880 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -36,17 +35,17 @@ class H5_DLLCPP IntType : public AtomType { // Returns an IntType object via DataType* by decoding the // binary object description of this type. - virtual DataType *decode() const; + virtual DataType *decode() const H5_OVERRIDE; // Retrieves the sign type for an integer type H5T_sign_t getSign() const; - // Sets the sign proprety for an integer type. + // Sets the sign property for an integer type. void setSign(H5T_sign_t sign) const; ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("IntType"); } @@ -61,7 +60,7 @@ class H5_DLLCPP IntType : public AtomType { IntType(const IntType &original); // Noop destructor. - virtual ~IntType(); + virtual ~IntType() H5_OVERRIDE; }; // end of IntType } // namespace H5 diff --git a/c++/src/H5LaccProp.cpp b/c++/src/H5LaccProp.cpp index feaa555255b..7c63bd0ff40 100644 --- a/c++/src/H5LaccProp.cpp +++ b/c++/src/H5LaccProp.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -70,8 +69,7 @@ LinkAccPropList::getConstant() void LinkAccPropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- diff --git a/c++/src/H5LaccProp.h b/c++/src/H5LaccProp.h index 4fa516ca60a..04fb681c23e 100644 --- a/c++/src/H5LaccProp.h +++ b/c++/src/H5LaccProp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -32,7 +31,7 @@ class H5_DLLCPP LinkAccPropList : public PropList { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("LinkAccPropList"); } @@ -52,7 +51,7 @@ class H5_DLLCPP LinkAccPropList : public PropList { size_t getNumLinks() const; // Noop destructor - virtual ~LinkAccPropList(); + virtual ~LinkAccPropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5LcreatProp.cpp b/c++/src/H5LcreatProp.cpp index 29721c18090..2f3437531b8 100644 --- a/c++/src/H5LcreatProp.cpp +++ b/c++/src/H5LcreatProp.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -70,8 +69,7 @@ LinkCreatPropList::getConstant() void LinkCreatPropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- @@ -122,7 +120,7 @@ LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const { - herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group); + herr_t ret_value = H5Pset_create_intermediate_group(id, static_cast(crt_intmd_group)); // Throw exception if H5Pset_create_intermediate_group returns failure if (ret_value < 0) { throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed"); @@ -147,7 +145,7 @@ LinkCreatPropList::getCreateIntermediateGroup() const throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed"); } - return ((bool)crt_intmd_group); + return static_cast(crt_intmd_group); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5LcreatProp.h b/c++/src/H5LcreatProp.h index aea38e76b88..ac6ab7f8cbe 100644 --- a/c++/src/H5LcreatProp.h +++ b/c++/src/H5LcreatProp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -32,7 +31,7 @@ class H5_DLLCPP LinkCreatPropList : public PropList { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("LinkCreatPropList"); } @@ -59,7 +58,7 @@ class H5_DLLCPP LinkCreatPropList : public PropList { H5T_cset_t getCharEncoding() const; // Noop destructor - virtual ~LinkCreatPropList(); + virtual ~LinkCreatPropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index 37516be9f43..5a94a9e19ed 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,8 +10,8 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include #include +#include #include "H5CppDoc.h" // included only for Doxygen to generate part of RM #include "H5Include.h" diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index 3df8d56d9b3..37706391558 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 065de0c09bc..b0210f82909 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,11 +10,11 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include +#include #include +#include using namespace std; -#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -351,7 +350,7 @@ H5Location::getComment(const char *name, size_t buf_size) const H5std_string comment; // Preliminary call to get the comment's length - ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, (size_t)0, H5P_DEFAULT); + ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, 0, H5P_DEFAULT); // If H5Oget_comment_by_name returns a negative value, raise an exception if (comment_len < 0) { @@ -368,7 +367,7 @@ H5Location::getComment(const char *name, size_t buf_size) const // Temporary buffer for char* comment char *comment_C = new char[tmp_len + 1]; - HDmemset(comment_C, 0, tmp_len + 1); // clear buffer + memset(comment_C, 0, tmp_len + 1); // Used overloaded function ssize_t temp_len = getComment(name, tmp_len + 1, comment_C); @@ -1747,7 +1746,7 @@ H5Location::getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t // Function: H5Location::getObjinfo ///\brief This is an overloaded member function, provided for convenience. /// It differs from the above functions in that it doesn't have -/// the paramemter \a follow_link. +/// the parameter \a follow_link. // Nov, 2005 //-------------------------------------------------------------------------- void @@ -1819,7 +1818,7 @@ H5std_string H5Location::getLinkval(const char *name, size_t size) const { H5L_info2_t linkinfo; - char * value_C; // value in C string + char *value_C; // value in C string size_t val_size = size; H5std_string value; herr_t ret_value; @@ -1835,8 +1834,9 @@ H5Location::getLinkval(const char *name, size_t size) const // if link has value, retrieve the value, otherwise, return null string if (val_size > 0) { - value_C = new char[val_size + 1]; // temporary C-string for C API - HDmemset(value_C, 0, val_size + 1); // clear buffer + // Create buffer for C string + value_C = new char[val_size + 1]; + memset(value_C, 0, val_size + 1); ret_value = H5Lget_val(getId(), name, value_C, val_size, H5P_DEFAULT); if (ret_value < 0) { @@ -2046,9 +2046,9 @@ H5Location::getObjnameByIdx(hsize_t idx) const if (name_len < 0) throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); - // now, allocate C buffer to get the name + // Create buffer for C string char *name_C = new char[name_len + 1]; - HDmemset(name_C, 0, name_len + 1); // clear buffer + memset(name_C, 0, name_len + 1); name_len = H5Lget_name_by_idx(getId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len + 1, H5P_DEFAULT); @@ -2102,8 +2102,9 @@ H5Location::getObjnameByIdx(hsize_t idx, char *name, size_t size) const ssize_t H5Location::getObjnameByIdx(hsize_t idx, H5std_string &name, size_t size) const { - char *name_C = new char[size + 1]; // temporary C-string for object name - HDmemset(name_C, 0, size + 1); // clear buffer + // Create buffer for C string + char *name_C = new char[size + 1]; + memset(name_C, 0, size + 1); // call overloaded function to get the name ssize_t name_len = getObjnameByIdx(idx, name_C, size + 1); diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 740d0ce57ea..01ab8a77a98 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -15,7 +14,7 @@ #ifndef H5Location_H #define H5Location_H -#include "H5Classes.h" // constains forward class declarations +#include "H5Classes.h" // contains forward class declarations namespace H5 { @@ -108,11 +107,11 @@ class H5_DLLCPP H5Location : public IdComponent { // Creates a new dataset in this location. DataSet createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space, const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT, - const DSetAccPropList & dapl = DSetAccPropList::DEFAULT, + const DSetAccPropList &dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const; DataSet createDataSet(const H5std_string &name, const DataType &data_type, const DataSpace &data_space, const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT, - const DSetAccPropList & dapl = DSetAccPropList::DEFAULT, + const DSetAccPropList &dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const; // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3 @@ -124,12 +123,12 @@ class H5_DLLCPP H5Location : public IdComponent { // Opens an existing dataset at this location. // DSetAccPropList is added - 1.10.3 DataSet openDataSet(const char *name, const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const; - DataSet openDataSet(const H5std_string & name, + DataSet openDataSet(const H5std_string &name, const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const; - H5L_info2_t getLinkInfo(const char * link_name, + H5L_info2_t getLinkInfo(const char *link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; - H5L_info2_t getLinkInfo(const H5std_string & link_name, + H5L_info2_t getLinkInfo(const H5std_string &link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; // Returns the value of a symbolic link. @@ -216,26 +215,26 @@ class H5_DLLCPP H5Location : public IdComponent { // Creates a soft link from link_name to target_name. void link(const char *target_name, const char *link_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; void link(const H5std_string &target_name, const H5std_string &link_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; // Creates a hard link from new_name to curr_name. void link(const char *curr_name, const Group &new_loc, const char *new_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; void link(const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; // Creates a hard link from new_name to curr_name in same location. void link(const char *curr_name, const hid_t same_loc, const char *new_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; void link(const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; // Creates a link of the specified type from new_name to current_name; // both names are interpreted relative to the specified location id. @@ -258,34 +257,34 @@ class H5_DLLCPP H5Location : public IdComponent { // Copies a link from a group to another. void copyLink(const char *src_name, const Group &dst, const char *dst_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; void copyLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; // Makes a copy of a link in the same group. void copyLink(const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; void copyLink(const H5std_string &src_name, const H5std_string &dst_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; // Renames a link in this group and moves to a new location. void moveLink(const char *src_name, const Group &dst, const char *dst_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; void moveLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; // Renames a link in this group. void moveLink(const char *src_name, const char *dst_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; void moveLink(const H5std_string &src_name, const H5std_string &dst_name, const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT, - const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const; + const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const; // Renames an object at this location. // Deprecated due to inadequate functionality. @@ -334,7 +333,7 @@ class H5_DLLCPP H5Location : public IdComponent { #endif // DOXYGEN_SHOULD_SKIP_THIS // Noop destructor. - virtual ~H5Location(); + virtual ~H5Location() H5_OVERRIDE; }; // end of H5Location } // namespace H5 diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 71109d3db1f..a308e6c46d1 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,9 +10,9 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include -#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -45,9 +44,12 @@ namespace H5 { extern "C" { static herr_t -userAttrOpWrpr(H5_ATTR_UNUSED hid_t loc_id, const char *attr_name, H5_ATTR_UNUSED const H5A_info_t *ainfo, - void *op_data) +userAttrOpWrpr(hid_t loc_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data) { + // Unused + (void)loc_id; + (void)ainfo; + H5std_string s_attr_name = H5std_string(attr_name); UserData4Aiterate *myData = reinterpret_cast(op_data); myData->op(*myData->location, s_attr_name, myData->opData); @@ -57,9 +59,11 @@ userAttrOpWrpr(H5_ATTR_UNUSED hid_t loc_id, const char *attr_name, H5_ATTR_UNUSE // userVisitOpWrpr interfaces between the user's function and the // C library function H5Ovisit3 static herr_t -userVisitOpWrpr(H5_ATTR_UNUSED hid_t obj_id, const char *attr_name, const H5O_info2_t *obj_info, - void *op_data) +userVisitOpWrpr(hid_t obj_id, const char *attr_name, const H5O_info2_t *obj_info, void *op_data) { + // Unused + (void)obj_id; + H5std_string s_attr_name = H5std_string(attr_name); UserData4Visit *myData = reinterpret_cast(op_data); int status = myData->op(*myData->obj, s_attr_name, obj_info, myData->opData); @@ -482,7 +486,7 @@ H5Object::getObjName() const H5std_string obj_name; // object name to return // Preliminary call to get the size of the object name - ssize_t name_size = H5Iget_name(getId(), NULL, static_cast(0)); + ssize_t name_size = H5Iget_name(getId(), NULL, 0); // If H5Iget_name failed, throw exception if (name_size < 0) { @@ -493,8 +497,9 @@ H5Object::getObjName() const } // Object's name exists, retrieve it else if (name_size > 0) { - char *name_C = new char[name_size + 1]; // temporary C-string - HDmemset(name_C, 0, name_size + 1); // clear buffer + // Create buffer for C string + char *name_C = new char[name_size + 1]; + memset(name_C, 0, name_size + 1); // Use overloaded function name_size = getObjName(name_C, name_size + 1); @@ -534,8 +539,9 @@ H5Object::getObjName(H5std_string &obj_name, size_t len) const } // If length is provided, get that number of characters in name else { - char *name_C = new char[len + 1]; // temporary C-string - HDmemset(name_C, 0, len + 1); // clear buffer + // Create buffer for C string + char *name_C = new char[len + 1]; + memset(name_C, 0, len + 1); // Use overloaded function name_size = getObjName(name_C, len + 1); diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index bc2f14a1860..c8e84677e7a 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -50,16 +49,16 @@ typedef int (*visit_operator_t)(H5Object &obj, const H5std_string attr_name, con class UserData4Aiterate { public: attr_operator_t op; - void * opData; - H5Object * location; // Consider changing to H5Location + void *opData; + H5Object *location; // Consider changing to H5Location }; // User data for visit iteration class UserData4Visit { public: visit_operator_t op; - void * opData; - H5Object * obj; + void *opData; + H5Object *obj; }; class H5_DLLCPP H5Object : public H5Location { diff --git a/c++/src/H5OcreatProp.cpp b/c++/src/H5OcreatProp.cpp index 81dae313ada..1391fc732f6 100644 --- a/c++/src/H5OcreatProp.cpp +++ b/c++/src/H5OcreatProp.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -70,8 +69,7 @@ ObjCreatPropList::getConstant() void ObjCreatPropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- diff --git a/c++/src/H5OcreatProp.h b/c++/src/H5OcreatProp.h index 7f6d411064e..ab97ab06d1f 100644 --- a/c++/src/H5OcreatProp.h +++ b/c++/src/H5OcreatProp.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -44,7 +43,7 @@ class H5_DLLCPP ObjCreatPropList : public PropList { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("ObjCreatPropList"); } @@ -57,7 +56,7 @@ class H5_DLLCPP ObjCreatPropList : public PropList { ObjCreatPropList(const hid_t plist_id); // Noop destructor - virtual ~ObjCreatPropList(); + virtual ~ObjCreatPropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 9e67968bfc6..5f5934e523f 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -27,7 +26,6 @@ #include "H5DataType.h" #include "H5AtomType.h" #include "H5PredType.h" -#include "H5private.h" namespace H5 { @@ -90,8 +88,12 @@ PredType::operator=(const PredType &rhs) // These dummy functions do not inherit from DataType - they'll // throw an DataTypeIException if invoked. void -PredType::commit(H5_ATTR_UNUSED H5Location &loc, H5_ATTR_UNUSED const char *name) +PredType::commit(H5Location &loc, const char *name) { + // Unused + (void)loc; + (void)name; + throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!"); } @@ -246,63 +248,32 @@ PredType *PredType::NATIVE_INT32_; PredType *PredType::NATIVE_UINT32_; PredType *PredType::NATIVE_INT64_; PredType *PredType::NATIVE_UINT64_; + // LEAST types -#if H5_SIZEOF_INT_LEAST8_T != 0 PredType *PredType::NATIVE_INT_LEAST8_; -#endif /* H5_SIZEOF_INT_LEAST8_T */ -#if H5_SIZEOF_UINT_LEAST8_T != 0 PredType *PredType::NATIVE_UINT_LEAST8_; -#endif /* H5_SIZEOF_UINT_LEAST8_T */ -#if H5_SIZEOF_INT_LEAST16_T != 0 PredType *PredType::NATIVE_INT_LEAST16_; -#endif /* H5_SIZEOF_INT_LEAST16_T */ -#if H5_SIZEOF_UINT_LEAST16_T != 0 PredType *PredType::NATIVE_UINT_LEAST16_; -#endif /* H5_SIZEOF_UINT_LEAST16_T */ -#if H5_SIZEOF_INT_LEAST32_T != 0 PredType *PredType::NATIVE_INT_LEAST32_; -#endif /* H5_SIZEOF_INT_LEAST32_T */ -#if H5_SIZEOF_UINT_LEAST32_T != 0 PredType *PredType::NATIVE_UINT_LEAST32_; -#endif /* H5_SIZEOF_UINT_LEAST32_T */ -#if H5_SIZEOF_INT_LEAST64_T != 0 PredType *PredType::NATIVE_INT_LEAST64_; -#endif /* H5_SIZEOF_INT_LEAST64_T */ -#if H5_SIZEOF_UINT_LEAST64_T != 0 PredType *PredType::NATIVE_UINT_LEAST64_; -#endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types -#if H5_SIZEOF_INT_FAST8_T != 0 PredType *PredType::NATIVE_INT_FAST8_; -#endif /* H5_SIZEOF_INT_FAST8_T */ -#if H5_SIZEOF_UINT_FAST8_T != 0 PredType *PredType::NATIVE_UINT_FAST8_; -#endif /* H5_SIZEOF_UINT_FAST8_T */ -#if H5_SIZEOF_INT_FAST16_T != 0 PredType *PredType::NATIVE_INT_FAST16_; -#endif /* H5_SIZEOF_INT_FAST16_T */ -#if H5_SIZEOF_UINT_FAST16_T != 0 PredType *PredType::NATIVE_UINT_FAST16_; -#endif /* H5_SIZEOF_UINT_FAST16_T */ -#if H5_SIZEOF_INT_FAST32_T != 0 PredType *PredType::NATIVE_INT_FAST32_; -#endif /* H5_SIZEOF_INT_FAST32_T */ -#if H5_SIZEOF_UINT_FAST32_T != 0 PredType *PredType::NATIVE_UINT_FAST32_; -#endif /* H5_SIZEOF_UINT_FAST32_T */ -#if H5_SIZEOF_INT_FAST64_T != 0 PredType *PredType::NATIVE_INT_FAST64_; -#endif /* H5_SIZEOF_INT_FAST64_T */ -#if H5_SIZEOF_UINT_FAST64_T != 0 PredType *PredType::NATIVE_UINT_FAST64_; -#endif /* H5_SIZEOF_UINT_FAST64_T */ //-------------------------------------------------------------------------- // Function: PredType::getPredTypes @@ -434,31 +405,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); @@ -469,63 +438,31 @@ PredType::makePredTypes() NATIVE_INT64_ = new PredType(H5T_NATIVE_INT64); NATIVE_UINT64_ = new PredType(H5T_NATIVE_UINT64); -// LEAST types -#if H5_SIZEOF_INT_LEAST8_T != 0 - NATIVE_INT_LEAST8_ = new PredType(H5T_NATIVE_INT_LEAST8); -#endif /* H5_SIZEOF_INT_LEAST8_T */ -#if H5_SIZEOF_UINT_LEAST8_T != 0 + // LEAST types + NATIVE_INT_LEAST8_ = new PredType(H5T_NATIVE_INT_LEAST8); NATIVE_UINT_LEAST8_ = new PredType(H5T_NATIVE_UINT_LEAST8); -#endif /* H5_SIZEOF_UINT_LEAST8_T */ -#if H5_SIZEOF_INT_LEAST16_T != 0 - NATIVE_INT_LEAST16_ = new PredType(H5T_NATIVE_INT_LEAST16); -#endif /* H5_SIZEOF_INT_LEAST16_T */ -#if H5_SIZEOF_UINT_LEAST16_T != 0 + NATIVE_INT_LEAST16_ = new PredType(H5T_NATIVE_INT_LEAST16); NATIVE_UINT_LEAST16_ = new PredType(H5T_NATIVE_UINT_LEAST16); -#endif /* H5_SIZEOF_UINT_LEAST16_T */ -#if H5_SIZEOF_INT_LEAST32_T != 0 - NATIVE_INT_LEAST32_ = new PredType(H5T_NATIVE_INT_LEAST32); -#endif /* H5_SIZEOF_INT_LEAST32_T */ -#if H5_SIZEOF_UINT_LEAST32_T != 0 + NATIVE_INT_LEAST32_ = new PredType(H5T_NATIVE_INT_LEAST32); NATIVE_UINT_LEAST32_ = new PredType(H5T_NATIVE_UINT_LEAST32); -#endif /* H5_SIZEOF_UINT_LEAST32_T */ -#if H5_SIZEOF_INT_LEAST64_T != 0 - NATIVE_INT_LEAST64_ = new PredType(H5T_NATIVE_INT_LEAST64); -#endif /* H5_SIZEOF_INT_LEAST64_T */ -#if H5_SIZEOF_UINT_LEAST64_T != 0 + NATIVE_INT_LEAST64_ = new PredType(H5T_NATIVE_INT_LEAST64); NATIVE_UINT_LEAST64_ = new PredType(H5T_NATIVE_UINT_LEAST64); -#endif /* H5_SIZEOF_UINT_LEAST64_T */ -// FAST types -#if H5_SIZEOF_INT_FAST8_T != 0 - NATIVE_INT_FAST8_ = new PredType(H5T_NATIVE_INT_FAST8); -#endif /* H5_SIZEOF_INT_FAST8_T */ -#if H5_SIZEOF_UINT_FAST8_T != 0 + // FAST types + NATIVE_INT_FAST8_ = new PredType(H5T_NATIVE_INT_FAST8); NATIVE_UINT_FAST8_ = new PredType(H5T_NATIVE_UINT_FAST8); -#endif /* H5_SIZEOF_UINT_FAST8_T */ -#if H5_SIZEOF_INT_FAST16_T != 0 - NATIVE_INT_FAST16_ = new PredType(H5T_NATIVE_INT_FAST16); -#endif /* H5_SIZEOF_INT_FAST16_T */ -#if H5_SIZEOF_UINT_FAST16_T != 0 + NATIVE_INT_FAST16_ = new PredType(H5T_NATIVE_INT_FAST16); NATIVE_UINT_FAST16_ = new PredType(H5T_NATIVE_UINT_FAST16); -#endif /* H5_SIZEOF_UINT_FAST16_T */ -#if H5_SIZEOF_INT_FAST32_T != 0 - NATIVE_INT_FAST32_ = new PredType(H5T_NATIVE_INT_FAST32); -#endif /* H5_SIZEOF_INT_FAST32_T */ -#if H5_SIZEOF_UINT_FAST32_T != 0 + NATIVE_INT_FAST32_ = new PredType(H5T_NATIVE_INT_FAST32); NATIVE_UINT_FAST32_ = new PredType(H5T_NATIVE_UINT_FAST32); -#endif /* H5_SIZEOF_UINT_FAST32_T */ -#if H5_SIZEOF_INT_FAST64_T != 0 - NATIVE_INT_FAST64_ = new PredType(H5T_NATIVE_INT_FAST64); -#endif /* H5_SIZEOF_INT_FAST64_T */ -#if H5_SIZEOF_UINT_FAST64_T != 0 + NATIVE_INT_FAST64_ = new PredType(H5T_NATIVE_INT_FAST64); NATIVE_UINT_FAST64_ = new PredType(H5T_NATIVE_UINT_FAST64); -#endif /* H5_SIZEOF_UINT_FAST64_T */ } // makePredTypes @@ -655,63 +592,31 @@ PredType::deleteConstants() delete NATIVE_INT64_; delete NATIVE_UINT64_; -// LEAST types -#if H5_SIZEOF_INT_LEAST8_T != 0 + // LEAST types delete NATIVE_INT_LEAST8_; -#endif /* H5_SIZEOF_INT_LEAST8_T */ -#if H5_SIZEOF_UINT_LEAST8_T != 0 delete NATIVE_UINT_LEAST8_; -#endif /* H5_SIZEOF_UINT_LEAST8_T */ -#if H5_SIZEOF_INT_LEAST16_T != 0 delete NATIVE_INT_LEAST16_; -#endif /* H5_SIZEOF_INT_LEAST16_T */ -#if H5_SIZEOF_UINT_LEAST16_T != 0 delete NATIVE_UINT_LEAST16_; -#endif /* H5_SIZEOF_UINT_LEAST16_T */ -#if H5_SIZEOF_INT_LEAST32_T != 0 delete NATIVE_INT_LEAST32_; -#endif /* H5_SIZEOF_INT_LEAST32_T */ -#if H5_SIZEOF_UINT_LEAST32_T != 0 delete NATIVE_UINT_LEAST32_; -#endif /* H5_SIZEOF_UINT_LEAST32_T */ -#if H5_SIZEOF_INT_LEAST64_T != 0 delete NATIVE_INT_LEAST64_; -#endif /* H5_SIZEOF_INT_LEAST64_T */ -#if H5_SIZEOF_UINT_LEAST64_T != 0 delete NATIVE_UINT_LEAST64_; -#endif /* H5_SIZEOF_UINT_LEAST64_T */ -// FAST types -#if H5_SIZEOF_INT_FAST8_T != 0 + // FAST types delete NATIVE_INT_FAST8_; -#endif /* H5_SIZEOF_INT_FAST8_T */ -#if H5_SIZEOF_UINT_FAST8_T != 0 delete NATIVE_UINT_FAST8_; -#endif /* H5_SIZEOF_UINT_FAST8_T */ -#if H5_SIZEOF_INT_FAST16_T != 0 delete NATIVE_INT_FAST16_; -#endif /* H5_SIZEOF_INT_FAST16_T */ -#if H5_SIZEOF_UINT_FAST16_T != 0 delete NATIVE_UINT_FAST16_; -#endif /* H5_SIZEOF_UINT_FAST16_T */ -#if H5_SIZEOF_INT_FAST32_T != 0 delete NATIVE_INT_FAST32_; -#endif /* H5_SIZEOF_INT_FAST32_T */ -#if H5_SIZEOF_UINT_FAST32_T != 0 delete NATIVE_UINT_FAST32_; -#endif /* H5_SIZEOF_UINT_FAST32_T */ -#if H5_SIZEOF_INT_FAST64_T != 0 delete NATIVE_INT_FAST64_; -#endif /* H5_SIZEOF_INT_FAST64_T */ -#if H5_SIZEOF_UINT_FAST64_T != 0 delete NATIVE_UINT_FAST64_; -#endif /* H5_SIZEOF_UINT_FAST64_T */ delete PREDTYPE_CONST_; PREDTYPE_CONST_ = 0; @@ -845,62 +750,30 @@ const PredType &PredType::NATIVE_INT64 = *NATIVE_INT64_; const PredType &PredType::NATIVE_UINT64 = *NATIVE_UINT64_; // LEAST types -#if H5_SIZEOF_INT_LEAST8_T != 0 -const PredType &PredType::NATIVE_INT_LEAST8 = *NATIVE_INT_LEAST8_; -#endif /* H5_SIZEOF_INT_LEAST8_T */ -#if H5_SIZEOF_UINT_LEAST8_T != 0 +const PredType &PredType::NATIVE_INT_LEAST8 = *NATIVE_INT_LEAST8_; const PredType &PredType::NATIVE_UINT_LEAST8 = *NATIVE_UINT_LEAST8_; -#endif /* H5_SIZEOF_UINT_LEAST8_T */ -#if H5_SIZEOF_INT_LEAST16_T != 0 -const PredType &PredType::NATIVE_INT_LEAST16 = *NATIVE_INT_LEAST16_; -#endif /* H5_SIZEOF_INT_LEAST16_T */ -#if H5_SIZEOF_UINT_LEAST16_T != 0 +const PredType &PredType::NATIVE_INT_LEAST16 = *NATIVE_INT_LEAST16_; const PredType &PredType::NATIVE_UINT_LEAST16 = *NATIVE_UINT_LEAST16_; -#endif /* H5_SIZEOF_UINT_LEAST16_T */ -#if H5_SIZEOF_INT_LEAST32_T != 0 -const PredType &PredType::NATIVE_INT_LEAST32 = *NATIVE_INT_LEAST32_; -#endif /* H5_SIZEOF_INT_LEAST32_T */ -#if H5_SIZEOF_UINT_LEAST32_T != 0 +const PredType &PredType::NATIVE_INT_LEAST32 = *NATIVE_INT_LEAST32_; const PredType &PredType::NATIVE_UINT_LEAST32 = *NATIVE_UINT_LEAST32_; -#endif /* H5_SIZEOF_UINT_LEAST32_T */ -#if H5_SIZEOF_INT_LEAST64_T != 0 -const PredType &PredType::NATIVE_INT_LEAST64 = *NATIVE_INT_LEAST64_; -#endif /* H5_SIZEOF_INT_LEAST64_T */ -#if H5_SIZEOF_UINT_LEAST64_T != 0 +const PredType &PredType::NATIVE_INT_LEAST64 = *NATIVE_INT_LEAST64_; const PredType &PredType::NATIVE_UINT_LEAST64 = *NATIVE_UINT_LEAST64_; -#endif /* H5_SIZEOF_UINT_LEAST64_T */ // FAST types -#if H5_SIZEOF_INT_FAST8_T != 0 -const PredType &PredType::NATIVE_INT_FAST8 = *NATIVE_INT_FAST8_; -#endif /* H5_SIZEOF_INT_FAST8_T */ -#if H5_SIZEOF_UINT_FAST8_T != 0 +const PredType &PredType::NATIVE_INT_FAST8 = *NATIVE_INT_FAST8_; const PredType &PredType::NATIVE_UINT_FAST8 = *NATIVE_UINT_FAST8_; -#endif /* H5_SIZEOF_UINT_FAST8_T */ -#if H5_SIZEOF_INT_FAST16_T != 0 -const PredType &PredType::NATIVE_INT_FAST16 = *NATIVE_INT_FAST16_; -#endif /* H5_SIZEOF_INT_FAST16_T */ -#if H5_SIZEOF_UINT_FAST16_T != 0 +const PredType &PredType::NATIVE_INT_FAST16 = *NATIVE_INT_FAST16_; const PredType &PredType::NATIVE_UINT_FAST16 = *NATIVE_UINT_FAST16_; -#endif /* H5_SIZEOF_UINT_FAST16_T */ -#if H5_SIZEOF_INT_FAST32_T != 0 -const PredType &PredType::NATIVE_INT_FAST32 = *NATIVE_INT_FAST32_; -#endif /* H5_SIZEOF_INT_FAST32_T */ -#if H5_SIZEOF_UINT_FAST32_T != 0 +const PredType &PredType::NATIVE_INT_FAST32 = *NATIVE_INT_FAST32_; const PredType &PredType::NATIVE_UINT_FAST32 = *NATIVE_UINT_FAST32_; -#endif /* H5_SIZEOF_UINT_FAST32_T */ -#if H5_SIZEOF_INT_FAST64_T != 0 -const PredType &PredType::NATIVE_INT_FAST64 = *NATIVE_INT_FAST64_; -#endif /* H5_SIZEOF_INT_FAST64_T */ -#if H5_SIZEOF_UINT_FAST64_T != 0 +const PredType &PredType::NATIVE_INT_FAST64 = *NATIVE_INT_FAST64_; const PredType &PredType::NATIVE_UINT_FAST64 = *NATIVE_UINT_FAST64_; -#endif /* H5_SIZEOF_UINT_FAST64_T */ #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -916,7 +789,7 @@ September 2015: classes, such as PropList, PredType, DataSpace, etc... Previously, these global constants were declared statically and the C++ library used a constant, called PredType::AtExit, to detect when all the global - contants are destroyed then close the C library (H5close). This method + constants are destroyed then close the C library (H5close). This method relied on the order of the constants being created and destroyed and that PredType constants be the last to be destroyed. In September 2015, it was recognized that the order in which the global constants were diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index b40d2b3782d..161efc74da4 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -29,7 +28,7 @@ class H5_DLLCPP PredType : public AtomType { public: ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("PredType"); } @@ -42,7 +41,7 @@ class H5_DLLCPP PredType : public AtomType { PredType(const PredType &original); // Noop destructor - virtual ~PredType(); + virtual ~PredType() H5_OVERRIDE; /*! \brief This dummy function do not inherit from DataType - it will throw a DataTypeIException if invoked. @@ -176,63 +175,31 @@ class H5_DLLCPP PredType : public AtomType { static const PredType &NATIVE_INT64; static const PredType &NATIVE_UINT64; -// LEAST types -#if H5_SIZEOF_INT_LEAST8_T != 0 + // LEAST types static const PredType &NATIVE_INT_LEAST8; -#endif /* H5_SIZEOF_INT_LEAST8_T */ -#if H5_SIZEOF_UINT_LEAST8_T != 0 static const PredType &NATIVE_UINT_LEAST8; -#endif /* H5_SIZEOF_UINT_LEAST8_T */ -#if H5_SIZEOF_INT_LEAST16_T != 0 static const PredType &NATIVE_INT_LEAST16; -#endif /* H5_SIZEOF_INT_LEAST16_T */ -#if H5_SIZEOF_UINT_LEAST16_T != 0 static const PredType &NATIVE_UINT_LEAST16; -#endif /* H5_SIZEOF_UINT_LEAST16_T */ -#if H5_SIZEOF_INT_LEAST32_T != 0 static const PredType &NATIVE_INT_LEAST32; -#endif /* H5_SIZEOF_INT_LEAST32_T */ -#if H5_SIZEOF_UINT_LEAST32_T != 0 static const PredType &NATIVE_UINT_LEAST32; -#endif /* H5_SIZEOF_UINT_LEAST32_T */ -#if H5_SIZEOF_INT_LEAST64_T != 0 static const PredType &NATIVE_INT_LEAST64; -#endif /* H5_SIZEOF_INT_LEAST64_T */ -#if H5_SIZEOF_UINT_LEAST64_T != 0 static const PredType &NATIVE_UINT_LEAST64; -#endif /* H5_SIZEOF_UINT_LEAST64_T */ -// FAST types -#if H5_SIZEOF_INT_FAST8_T != 0 + // FAST types static const PredType &NATIVE_INT_FAST8; -#endif /* H5_SIZEOF_INT_FAST8_T */ -#if H5_SIZEOF_UINT_FAST8_T != 0 static const PredType &NATIVE_UINT_FAST8; -#endif /* H5_SIZEOF_UINT_FAST8_T */ -#if H5_SIZEOF_INT_FAST16_T != 0 static const PredType &NATIVE_INT_FAST16; -#endif /* H5_SIZEOF_INT_FAST16_T */ -#if H5_SIZEOF_UINT_FAST16_T != 0 static const PredType &NATIVE_UINT_FAST16; -#endif /* H5_SIZEOF_UINT_FAST16_T */ -#if H5_SIZEOF_INT_FAST32_T != 0 static const PredType &NATIVE_INT_FAST32; -#endif /* H5_SIZEOF_INT_FAST32_T */ -#if H5_SIZEOF_UINT_FAST32_T != 0 static const PredType &NATIVE_UINT_FAST32; -#endif /* H5_SIZEOF_UINT_FAST32_T */ -#if H5_SIZEOF_INT_FAST64_T != 0 static const PredType &NATIVE_INT_FAST64; -#endif /* H5_SIZEOF_INT_FAST64_T */ -#if H5_SIZEOF_UINT_FAST64_T != 0 static const PredType &NATIVE_UINT_FAST64; -#endif /* H5_SIZEOF_UINT_FAST64_T */ #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -378,64 +345,31 @@ class H5_DLLCPP PredType : public AtomType { static PredType *NATIVE_INT64_; static PredType *NATIVE_UINT64_; -// LEAST types -#if H5_SIZEOF_INT_LEAST8_T != 0 + // LEAST types static PredType *NATIVE_INT_LEAST8_; -#endif /* H5_SIZEOF_INT_LEAST8_T */ -#if H5_SIZEOF_UINT_LEAST8_T != 0 static PredType *NATIVE_UINT_LEAST8_; -#endif /* H5_SIZEOF_UINT_LEAST8_T */ -#if H5_SIZEOF_INT_LEAST16_T != 0 static PredType *NATIVE_INT_LEAST16_; -#endif /* H5_SIZEOF_INT_LEAST16_T */ -#if H5_SIZEOF_UINT_LEAST16_T != 0 static PredType *NATIVE_UINT_LEAST16_; -#endif /* H5_SIZEOF_UINT_LEAST16_T */ -#if H5_SIZEOF_INT_LEAST32_T != 0 static PredType *NATIVE_INT_LEAST32_; -#endif /* H5_SIZEOF_INT_LEAST32_T */ -#if H5_SIZEOF_UINT_LEAST32_T != 0 static PredType *NATIVE_UINT_LEAST32_; -#endif /* H5_SIZEOF_UINT_LEAST32_T */ -#if H5_SIZEOF_INT_LEAST64_T != 0 static PredType *NATIVE_INT_LEAST64_; -#endif /* H5_SIZEOF_INT_LEAST64_T */ -#if H5_SIZEOF_UINT_LEAST64_T != 0 static PredType *NATIVE_UINT_LEAST64_; -#endif /* H5_SIZEOF_UINT_LEAST64_T */ -// FAST types -#if H5_SIZEOF_INT_FAST8_T != 0 + // FAST types static PredType *NATIVE_INT_FAST8_; -#endif /* H5_SIZEOF_INT_FAST8_T */ -#if H5_SIZEOF_UINT_FAST8_T != 0 static PredType *NATIVE_UINT_FAST8_; -#endif /* H5_SIZEOF_UINT_FAST8_T */ -#if H5_SIZEOF_INT_FAST16_T != 0 static PredType *NATIVE_INT_FAST16_; -#endif /* H5_SIZEOF_INT_FAST16_T */ -#if H5_SIZEOF_UINT_FAST16_T != 0 static PredType *NATIVE_UINT_FAST16_; -#endif /* H5_SIZEOF_UINT_FAST16_T */ -#if H5_SIZEOF_INT_FAST32_T != 0 static PredType *NATIVE_INT_FAST32_; -#endif /* H5_SIZEOF_INT_FAST32_T */ -#if H5_SIZEOF_UINT_FAST32_T != 0 static PredType *NATIVE_UINT_FAST32_; -#endif /* H5_SIZEOF_UINT_FAST32_T */ -#if H5_SIZEOF_INT_FAST64_T != 0 static PredType *NATIVE_INT_FAST64_; -#endif /* H5_SIZEOF_INT_FAST64_T */ -#if H5_SIZEOF_UINT_FAST64_T != 0 static PredType *NATIVE_UINT_FAST64_; -#endif /* H5_SIZEOF_UINT_FAST64_T */ - // End of Declaration of pointers #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index fda41148e7e..4b2eaebd661 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -11,11 +10,10 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include - #include -#include "H5private.h" // for HDmemset #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" @@ -71,8 +69,7 @@ PropList::getConstant() void PropList::deleteConstants() { - if (DEFAULT_ != 0) - delete DEFAULT_; + delete DEFAULT_; } //-------------------------------------------------------------------------- @@ -305,7 +302,7 @@ PropList::getId() const ///\exception H5::IdComponentException when the attempt to close the HDF5 /// object fails // Description: -// The underlaying reference counting in the C library ensures +// The underlying reference counting in the C library ensures // that the current valid id of this object is properly closed. // Then the object's id is reset to the new id. // Programmer Binh-Minh Ribler - 2000 @@ -461,8 +458,8 @@ PropList::getProperty(const char *name) const size_t size = getPropSize(name); // Allocate buffer then get the property - char *prop_strg_C = new char[size + 1]; // temporary C-string for C API - HDmemset(prop_strg_C, 0, size + 1); // clear buffer + char *prop_strg_C = new char[size + 1]; + memset(prop_strg_C, 0, size + 1); herr_t ret_value = H5Pget(id, name, prop_strg_C); // call C API @@ -548,7 +545,7 @@ PropList::getPropSize(const H5std_string &name) const // Function: PropList::getClassName ///\brief Return the name of a generic property list class. ///\return A string containing the class name, if success, otherwise, -/// a NULL string. +/// an empty string. // Programmer: Binh-Minh Ribler - April, 2004 //-------------------------------------------------------------------------- H5std_string @@ -562,8 +559,9 @@ PropList::getClassName() const return (class_name); } else - return 0; + return ""; } + //-------------------------------------------------------------------------- // Function: PropList::getNumProps ///\brief Returns the number of properties in this property list or class. @@ -633,11 +631,12 @@ PropList::setProperty(const char *name, void *value) const void PropList::setProperty(const char *name, const char *charptr) const { - herr_t ret_value = H5Pset(id, name, (const void *)charptr); + herr_t ret_value = H5Pset(id, name, static_cast(charptr)); if (ret_value < 0) { throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } + //-------------------------------------------------------------------------- // Function: PropList::setProperty ///\brief This is an overloaded member function, provided for convenience. diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index 12c8b4b058c..27fe8012d29 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -38,7 +37,7 @@ class H5_DLLCPP PropList : public IdComponent { bool operator==(const PropList &rhs) const; // Close this property list. - virtual void close(); + virtual void close() H5_OVERRIDE; // Close a property list class. void closeClass() const; @@ -102,7 +101,7 @@ class H5_DLLCPP PropList : public IdComponent { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("PropList"); } @@ -114,10 +113,10 @@ class H5_DLLCPP PropList : public IdComponent { PropList(const PropList &original); // Gets the property list id. - virtual hid_t getId() const; + virtual hid_t getId() const H5_OVERRIDE; // Destructor: properly terminates access to this property list. - virtual ~PropList(); + virtual ~PropList() H5_OVERRIDE; #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -128,7 +127,7 @@ class H5_DLLCPP PropList : public IdComponent { hid_t id; // HDF5 property list id // Sets the property list id. - virtual void p_setId(const hid_t new_id); + virtual void p_setId(const hid_t new_id) H5_OVERRIDE; private: static PropList *DEFAULT_; diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index 5df48f38660..42011eef408 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -32,7 +31,6 @@ #include "H5StrType.h" #include "H5DataSet.h" #include "H5PredType.h" -#include "H5private.h" namespace H5 { @@ -105,8 +103,11 @@ StrType::StrType(const PredType &pred_type, const size_t &size) : AtomType() // This constructor replaced the previous one. // Programmer Binh-Minh Ribler - Nov 28, 2005 //-------------------------------------------------------------------------- -StrType::StrType(H5_ATTR_UNUSED const int dummy, const size_t &size) : AtomType() +StrType::StrType(const int dummy, const size_t &size) : AtomType() { + // Unused + (void)dummy; + // use DataType::copy to make a copy of the string predefined type // then set its length copy(PredType::C_S1); diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h index d272c535bcf..f8ef3c96aa6 100644 --- a/c++/src/H5StrType.h +++ b/c++/src/H5StrType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -42,7 +41,7 @@ class H5_DLLCPP StrType : public AtomType { // Returns an StrType object via DataType* by decoding the // binary object description of this type. - virtual DataType *decode() const; + virtual DataType *decode() const H5_OVERRIDE; // Retrieves the character set type of this string datatype. H5T_cset_t getCset() const; @@ -58,7 +57,7 @@ class H5_DLLCPP StrType : public AtomType { ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("StrType"); } @@ -73,7 +72,7 @@ class H5_DLLCPP StrType : public AtomType { StrType(const StrType &original); // Noop destructor. - virtual ~StrType(); + virtual ~StrType() H5_OVERRIDE; }; // end of StrType } // namespace H5 diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp index 0270febfe59..6043e14a8d9 100644 --- a/c++/src/H5VarLenType.cpp +++ b/c++/src/H5VarLenType.cpp @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index f767e0ebd2f..26588c26d09 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -1,7 +1,6 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -33,11 +32,11 @@ class H5_DLLCPP VarLenType : public DataType { // Returns an VarLenType object via DataType* by decoding the // binary object description of this type. - virtual DataType *decode() const; + virtual DataType *decode() const H5_OVERRIDE; ///\brief Returns this class name. virtual H5std_string - fromClass() const + fromClass() const H5_OVERRIDE { return ("VarLenType"); } @@ -53,7 +52,7 @@ class H5_DLLCPP VarLenType : public DataType { VarLenType(const H5Location &loc, const H5std_string &name); // Noop destructor - virtual ~VarLenType(); + virtual ~VarLenType() H5_OVERRIDE; // Default constructor VarLenType(); diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index f17652eee6b..67f78ef284b 100644 --- a/c++/src/cpp_doc_config +++ b/c++/src/cpp_doc_config @@ -38,7 +38,7 @@ PROJECT_NAME = # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "1.12.1" +PROJECT_NUMBER = "1.12.3" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/c++/src/footer.html b/c++/src/footer.html index 5ad9b7cc422..7592925c9a1 100644 --- a/c++/src/footer.html +++ b/c++/src/footer.html @@ -13,8 +13,6 @@ Copyright by The HDF Group -
- and the Board of Trustees of the University of Illinois diff --git a/c++/src/h5c++.in b/c++/src/h5c++.in index bcc835ebe38..05f77582d8a 100755 --- a/c++/src/h5c++.in +++ b/c++/src/h5c++.in @@ -1,7 +1,6 @@ #!/bin/sh # # 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 @@ -35,10 +34,10 @@ HL="@HL@" ## (Advanced usage - know what you're doing - you're on your own here.) ## ## The four variables below can be used to insert paths and flags in ## ## CPPFLAGS, CXXFLAGS, LDFLAGS, or LIBS in the h5cc compile line: ## -## $CLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS ## +## $CXXLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS ## ## $LDFLAGS $LIBS $clibpath $link_objs $link_args $shared_link ## ## ## -## These settings can be overridden by setting HDF5_CXXFLAGS, ## +## These settings can be overridden by setting HDF5_CXXFLAGS, ## ## HDF5_CPPFLAGS, HDF5_LDFLAGS, or HDF5_LIBS in the environment. ## ## ## ############################################################################ @@ -93,7 +92,7 @@ H5BLD_LDFLAGS="@AM_LDFLAGS@ @LDFLAGS@" H5BLD_LIBS="@LIBS@" CXX="${HDF5_CXX:-$CXXBASE}" -CXXLINKER="${HDF5_CLINKER:-$CXXLINKERBASE}" +CXXLINKER="${HDF5_CXXLINKER:-$CXXLINKERBASE}" CXXFLAGS="${HDF5_CXXFLAGS:-$CXXFLAGSBASE}" CPPFLAGS="${HDF5_CPPFLAGS:-$CPPFLAGSBASE}" LDFLAGS="${HDF5_LDFLAGS:-$LDFLAGSBASE}" diff --git a/c++/src/header.html b/c++/src/header.html index 5b92416dbb1..8bacd7cffa3 100644 --- a/c++/src/header.html +++ b/c++/src/header.html @@ -7,7 +7,6 @@ typedef herr_t (*H5DS_iterate_t)(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); +//! #ifdef __cplusplus extern "C" { #endif +/** \page H5DS_UG The HDF5 High Level Dimension Scales + * @todo Under Construction + */ + +/**\defgroup H5DS HDF5 Dimension Scales APIs (H5DS) + * + * Creating and manipulating HDF5 datasets that are associated with + * the dimension of another HDF5 dataset (H5DS) + * + * \note \Bold{Programming hints:} + * \note To use any of these functions or subroutines, + * you must first include the relevant include file (C) or + * module (Fortran) in your application. + * \note The following line includes the HDF5 Dimension Scale package, + * H5DS, in C applications: + * \code #include "hdf5_hl.h" \endcode + * \note This line includes the H5DS module in Fortran applications: + * \code use h5ds \endcode + * + * - \ref H5DSwith_new_ref + * \n Determines if new references are used with dimension scales. + * - \ref H5DSattach_scale + * \n Attach dimension scale dsid to dimension idx of dataset did. + * - \ref H5DSdetach_scale + * \n Detach dimension scale dsid from the dimension idx of Dataset did. + * - \ref H5DSget_label + * \n Read the label for dimension idx of did into buffer label. + * - \ref H5DSget_num_scales + * \n Determines how many Dimension Scales are attached + * to dimension idx of did. + * - \ref H5DSget_scale_name + * \n Retrieves name of scale did into buffer name. + * - \ref H5DSis_attached + * \n Report if dimension scale dsid is currently attached + * to dimension idx of dataset did. + * - \ref H5DSis_scale + * \n Determines whether dset is a Dimension Scale. + * - \ref H5DSiterate_scales + * \n Iterates the operation visitor through the scales + * attached to dimension dim. + * - \ref H5DSset_label + * \n Set label for the dimension idx of did to the value label. + * - \ref H5DSset_scale + * \n Convert dataset dsid to a dimension scale, + * with optional name, dimname. + * + */ + +/* THIS IS A NEW ROUTINE NOT ON OLD PORTAL */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Determines if new references are used with dimension scales. + * + * \param[in] obj_id Object identifier + * \param[out] with_new_ref New references are used or not + * + * \return \herr_t + * + * \details 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. + * + */ +H5_HLDLL herr_t H5DSwith_new_ref(hid_t obj_id, hbool_t *with_new_ref); + +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Attach dimension scale \p dsid to dimension \p idx of + * dataset did. + * + * \param[in] did The dataset + * \param[in] dsid The scale to be attached + * \param[in] idx The dimension of \p did that \p dsid is associated with + * + * \return \herr_t + * + * \details Define Dimension Scale \p dsid to be associated with + * dimension \p idx of dataset \p did. + * + * Entries are created in the #DIMENSION_LIST and + * #REFERENCE_LIST attributes, as defined in section 4.2 of + * + * HDF5 Dimension Scale Specification. + * + * Fails if: + * - Bad arguments + * - If \p dsid is not a Dimension Scale + * - If \p did is a Dimension Scale + * (A Dimension Scale cannot have scales.) + * + * \note The Dimension Scale \p dsid can be attached to the + * same dimension more than once, which has no effect. + */ H5_HLDLL herr_t H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Detach dimension scale \p dsid from the dimension \p idx of dataset \p did. + * + * \param[in] did The dataset + * \param[in] dsid The scale to be detached + * \param[in] idx The dimension of \p did to detach + * + * \return \herr_t + * + * \details If possible, deletes association of Dimension Scale \p dsid with + * dimension \p idx of dataset \p did. This deletes the entries in the + * #DIMENSION_LIST and #REFERENCE_LIST attributes, + * as defined in section 4.2 of + * + * HDF5 Dimension Scale Specification. + * + * Fails if: + * - Bad arguments + * - The dataset \p did or \p dsid do not exist + * - The \p dsid is not a Dimension Scale + * - \p dsid is not attached to \p did + * + * \note A scale may be associated with more than dimension of the + * same dataset. If so, the detach operation only deletes one + * of the associations, for \p did. + * + */ H5_HLDLL herr_t H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Convert dataset \p dsid to a dimension scale, + * with optional name, \p dimname. + * + * \param[in] dsid The dataset to be made a Dimemsion Scale + * \param[in] dimname The dimension name (optional), NULL if the + * dimension has no name. + * + * \return \herr_t + * + * \details The dataset \p dsid is converted to a Dimension Scale dataset, + * as defined above. Creates the CLASS attribute, set to the value + * "DIMENSION_SCALE" and an empty #REFERENCE_LIST attribute, + * as described in + * + * HDF5 Dimension Scale Specification. + * (PDF, see section 4.2). + * + * If \p dimname is specified, then an attribute called NAME + * is created, with the value \p dimname. + * + * Fails if: + * - Bad arguments + * - If \p dsid is already a scale + * - If \p dsid is a dataset which already has dimension scales + * + * If the dataset was created with the Table, Image, or Palette interface [9], + * it is not recommended to convert to a Dimension Scale. + * (These Datasets will have a CLASS Table, Image, or Palette.) + * + * \todo what is [9] after Palette interface? + */ H5_HLDLL herr_t H5DSset_scale(hid_t dsid, const char *dimname); -H5_HLDLL int H5DSget_num_scales(hid_t did, unsigned int dim); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Determines how many Dimension Scales are attached + * to dimension \p idx of \p did. + * + * \param[in] did The dataset to query + * \param[in] idx The dimension of \p did to query + * + * \return Returns the number of Dimension Scales associated + * with \p did, if successful, otherwise returns a + * negative value. + * + * \details H5DSget_num_scales() determines how many Dimension + * Scales are attached to dimension \p idx of + * dataset \p did. + * + */ +H5_HLDLL int H5DSget_num_scales(hid_t did, unsigned int idx); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Set label for the dimension \p idx of \p did + * to the value \p label. + * + * \param[in] did The dataset + * \param[in] idx The dimension + * \param[in] label The label + * + * \return \herr_t + * + * \details Sets the #DIMENSION_LABELS for dimension \p idx of + * dataset \p did. If the dimension had a label, + * the new value replaces the old. + * + * Fails if: + * - Bad arguments + * + */ H5_HLDLL herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Read the label for dimension \p idx of \p did into buffer \p label. + * + * \param[in] did The dataset + * \param[in] idx The dimension + * \param[out] label The label + * \param[in] size The length of the label buffer + * + * \return Upon success, size of label or zero if no label found. + * Negative if fail. + * + * \details Returns the value of the #DIMENSION_LABELS for + * dimension \p idx of dataset \p did, if set. + * Up to \p size characters of the name are copied into + * the buffer \p label. If the label is longer than + * \p size, it will be truncated to fit. The parameter + * \p size is set to the size of the returned \p label. + * + * If \p did has no label, the return value of + * \p label is NULL. + * + * Fails if: + * - Bad arguments + * + */ H5_HLDLL ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Retrieves name of scale \p did into buffer \p name. + * + * \param[in] did Dimension scale identifier + * \param[out] name Buffer to contain the returned name + * \param[in] size Size in bytes, of the \p name buffer + * + * \return Upon success, the length of the scale name or zero if no name found. + * Negative if fail. + * + * \details H5DSget_scale_name() retrieves the name attribute + * for scale \p did. + * + * Up to \p size characters of the scale name are returned + * in \p name; additional characters, if any, are not returned + * to the user application. + * + * If the length of the name, which determines the required value of + * \p size, is unknown, a preliminary H5DSget_scale_name() call can + * be made by setting \p name to NULL. The return value of this call + * will be the size of the scale name; that value plus one (1) can then + * be assigned to \p size for a second H5DSget_scale_name() call, + * which will retrieve the actual name. (The value passed in with the + * parameter \p size must be one greater than size in bytes of the actual + * name in order to accommodate the null terminator; + * if \p size is set to the exact size of the name, the last byte + * passed back will contain the null terminator and the last character + * will be missing from the name passed back to the calling application.) + */ H5_HLDLL ssize_t H5DSget_scale_name(hid_t did, char *name, size_t size); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Determines whether \p did is a Dimension Scale. + * + * \param[in] did The dataset to query + * + * \return \htri_t + * + * \details H5DSis_scale() determines if \p did is a Dimension Scale, + * i.e., has class="DIMENSION_SCALE"). + * + */ H5_HLDLL htri_t H5DSis_scale(hid_t did); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Iterates the operation visitor through the scales + * attached to dimension \p dim. + * + * \param[in] did The dataset + * \param[in] dim The dimension of dataset \p did + * \param[in,out] idx Input the index to start iterating, + * output the next index to visit. + * If NULL, start at the first position. + * \param[in] visitor The visitor function + * \param[in] visitor_data Arbitrary data to pass to the + * visitor function + * + * \return Returns the return value of the last operator if it was + * non-zero, or zero if all scales were processed. + * + * \details H5DSiterate_scales() iterates over the scales attached to + * dimension \p dim of dataset \p did. For each scale in the + * list, the \p visitor_data and some additional information, + * specified below, are passed to the \p visitor function. + * The iteration begins with the \p idx object in the + * group and the next element to be processed by the operator + * is returned in \p idx. If \p idx is NULL, then the + * iterator starts at the first group member; since no + * stopping point is returned in this case, + * the iterator cannot be restarted if one of the calls + * to its operator returns non-zero. + * + * The prototype for \ref H5DS_iterate_t is: + * \snippet this H5DS_iterate_t_snip + * + * The operation receives the Dimension Scale dataset + * identifier, \p scale, and the pointer to the operator + * data passed in to H5DSiterate_scales(), \p visitor_data. + * + * The return values from an operator are: + * + * - Zero causes the iterator to continue, returning zero + * when all group members have been processed. + * - Positive causes the iterator to immediately return that + * positive value, indicating short-circuit success. + * The iterator can be restarted at the next group member. + * - Negative causes the iterator to immediately return + * that value, indicating failure. The iterator can be + * restarted at the next group member. + * + * H5DSiterate_scales() assumes that the scales of the + * dimension identified by \p dim remain unchanged through + * the iteration. If the membership changes during the iteration, + * the function's behavior is undefined. + */ H5_HLDLL herr_t H5DSiterate_scales(hid_t did, unsigned int dim, int *idx, H5DS_iterate_t visitor, void *visitor_data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5DS + * + * \brief Report if dimension scale \p dsid is currently attached to + * dimension \p idx of dataset \p did. + * + * \param[in] did The dataset + * \param[in] dsid The scale to be attached + * \param[in] idx The dimension of \p did that \p dsid is associated with + * + * \return \htri_t + * + * \details Report if dimension scale \p dsid is currently attached to + * dimension \p idx of dataset \p did. + * + * Fails if: + * - Bad arguments + * - If \p dsid is not a Dimension Scale + * - The \p dsid is not a Dimension Scale + * - If \p did is a Dimension Scale (A Dimension Scale cannot have scales.) + * + */ H5_HLDLL htri_t H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx); #ifdef __cplusplus diff --git a/hl/src/H5HLprivate2.h b/hl/src/H5HLprivate2.h index c696b773260..2bd8d01917b 100644 --- a/hl/src/H5HLprivate2.h +++ b/hl/src/H5HLprivate2.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index ff10d573c7c..952bbedca65 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -650,7 +649,7 @@ H5IMlink_palette(hid_t loc_id, const char *image_name, const char *pal_name) /*------------------------------------------------------------------------- * Function: H5IMunlink_palette * - * Purpose: This function dettaches a palette from an existing image dataset + * Purpose: This function detaches a palette from an existing image dataset * * Return: Success: 0, Failure: -1 * @@ -1066,7 +1065,7 @@ H5IMis_image(hid_t loc_id, const char *dset_name) int has_class; hid_t atid; hid_t aid = -1; - char * attr_data; /* Name of attribute */ + char *attr_data; /* Name of attribute */ hsize_t storage_size; /* Size of storage for attribute */ herr_t ret; @@ -1166,7 +1165,7 @@ H5IMis_palette(hid_t loc_id, const char *dset_name) int has_class; hid_t atid; hid_t aid = -1; - char * attr_data; /* Name of attribute */ + char *attr_data; /* Name of attribute */ hsize_t storage_size; /* Size of storage for attribute */ herr_t ret; diff --git a/hl/src/H5IMprivate.h b/hl/src/H5IMprivate.h index 3570ea3352e..29d2669fbd8 100644 --- a/hl/src/H5IMprivate.h +++ b/hl/src/H5IMprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5IMpublic.h b/hl/src/H5IMpublic.h index 2843942e13d..0ba9d648cff 100644 --- a/hl/src/H5IMpublic.h +++ b/hl/src/H5IMpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -18,33 +17,329 @@ extern "C" { #endif +/** \page H5IM_UG The HDF5 High Level Images + * @todo Under Construction + */ + +/**\defgroup H5IM HDF5 Images API (H5IM) + * + * Creating and manipulating HDF5 datasets intended to be + * interpreted as images (H5IM) + * + * The specification for the Images API is presented in another + * document: \ref IMG + * This version of the API is primarily concerned with two dimensional raster + * data similar to HDF4 Raster Images. + * The HDF5 Images API uses the \ref H5LT. + * + * \note \Bold{Programming hints:} + * \note To use any of these functions or subroutines, + * you must first include the relevant include file (C) or + * module (Fortran) in your application. + * \note The following line includes the HDF5 Images package, H5IM, + * in C applications: + * \code #include "hdf5_hl.h" \endcode + * \note This line includes the H5IM module in Fortran applications: + * \code use h5im \endcode + * + * - \ref H5IMget_image_info + * \n Gets information about an image dataset (dimensions, + * interlace mode and number of associated palettes). + * - \ref H5IMget_npalettes + * \n Gets the number of palettes associated to an image. + * - \ref H5IMget_palette + * \n Gets the palette dataset. + * - \ref H5IMget_palette_info + * \n Gets information about a palette dataset (dimensions). + * - \ref H5IMis_image + * \n Inquires if a dataset is an image + * - \ref H5IMis_palette + * \n Inquires if a dataset is a palette. + * - \ref H5IMlink_palette + * \n Attaches a palette to an image. + * - \ref H5IMmake_image_8bit + * \n Creates and writes an image. + * - \ref H5IMmake_image_24bit + * \n Creates and writes a true color image. + * - \ref H5IMmake_palette + * \n Creates and writes a palette. + * - \ref H5IMread_image + * \n Reads image data from disk. + * - \ref H5IMunlink_palette + * \n Detaches a palette from an image. + * + */ + +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Creates and writes an image. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to create + * \param[in] width The width of the image + * \param[in] height The height of the image + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5IMmake_image_8bit() creates and writes a dataset named + * \p dset_name attached to the file or group specified by the + * identifier \p loc_id. Attributes conforming to the HDF5 Image + * and Palette specification for an indexed image are attached to + * the dataset, thus identifying it as an image. The image data is + * of the type #H5T_NATIVE_UCHAR. An indexed image is an image in + * which each each pixel information storage is an index to a + * table palette. + * + */ H5_HLDLL herr_t H5IMmake_image_8bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, const unsigned char *buffer); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Creates and writes a true color image. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to create + * \param[in] width The width of the image + * \param[in] height The height of the image + * \param[in] interlace String defining the interlace mode + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5IMmake_image_24bit() creates and writes a dataset named + * \p dset_name attached to the file or group specified by the + * identifier \p loc_id. This function defines a true color image + * conforming to the HDF5 Image and Palette specification. + * The function assumes that the image data is of the type + * #H5T_NATIVE_UCHAR. + * + * A true color image is an image where the pixel storage contains + * several color planes. In a 24 bit RGB color model, these planes + * are red, green and blue. In a true color image the stream of bytes + * can be stored in several different ways, thus defining the + * interlace (or interleaving) mode. The 2 most used types of interlace mode + * are interlace by pixel and interlace by plane. In the 24 bit RGB color + * model example, interlace by plane means all the red components for the + * entire dataset are stored first, followed by all the green components, + * and then by all the blue components. Interlace by pixel in this example + * means that for each pixel the sequence red, green, blue is defined. + * In this function, the interlace mode is defined in the parameter + * \p interlace, a string that can have the values INTERLACE_PIXEL + * or INTERLACE_PLANE. + * + */ H5_HLDLL herr_t H5IMmake_image_24bit(hid_t loc_id, const char *dset_name, hsize_t width, hsize_t height, const char *interlace, const unsigned char *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Gets information about an image dataset + * (dimensions, interlace mode and number of associated palettes). + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset + * \param[out] width The width of the image + * \param[out] height The height of the image + * \param[out] planes The number of color planes of the image + * \param[out] interlace The interlace mode of the image + * \param[out] npals The number of palettes associated to the image + * + * \return \herr_t + * + * \details H5IMget_image_info() gets information about an image + * named \p dset_name attached to the file or group specified + * by the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5IMget_image_info(hid_t loc_id, const char *dset_name, hsize_t *width, hsize_t *height, hsize_t *planes, char *interlace, hssize_t *npals); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Reads image data from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to create + * \param[out] buffer Buffer with data to store the image + * + * \return \herr_t + * + * \details H5IMread_image() reads a dataset named \p dset_name + * attached to the file or group specified by the + * identifier \p loc_id. + * + */ H5_HLDLL herr_t H5IMread_image(hid_t loc_id, const char *dset_name, unsigned char *buffer); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Creates and writes a palette. + * + * \fg_loc_id + * \param[in] pal_name The name of the palette + * \param[in] pal_dims An array of the size of the palette dimensions + * \param[in] pal_data Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5IMmake_palette() creates and writes a dataset + * named \p pal_name. Attributes conforming to the HDF5 Image and + * Palette specification are attached to the dataset, thus + * identifying it as a palette. The palette data is of the + * type #H5T_NATIVE_UCHAR. + * + */ H5_HLDLL herr_t H5IMmake_palette(hid_t loc_id, const char *pal_name, const hsize_t *pal_dims, const unsigned char *pal_data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Attaches a palette to an image. + * + * \fg_loc_id + * \param[in] image_name The name of the dataset to attach the palette to + * \param[in] pal_name The name of the palette + * + * \return \herr_t + * + * \details H5IMlink_palette() attaches a palette named \p pal_name + * to an image specified by \p image_name. The image dataset + * may or not already have an attached palette. If it has, + * the array of palette references is extended to hold the reference + * to the new palette. + * + */ H5_HLDLL herr_t H5IMlink_palette(hid_t loc_id, const char *image_name, const char *pal_name); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Detaches a palette from an image. + * + * \fg_loc_id + * \param[in] image_name The name of the image dataset + * \param[in] pal_name The name of the palette + * + * \return \herr_t + * + * \details H5IMunlink_palette() detaches a palette from an image + * specified by \p image_name. + * + */ H5_HLDLL herr_t H5IMunlink_palette(hid_t loc_id, const char *image_name, const char *pal_name); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Gets the number of palettes associated to an image. + * + * \fg_loc_id + * \param[in] image_name The name of the image dataset + * \param[out] npals The number of palettes + * + * \return \herr_t + * + * \details H5IMget_npalettes() gets the number of palettes associated to + * an image specified by \p image_name. + * + */ H5_HLDLL herr_t H5IMget_npalettes(hid_t loc_id, const char *image_name, hssize_t *npals); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Gets information about a palette dataset (dimensions). + * + * \fg_loc_id + * \param[in] image_name The name of the image dataset + * \param[in] pal_number The zero based index that identifies + * the palette + * \param[out] pal_dims The dimensions of the palette dataset + * + * \return \herr_t + * + * \details H5IMget_palette_info() gets the dimensions of the palette + * dataset identified by \p pal_number (a zero based index) + * associated to an image specified by \p image_name. + * + */ H5_HLDLL herr_t H5IMget_palette_info(hid_t loc_id, const char *image_name, int pal_number, hsize_t *pal_dims); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Gets the palette dataset. + * + * \fg_loc_id + * \param[in] image_name The name of the image dataset + * \param[in] pal_number The zero based index that identifies + * the palette + * \param[out] pal_data The palette dataset + * + * \return \herr_t + * + * \details H5IMget_palette() gets the palette dataset identified + * by \p pal_number (a zero based index) associated to an + * image specified by \p image_name. + * + */ H5_HLDLL herr_t H5IMget_palette(hid_t loc_id, const char *image_name, int pal_number, unsigned char *pal_data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Inquires if a dataset is an image. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset + * + * \return \htri_t + * + * \details H5IMis_image() inquires if a dataset named \p dset_name, + * attached to the file or group specified by the identifier + * \p loc_id, is an image based on the HDF5 Image and Palette + * Specification. + * + */ H5_HLDLL herr_t H5IMis_image(hid_t loc_id, const char *dset_name); +/** + * -------------------------------------------------------------------------- + * \ingroup H5IM + * + * \brief Inquires if a dataset is a palette + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset + * + * \return \htri_t + * + * \details H5IMis_palette() inquires if a dataset named \p dset_name, + * attached to the file or group specified by the + * identifier \p loc_id, is a palette based on the HDF5 + * Image and Palette Specification. + * + */ H5_HLDLL herr_t H5IMis_palette(hid_t loc_id, const char *dset_name); #ifdef __cplusplus diff --git a/hl/src/H5LD.c b/hl/src/H5LD.c index 8bfd0d682f4..30257f65692 100644 --- a/hl/src/H5LD.c +++ b/hl/src/H5LD.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -29,9 +28,9 @@ static herr_t H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsi * Function: H5LD_clean_vector * * Purpose: Process the vector of info: - * 1) free the array of pointers to member names in listv[n] - * 2) close the type id of the last member in listv[n] - * 3) free the H5LD_memb_t structure itself as pointed to by listv[n] + * 1) free the array of pointers to member names in listv[n] + * 2) close the type id of the last member in listv[n] + * 3) free the H5LD_memb_t structure itself as pointed to by listv[n] * * Return: void * @@ -69,12 +68,12 @@ H5LD_clean_vector(H5LD_memb_t *listv[]) * Function: H5LD_construct_info() * * Purpose: Get the remaining info for a field: - * 1) Get the type id of the last member in the field - * 2) Get the total offset of all the members in the field - * 3) Get the type size of the last member in the field + * 1) Get the type id of the last member in the field + * 2) Get the total offset of all the members in the field + * 3) Get the type size of the last member in the field * * Return: Success: 0 - * Failure: negative + * Failure: negative * * Programmer: Vailin Choi; Aug 2010 * @@ -129,24 +128,24 @@ H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid) * Function: H5LD_construct_vector * * Purpose: Process the comma-separated list of fields in "fields" as follows: - * Example: - * "fields": "a.b.c,d" - * listv[0]->tot_offset = total offset of "a" & "b" & "c" - * listv[0]->last_tid = type id of "c" - * listv[0]->last_tsize = type size of "c" - * listv[0]->names[0] = "a" - * listv[0]->names[1] = "b" - * listv[0]->names[2] = "c" - * listv[0]->names[3] = NULL - * - * listv[1]->tot_offset = offset of "d" - * listv[1]->last_tid = type id of "d" - * listv[1]->last_tsize = type size of "d" - * listv[1]->names[0] = "d" - * listv[1]->names[1] = NULL + * Example: + * "fields": "a.b.c,d" + * listv[0]->tot_offset = total offset of "a" & "b" & "c" + * listv[0]->last_tid = type id of "c" + * listv[0]->last_tsize = type size of "c" + * listv[0]->names[0] = "a" + * listv[0]->names[1] = "b" + * listv[0]->names[2] = "c" + * listv[0]->names[3] = NULL + * + * listv[1]->tot_offset = offset of "d" + * listv[1]->last_tid = type id of "d" + * listv[1]->last_tsize = type size of "d" + * listv[1]->names[0] = "d" + * listv[1]->names[1] = NULL * * Return: Success: # of comma-separated fields in "fields" - * Failure: negative value + * Failure: negative value * * Programmer: Vailin Choi; Aug 2010 * @@ -157,7 +156,7 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[] /*OUT*/, hid_t par_tid) { int nfields; /* The # of comma-separated fields in "fields" */ hbool_t end_of_fields = FALSE; /* end of "fields" */ - char * fields_ptr; /* Pointer to "fields" */ + char *fields_ptr; /* Pointer to "fields" */ int ret_value = FAIL; /* Return value */ HDassert(listv); @@ -169,7 +168,7 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[] /*OUT*/, hid_t par_tid) /* Process till end of "fields" */ while (!end_of_fields) { H5LD_memb_t *memb = NULL; /* Pointer to structure for storing a field's info */ - char * cur; /* Pointer to a member in a field */ + char *cur; /* Pointer to a member in a field */ size_t len; /* Estimated # of members in a field */ hbool_t gotcomma = FALSE; /* A comma encountered */ hbool_t gotmember = FALSE; /* Getting member in a field */ @@ -251,8 +250,10 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[] /*OUT*/, hid_t par_tid) goto done; } /* end if */ else { - if (memb) + if (memb) { + HDfree(memb->names); HDfree(memb); + } goto done; } /* end else */ } /* while !end_of_fields */ @@ -272,10 +273,10 @@ H5LD_construct_vector(char *fields, H5LD_memb_t *listv[] /*OUT*/, hid_t par_tid) * Function: H5LD_get_dset_dims * * Purpose: To return the current size for each dimension of the - * dataset's dataspace + * dataset's dataspace * * Return: Success: 0 - * Failure: negative value + * Failure: negative value * * Programmer: Vailin Choi; March 2010 * @@ -316,12 +317,12 @@ H5LD_get_dset_dims(hid_t did, hsize_t *cur_dims) * Function: H5LD_get_dset_type_size * * Purpose: To return the size of the dataset's datatype in bytes - * null "fields": return the size of the dataset's datatype - * non-null "fields": return the size of the dataset's datatype - * with respect to the selection in "fields" + * null "fields": return the size of the dataset's datatype + * non-null "fields": return the size of the dataset's datatype + * with respect to the selection in "fields" * * Return: Success: size of the dataset's datatype - * Failure: 0 (valid datatypes are never zero size) + * Failure: 0 (valid datatypes are never zero size) * * Programmer: Vailin Choi; March 2010 * @@ -333,7 +334,7 @@ H5LD_get_dset_type_size(hid_t did, const char *fields) hid_t dset_tid = -1; /* Dataset's type identifier */ hid_t tid = -1; /* Native Type identifier */ H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */ - char * dup_fields = NULL; /* A copy of "fields" */ + char *dup_fields = NULL; /* A copy of "fields" */ size_t ret_value = 0; /* Return value */ /* Get the datatype of the dataset */ @@ -402,7 +403,7 @@ H5LD_get_dset_type_size(hid_t did, const char *fields) * Purpose: To retrieve selected data from the dataset * * Return: Success: 0 - * Failure: negative + * Failure: negative * * Programmer: Vailin Choi; August 2010 * @@ -419,8 +420,8 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims hsize_t start[H5S_MAX_RANK]; /* Starting offset */ hsize_t count[H5S_MAX_RANK]; /* ??offset */ H5LD_memb_t **listv = NULL; /* Vector for storing information in "fields" */ - char * dup_fields = NULL; /* A copy of "fields" */ - char * sav_buf = NULL; /* Saved pointer temporary buffer */ + char *dup_fields = NULL; /* A copy of "fields" */ + char *sav_buf = NULL; /* Saved pointer temporary buffer */ unsigned ctr; /* Counter for # of curr_dims > prev_dims */ int ndims; /* Number of dimensions for the dataset */ int i; /* Local index variable */ @@ -492,7 +493,7 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims } /* end if */ else { /* "fields" is specified */ unsigned char *buf_p = (unsigned char *)buf; /* Pointer to the destination buffer */ - char * tmp_buf; /* Temporary buffer for data read */ + char *tmp_buf; /* Temporary buffer for data read */ size_t tot_tsize; /* Total datatype size */ size_t len; /* Estimate the number of comma-separated fields in "fields" */ @@ -578,7 +579,7 @@ H5LD_get_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims * Purpose: To retrieve the current dimension sizes for a dataset * * Return: Success: 0 - * Failure: negative value + * Failure: negative value * * Programmer: Vailin Choi; March 2010 * @@ -596,7 +597,7 @@ H5LDget_dset_dims(hid_t did, hsize_t *cur_dims) * Purpose: To return the size in bytes of the datatype for the dataset * * Return: Success: size in bytes of the dataset's datatype - * Failure: 0 (valid datatypes are never zero size) + * Failure: 0 (valid datatypes are never zero size) * * Programmer: Vailin Choi; March 2010 * @@ -614,7 +615,7 @@ H5LDget_dset_type_size(hid_t did, const char *fields) * Purpose: To retrieve selected data from the dataset * * Return: Success: 0 - * Failure: negative value + * Failure: negative value * * Programmer: Vailin Choi; March 2010 * diff --git a/hl/src/H5LDprivate.h b/hl/src/H5LDprivate.h index 862e5b7d98c..639cdceb885 100644 --- a/hl/src/H5LDprivate.h +++ b/hl/src/H5LDprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5LDpublic.h b/hl/src/H5LDpublic.h index 011b208e4cb..830b48871e8 100644 --- a/hl/src/H5LDpublic.h +++ b/hl/src/H5LDpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -18,8 +17,146 @@ extern "C" { #endif +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Retrieves the current dimension sizes of a dataset. + * + * \param[in] did The dataset identifier + * \param[out] cur_dims The current dimension sizes of the dataset + * + * \return \herr_t + * + * \details H5LDget_dset_dims() retrieves the current dimension sizes + * for the dataset \p did through the parameter \p cur_dims. + * It will return failure if \p cur_dims is NULL. + * + * \note See Also: + * \note Dataset Watch functions (used with h5watch): + * - H5LDget_dset_dims() + * - H5LDget_dset_elmts() + * - H5LDget_dset_type_size() + * + * \par Example: + * See the example code in H5LDget_dset_elmts() for usage of this routine. + * + * \since 1.10.0 + * + */ H5_HLDLL herr_t H5LDget_dset_dims(hid_t did, hsize_t *cur_dims); + +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Returns the size in bytes of the dataset’s datatype + * + * \param[in] did The dataset identifier + * \param[in] fields The pointer to a comma-separated list of fields for a compound datatype + * + * \return If successful, returns the size in bytes of the + * dataset’s datatype. Otherwise, returns 0. + * + * \details H5LDget_dset_type_size() allows the user to find out the datatype + * size for the dataset associated with \p did. If the + * parameter \p fields is NULL, this routine just returns the size + * of the dataset’s datatype. If the dataset has a compound datatype + * and \p fields is non-NULL, this routine returns the size of the + * datatype(s) for the selected fields specified in \p fields. + * Note that ’,’ is the separator for the fields of a compound + * datatype while ’.’ (dot) is the separator for a nested field. + * Use a backslash ( \ ) to escape characters in field names that + * conflict with these two separators. + * + * \note See Also: + * \note Dataset Watch functions (used with h5watch): + * - H5LDget_dset_dims() + * - H5LDget_dset_elmts() + * - H5LDget_dset_type_size() + * + * \par Example: + * See the example code in H5LDget_dset_elmts() for usage of this routine. + * + * \since 1.10.0 + * + */ H5_HLDLL size_t H5LDget_dset_type_size(hid_t did, const char *fields); + +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Retrieves selected data from the dataset + * + * \param[in] did The dataset identifier + * \param[in] prev_dims The previous dimension size of the dataset + * \param[in] cur_dims The current dimension sizes of the dataset + * \param[in] fields A string containing a comma-separated list + * of fields for a compound datatype + * \param[out] buf Buffer for storing data retrieved from the + * dataset + * + * \return \herr_t + * + * \details H5LDget_dset_dims() retrieves selected data of the dataset + * \p did and stores the data in the parameter \p buf. + * The difference between the parameters \p prev_dims and + * \p cur_dims indicates the dimension sizes of the data to be + * selected from the dataset. Note that \p cur_dims must have + * at least one dimension whose size is greater than the + * corresponding dimension in \p prev_dims. Users can + * determine the size of buf by multiplying the datatype + * size of the dataset by the number of selected elements. + * + * If the parameter \p fields is NULL, this routine returns + * data for the selected elements of the dataset. If \p fields + * is not NULL and the dataset has a compound datatype, \p fields + * is a string containing a comma-separated list of fields. + * Each name in \p fields specifies a field in the compound + * datatype, and this routine returns data of the selected fields + * for the dataset's selected elements. Note that ’,’ is the + * separator for the fields of a compound datatype while + * ’.’ is the separator for a nested field. Use backslash to + * escape characters in field names that conflict with these + * two separators. + * + * \note See Also: + * \note Dataset Watch functions (used with h5watch): + * - H5LDget_dset_dims() + * - H5LDget_dset_elmts() + * - H5LDget_dset_type_size() + * + * \par Examples: + * + * For the first example, \c DSET1 is a two-dimensional chunked dataset with atomic type defined below: + * \snippet H5LDget_dset_elmts.c first_declare + * + * The following coding sample illustrates the reading of + * data elements appended to the dataset \c DSET1: + * \snippet H5LDget_dset_elmts.c first_reading + * + * The output buffer will contain data elements selected from + * \c DSET1 as follows: + * \snippet H5LDget_dset_elmts.c first_output + * + * For the second example, DSET2 is a one-dimensional chunked dataset + * with compound type defined below: + * \snippet H5LDget_dset_elmts.c second_declare + * + * The following coding sample illustrates the reading of data elements + * appended to the dataset \c DSET2 with compound datatype. + * This example selects only 2 fields: the fourth field \c d and a + * subfield of the sixth field \c s2.c: + * \snippet H5LDget_dset_elmts.c second_reading + * + * The output buffer will contain data for \c d and \c s2.c + * selected from \c DSET2 as follows: + * \snippet H5LDget_dset_elmts.c second_output + * + * \since 1.10.0 + * + */ H5_HLDLL herr_t H5LDget_dset_elmts(hid_t did, const hsize_t *prev_dims, const hsize_t *cur_dims, const char *fields, void *buf); diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index fb507e7d792..2e089fd6f37 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -20,7 +19,7 @@ #define TMP_LEN 256 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) size_t input_len; -char * myinput; +char *myinput; size_t indent = 0; /* File Image operations @@ -57,12 +56,12 @@ size_t indent = 0; /* Data structure to pass application data to callbacks. */ typedef struct { - void * app_image_ptr; /* Pointer to application buffer */ + void *app_image_ptr; /* Pointer to application buffer */ size_t app_image_size; /* Size of application buffer */ - void * fapl_image_ptr; /* Pointer to FAPL buffer */ + void *fapl_image_ptr; /* Pointer to FAPL buffer */ size_t fapl_image_size; /* Size of FAPL buffer */ int fapl_ref_count; /* Reference counter for FAPL buffer */ - void * vfd_image_ptr; /* Pointer to VFD buffer */ + void *vfd_image_ptr; /* Pointer to VFD buffer */ size_t vfd_image_size; /* Size of VFD buffer */ int vfd_ref_count; /* Reference counter for VFD buffer */ unsigned flags; /* Flags indicate how the file image will */ @@ -71,12 +70,12 @@ typedef struct { } H5LT_file_image_ud_t; /* callbacks prototypes for file image ops */ -static void * image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata); -static void * image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, +static void *image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *udata); +static void *image_memcpy(void *dest, const void *src, size_t size, H5FD_file_image_op_t file_image_op, void *udata); -static void * image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); +static void *image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *udata); static herr_t image_free(void *ptr, H5FD_file_image_op_t file_image_op, void *udata); -static void * udata_copy(void *udata); +static void *udata_copy(void *udata); static herr_t udata_free(void *udata); /* Definition of callbacks for file image operations. */ @@ -102,7 +101,7 @@ static void * image_malloc(size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; - void * return_value = NULL; + void *return_value = NULL; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) @@ -282,7 +281,7 @@ static void * image_realloc(void *ptr, size_t size, H5FD_file_image_op_t file_image_op, void *_udata) { H5LT_file_image_ud_t *udata = (H5LT_file_image_ud_t *)_udata; - void * return_value = NULL; + void *return_value = NULL; /* callback is only used if the application buffer is not actually copied */ if (!(udata->flags & H5LT_FILE_IMAGE_DONT_COPY)) @@ -1776,34 +1775,33 @@ H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_nam } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_float + * Function: H5LTset_attribute_ullong * * Purpose: Create and write an attribute. * * Return: Success: 0, Failure: -1 * - * Programmer: Pedro Vicente + * Programmer: Alessandro Felder * - * Date: July 25, 2001 + * Date: August 27, 2021 * * Comments: * *------------------------------------------------------------------------- */ - herr_t -H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *data, - size_t size) +H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned long long *data, size_t size) { - if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULLONG, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- - * Function: H5LTset_attribute_double + * Function: H5LTset_attribute_float * * Purpose: Create and write an attribute. * @@ -1811,7 +1809,7 @@ H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_nam * * Programmer: Pedro Vicente * - * Date: November 7, 2001 + * Date: July 25, 2001 * * Comments: * @@ -1819,54 +1817,41 @@ H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_nam */ herr_t -H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *data, - size_t size) +H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *data, + size_t size) { - if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0) + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_FLOAT, data) < 0) return -1; return 0; } /*------------------------------------------------------------------------- - * Function: find_attr + * Function: H5LTset_attribute_double + * + * Purpose: Create and write an attribute. * - * Purpose: operator function used by H5LT_find_attribute + * Return: Success: 0, Failure: -1 * * Programmer: Pedro Vicente * - * Date: June 21, 2001 + * Date: November 7, 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 - */ +herr_t +H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *data, + size_t size) +{ - if (HDstrncmp(name, (char *)op_data, MAX(HDstrlen((char *)op_data), HDstrlen(name))) == 0) - ret = H5_ITER_STOP; + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_DOUBLE, data) < 0) + return -1; - return ret; + return 0; } /*------------------------------------------------------------------------- @@ -1900,32 +1885,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_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_DIAG_ON("cast-qual") /*------------------------------------------------------------------------- * Function: H5LTget_attribute_ndims @@ -2146,19 +2121,28 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str size_t size_str_to_add, size_str; if (_no_user_buf) { + char *tmp_realloc; + + if (!buf) + goto out; + /* If the buffer isn't big enough, reallocate it. Otherwise, go to do strcat. */ if (str_to_add && ((ssize_t)(*len - (HDstrlen(buf) + HDstrlen(str_to_add) + 1)) < LIMIT)) { *len += ((HDstrlen(buf) + HDstrlen(str_to_add) + 1) / INCREMENT + 1) * INCREMENT; - buf = (char *)HDrealloc(buf, *len); } else if (!str_to_add && ((ssize_t)(*len - HDstrlen(buf) - 1) < LIMIT)) { *len += INCREMENT; - buf = (char *)HDrealloc(buf, *len); } - } - if (!buf) - goto out; + tmp_realloc = (char *)HDrealloc(buf, *len); + if (tmp_realloc == NULL) { + HDfree(buf); + buf = NULL; + goto out; + } + else + buf = tmp_realloc; + } if (str_to_add) { /* find the size of the buffer to add */ @@ -2171,7 +2155,7 @@ realloc_and_append(hbool_t _no_user_buf, size_t *len, char *buf, const char *str */ if (size_str < *len - 1) { if (size_str + size_str_to_add < *len - 1) { - HDstrncat(buf, str_to_add, size_str_to_add); + HDstrcat(buf, str_to_add); } else { HDstrncat(buf, str_to_add, (*len - 1) - size_str); @@ -2239,7 +2223,7 @@ indentation(size_t x, char *str, hbool_t no_u_buf, size_t *s_len) static char * print_enum(hid_t type, char *str, size_t *str_len, hbool_t no_ubuf, size_t indt) { - char ** name = NULL; /*member names */ + char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ int nmembs; /*number of members */ char tmp_str[TMP_LEN]; @@ -2374,9 +2358,9 @@ print_enum(hid_t type, char *str, size_t *str_len, hbool_t no_ubuf, size_t indt) herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) { - size_t str_len = INCREMENT; - char * text_str; - herr_t ret = SUCCEED; + size_t str_len = INCREMENT; + char *text_str = NULL; + herr_t ret = SUCCEED; if (lang_type <= H5LT_LANG_ERR || lang_type >= H5LT_NO_LANG) goto out; @@ -2400,6 +2384,8 @@ H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len) return ret; out: + HDfree(text_str); + return FAIL; } @@ -2542,11 +2528,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"); @@ -2766,7 +2750,7 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb case H5T_ENUM: { hid_t super; size_t super_len; - char * stmp = NULL; + char *stmp = NULL; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_ENUM {\n"); @@ -2779,10 +2763,14 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); - if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + HDfree(stmp); goto out; - if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + HDfree(stmp); goto out; + } if (stmp) HDfree(stmp); @@ -2809,7 +2797,7 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb case H5T_VLEN: { hid_t super; size_t super_len; - char * stmp = NULL; + char *stmp = NULL; /* Print lead-in */ HDsnprintf(dt_str, *slen, "H5T_VLEN {\n"); @@ -2822,10 +2810,14 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); - if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + HDfree(stmp); goto out; - if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + HDfree(stmp); goto out; + } if (stmp) HDfree(stmp); @@ -2848,7 +2840,7 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb case H5T_ARRAY: { hid_t super; size_t super_len; - char * stmp = NULL; + char *stmp = NULL; hsize_t dims[H5S_MAX_RANK]; int ndims; @@ -2879,10 +2871,14 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb if (H5LTdtype_to_text(super, NULL, lang, &super_len) < 0) goto out; stmp = (char *)HDcalloc(super_len, sizeof(char)); - if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) + if (H5LTdtype_to_text(super, stmp, lang, &super_len) < 0) { + HDfree(stmp); goto out; - if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, stmp))) { + HDfree(stmp); goto out; + } if (stmp) HDfree(stmp); stmp = NULL; @@ -2902,12 +2898,12 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb break; } case H5T_COMPOUND: { - char * mname = NULL; + char *mname = NULL; hid_t mtype; size_t moffset; H5T_class_t mclass; size_t mlen; - char * mtmp = NULL; + char *mtmp = NULL; int nmembs; if ((nmembs = H5Tget_nmembers(dtype)) < 0) @@ -2933,10 +2929,14 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, hb if (H5LTdtype_to_text(mtype, NULL, lang, &mlen) < 0) goto out; mtmp = (char *)HDcalloc(mlen, sizeof(char)); - if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) + if (H5LTdtype_to_text(mtype, mtmp, lang, &mlen) < 0) { + HDfree(mtmp); goto out; - if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) + } + if (!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, mtmp))) { + HDfree(mtmp); goto out; + } if (mtmp) HDfree(mtmp); mtmp = NULL; @@ -3289,6 +3289,33 @@ H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_nam return 0; } +/*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ullong + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Alessandro Felder + * + * Date: August 27, 2021 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long long *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULLONG, data) < 0) + return -1; + + return 0; +} + /*------------------------------------------------------------------------- * Function: H5LTget_attribute_float * @@ -3576,9 +3603,9 @@ H5LT_set_attribute_string(hid_t dset_id, const char *name, const char *buf) htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid) { - char * tmp_path = NULL; /* Temporary copy of the path */ - char * curr_name; /* Pointer to current component of path name */ - char * delimit; /* Pointer to path delimiter during traversal */ + char *tmp_path = NULL; /* Temporary copy of the path */ + char *curr_name; /* Pointer to current component of path name */ + char *delimit; /* Pointer to path delimiter during traversal */ H5I_type_t obj_type; htri_t link_exists, obj_exists; size_t path_length; diff --git a/hl/src/H5LTanalyze.c b/hl/src/H5LTanalyze.c index 875a37a9eed..55505c57de1 100644 --- a/hl/src/H5LTanalyze.c +++ b/hl/src/H5LTanalyze.c @@ -10,6 +10,7 @@ #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wstrict-overflow" #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #if !defined (__clang__) #pragma GCC diagnostic ignored "-Wlarger-than=" #pragma GCC diagnostic ignored "-Wsuggest-attribute=const" @@ -891,7 +892,6 @@ char *yytext; #line 1 "hl/src/H5LTanalyze.l" /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l index 50066126fbf..6133a9898c1 100644 --- a/hl/src/H5LTanalyze.l +++ b/hl/src/H5LTanalyze.l @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5LTparse.c b/hl/src/H5LTparse.c index 7f552d8cb00..fe9854ee868 100644 --- a/hl/src/H5LTparse.c +++ b/hl/src/H5LTparse.c @@ -10,6 +10,7 @@ #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wstrict-overflow" #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #if !defined (__clang__) #pragma GCC diagnostic ignored "-Wlarger-than=" #pragma GCC diagnostic ignored "-Wsuggest-attribute=const" diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y index 01f6ded1f61..93e72a35068 100644 --- a/hl/src/H5LTparse.y +++ b/hl/src/H5LTparse.y @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5LTprivate.h b/hl/src/H5LTprivate.h index 5a97d9c22f6..73ed501e72a 100644 --- a/hl/src/H5LTprivate.h +++ b/hl/src/H5LTprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h index 2af9b07a0ff..7ef51d4efb4 100644 --- a/hl/src/H5LTpublic.h +++ b/hl/src/H5LTpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -19,7 +18,7 @@ #define H5LT_FILE_IMAGE_DONT_COPY 0x0002 /* The HDF5 lib won't copy */ /* user supplied image buffer. The same image is open with the core driver. */ #define H5LT_FILE_IMAGE_DONT_RELEASE 0x0004 /* The HDF5 lib won't */ -/* deallocate user supplied image buffer. The user application is reponsible */ +/* deallocate user supplied image buffer. The user application is responsible */ /* for doing so. */ #define H5LT_FILE_IMAGE_ALL 0x0007 @@ -35,6 +34,124 @@ typedef enum H5LT_lang_t { extern "C" { #endif +/** \page H5LT_UG The HDF5 High Level Lite + * @todo Under Construction + */ + +/**\defgroup H5LT HDF5 Lite APIs (H5LT,H5LD) + * Functions used to simplify creating and manipulating datasets, + * attributes and other features (H5LT, H5LD) + * + * The HDF5 Lite API consists of higher-level functions which do + * more operations per call than the basic HDF5 interface. + * The purpose is to wrap intuitive functions around certain sets + * of features in the existing APIs. + * It has the following sets of functions listed below. + * + * \note \Bold{Programming hints:} + * \note To use any of these functions or subroutines, + * you must first include the relevant include file (C) or + * module (Fortran) in your application. + * \note The following line includes the HDF5 Lite package, H5LT, + * in C applications: + * \code #include "hdf5_hl.h" \endcode + * \note This line includes the H5LT module in Fortran applications: + * \code use h5lt \endcode + * + * + * + *
+ * + * - Dataset Functions + * - Make dataset functions + * - \ref H5LTmake_dataset + * - \ref H5LTmake_dataset_char + * - \ref H5LTmake_dataset_short + * - \ref H5LTmake_dataset_int + * - \ref H5LTmake_dataset_long + * - \ref H5LTmake_dataset_float + * - \ref H5LTmake_dataset_double + * - \ref H5LTmake_dataset_string + * + * - Read dataset functions + * - \ref H5LTread_dataset + * - \ref H5LTread_dataset_char + * - \ref H5LTread_dataset_short + * - \ref H5LTread_dataset_int + * - \ref H5LTread_dataset_long + * - \ref H5LTread_dataset_float + * - \ref H5LTread_dataset_double + * - \ref H5LTread_dataset_string + * + * - Query dataset functions + * - \ref H5LTfind_dataset + * - \ref H5LTget_dataset_ndims + * - \ref H5LTget_dataset_info + * + * - Dataset watch functions + * - \ref H5LDget_dset_dims + * - \ref H5LDget_dset_elmts + * - \ref H5LDget_dset_type_size + * + * + * + * - Attribute Functions + * - Set attribute functions + * - \ref H5LTset_attribute_string + * - \ref H5LTset_attribute_char + * - \ref H5LTset_attribute_uchar + * - \ref H5LTset_attribute_short + * - \ref H5LTset_attribute_ushort + * - \ref H5LTset_attribute_int + * - \ref H5LTset_attribute_uint + * - \ref H5LTset_attribute_long + * - \ref H5LTset_attribute_long_long + * - \ref H5LTset_attribute_ulong + * - \ref H5LTset_attribute_ullong + * - \ref H5LTset_attribute_float + * - \ref H5LTset_attribute_double + * - H5LTset_attribute_f (fortran ONLY) + * + * - Get attribute functions + * - \ref H5LTget_attribute + * - \ref H5LTget_attribute_string + * - \ref H5LTget_attribute_char + * - \ref H5LTget_attribute_uchar + * - \ref H5LTget_attribute_short + * - \ref H5LTget_attribute_ushort + * - \ref H5LTget_attribute_int + * - \ref H5LTget_attribute_uint + * - \ref H5LTget_attribute_long + * - \ref H5LTget_attribute_long_long + * - \ref H5LTget_attribute_ulong + * - \ref H5LTget_attribute_ullong + * - \ref H5LTget_attribute_float + * - \ref H5LTget_attribute_double + * + * - Query attribute functions + * - \ref H5LTfind_attribute + * - \ref H5LTget_attribute_info + * - \ref H5LTget_attribute_ndims + * + * + * + * - Datatype Functions + * - Datatype translation functions + * - \ref H5LTtext_to_dtype + * - \ref H5LTdtype_to_text + * + * - File image function + * - Open file image function + * - \ref H5LTopen_file_image + * + * - Path and object function + * - Query path and object function + * - \ref H5LTpath_valid + * + *
+ * + */ + /*------------------------------------------------------------------------- * * Make dataset functions @@ -42,27 +159,214 @@ extern "C" { *------------------------------------------------------------------------- */ +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a dataset of a type \p type_id. + * + * \fg_loc_id + * \param[in] dset_name The Name of the dataset to create + * \param[in] rank Number of dimensions of dataspace + * \param[in] dims An array of the size of each dimension + * \param[in] type_id Identifier of the datatype to use when creating the dataset + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5LTmake_dataset() creates and writes a dataset named + * \p dset_name attached to the object specified by the + * identifier \p loc_id. + * + * The parameter \p type_id can be any valid HDF5 Prdefined \ref PDTNAT; + * For example, setting \p type_id to #H5T_NATIVE_INT will result in a dataset + * of signed \e integer datatype. + * + * \version 1.10.0 Fortran 2003 subroutine added to accept a C address of the data buffer. + * \version 1.8.7 Fortran subroutine modified in this release to accommodate arrays + * with more than three dimensions. + * + */ H5_HLDLL herr_t H5LTmake_dataset(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, hid_t type_id, const void *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a dataset. + * + * \fg_loc_id + * \param[in] dset_name The Name of the dataset to create + * \param[in] rank Number of dimensions of dataspace + * \param[in] dims An array of the size of each dimension + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5LTmake_dataset_char() creates and writes a dataset + * named \p dset_name attached to the object specified by + * the identifier \p loc_id. + * + * The dataset’s datatype will be \e character, #H5T_NATIVE_CHAR. + * + */ H5_HLDLL herr_t H5LTmake_dataset_char(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const char *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a dataset. + * + * \fg_loc_id + * \param[in] dset_name The Name of the dataset to create + * \param[in] rank Number of dimensions of dataspace + * \param[in] dims An array of the size of each dimension + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5LTmake_dataset_short() creates and writes a dataset + * named \p dset_name attached to the object specified by + * the identifier \p loc_id. + * + * The dataset’s datatype will be short signed integer, + * #H5T_NATIVE_SHORT. + * + */ H5_HLDLL herr_t H5LTmake_dataset_short(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const short *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a dataset. + * + * \fg_loc_id + * \param[in] dset_name The Name of the dataset to create + * \param[in] rank Number of dimensions of dataspace + * \param[in] dims An array of the size of each dimension + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5LTmake_dataset_int() creates and writes a dataset + * named \p dset_name attached to the object specified by + * the identifier \p loc_id. + * + * The dataset’s datatype will be native signed integer, + * #H5T_NATIVE_INT. + * + * \version Fortran subroutine modified in this release to accommodate + * arrays with more than three dimensions. + * + */ H5_HLDLL herr_t H5LTmake_dataset_int(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const int *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a dataset. + * + * \fg_loc_id + * \param[in] dset_name The Name of the dataset to create + * \param[in] rank Number of dimensions of dataspace + * \param[in] dims An array of the size of each dimension + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5LTmake_dataset_long() creates and writes a dataset + * named \p dset_name attached to the object specified by + * the identifier \p loc_id. + * + * The dataset’s datatype will be long signed integer, + * #H5T_NATIVE_LONG. + * + */ H5_HLDLL herr_t H5LTmake_dataset_long(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const long *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a dataset. + * + * \fg_loc_id + * \param[in] dset_name The Name of the dataset to create + * \param[in] rank Number of dimensions of dataspace + * \param[in] dims An array of the size of each dimension + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5LTmake_dataset_float() creates and writes a dataset + * named \p dset_name attached to the object specified by + * the identifier \p loc_id. + * + * The dataset’s datatype will be native floating point, + * #H5T_NATIVE_FLOAT. + * + * \version 1.8.7 Fortran subroutine modified in this release to accommodate + * arrays with more than three dimensions. + * + */ H5_HLDLL herr_t H5LTmake_dataset_float(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const float *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a dataset. + * + * \fg_loc_id + * \param[in] dset_name The Name of the dataset to create + * \param[in] rank Number of dimensions of dataspace + * \param[in] dims An array of the size of each dimension + * \param[in] buffer Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5LTmake_dataset_double() creates and writes a dataset + * named \p dset_name attached to the object specified by + * the identifier \p loc_id. + * + * The dataset’s datatype will be + * native floating-point double, #H5T_NATIVE_DOUBLE. + * + * \version 1.8.7 Fortran subroutine modified in this release to accommodate + * arrays with more than three dimensions. + * + */ H5_HLDLL herr_t H5LTmake_dataset_double(hid_t loc_id, const char *dset_name, int rank, const hsize_t *dims, const double *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a dataset with string datatype. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to create + * \param[in] buf Buffer with data to be written to the dataset + * + * \return \herr_t + * + * \details H5LTmake_dataset_string() creates and writes a dataset + * named \p dset_name attached to the object specified by + * the identifier \p loc_id. + * + * The dataset’s datatype will be C string, #H5T_C_S1. + * + */ H5_HLDLL herr_t H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, const char *buf); /*------------------------------------------------------------------------- @@ -72,20 +376,169 @@ H5_HLDLL herr_t H5LTmake_dataset_string(hid_t loc_id, const char *dset_name, con *------------------------------------------------------------------------- */ +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a dataset from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[in] type_id Identifier of the datatype to use when reading + * the dataset + * \param[out] buffer Buffer with data + * + * \return \herr_t + * + * \details H5LTread_dataset() reads a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * + * \version 1.10.0 Fortran 2003 subroutine added to accept a C + * address of the data buffer. + * \version 1.8.7 Fortran subroutine modified in this release to + * accommodate arrays with more than three dimensions. + * + */ H5_HLDLL herr_t H5LTread_dataset(hid_t loc_id, const char *dset_name, hid_t type_id, void *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a dataset from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] buffer Buffer with data + * + * \return \herr_t + * + * \details H5LTread_dataset_char() reads a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * The HDF5 datatype is #H5T_NATIVE_CHAR. + * + */ H5_HLDLL herr_t H5LTread_dataset_char(hid_t loc_id, const char *dset_name, char *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a dataset from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] buffer Buffer with data + * + * \return \herr_t + * + * \details H5LTread_dataset_short() reads a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * The HDF5 datatype is #H5T_NATIVE_SHORT. + * + */ H5_HLDLL herr_t H5LTread_dataset_short(hid_t loc_id, const char *dset_name, short *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a dataset from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] buffer Buffer with data + * + * \return \herr_t + * + * \details H5LTread_dataset_int() reads a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * The HDF5 datatype is #H5T_NATIVE_INT. + * + * \version 1.8.7 Fortran subroutine modified in this release to + * accommodate arrays with more than three dimensions. + * + */ H5_HLDLL herr_t H5LTread_dataset_int(hid_t loc_id, const char *dset_name, int *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a dataset from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] buffer Buffer with data + * + * \return \herr_t + * + * \details H5LTread_dataset_long() reads a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * The HDF5 datatype is #H5T_NATIVE_LONG. + * + */ H5_HLDLL herr_t H5LTread_dataset_long(hid_t loc_id, const char *dset_name, long *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a dataset from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] buffer Buffer with data + * + * \return \herr_t + * + * \details H5LTread_dataset_float() reads a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * The HDF5 datatype is #H5T_NATIVE_FLOAT. + * + * \version 1.8.7 Fortran subroutine modified in this release to + * accommodate arrays with more than three dimensions. + */ H5_HLDLL herr_t H5LTread_dataset_float(hid_t loc_id, const char *dset_name, float *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a dataset from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] buffer Buffer with data + * + * \return \herr_t + * + * \details H5LTread_dataset_double() reads a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * The HDF5 datatype is #H5T_NATIVE_DOUBLE. + * + * \version 1.8.7 Fortran subroutine modified in this release to + * accommodate arrays with more than three dimensions. + */ H5_HLDLL herr_t H5LTread_dataset_double(hid_t loc_id, const char *dset_name, double *buffer); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a dataset from disk. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] buf Buffer with data + * + * \return \herr_t + * + * \details H5LTread_dataset_string() reads a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * The HDF5 datatype is #H5T_C_S1. + * + */ H5_HLDLL herr_t H5LTread_dataset_string(hid_t loc_id, const char *dset_name, char *buf); /*------------------------------------------------------------------------- @@ -95,11 +548,67 @@ H5_HLDLL herr_t H5LTread_dataset_string(hid_t loc_id, const char *dset_name, cha *------------------------------------------------------------------------- */ +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Gets the dimensionality of a dataset + * + * \param[in] loc_id Identifier of the object to + * locate the dataset within + * \param[in] dset_name The dataset name + * \param[out] rank The dimensionality of the dataset + * + * \return \herr_t + * + * \details H5LTget_dataset_ndims() gets the dimensionality of a dataset + * named \p dset_name exists attached to the object \p loc_id. + * + */ H5_HLDLL herr_t H5LTget_dataset_ndims(hid_t loc_id, const char *dset_name, int *rank); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Retrieves information about a dataset + * + * \param[in] loc_id Identifier of the object to locate + * the dataset within + * \param[in] dset_name The dataset name + * \param[out] dims The dimensions of the dataset + * \param[out] type_class The class identifier. #H5T_class_t is defined in + * H5Tpublic.h. See H5Tget_class() for a list + * of class types. + * \param[out] type_size The size of the datatype in bytes + * + * \return \herr_t + * + * \details H5LTget_dataset_info() retrieves information about a dataset + * named \p dset_name attached to the object \p loc_id. + * + */ H5_HLDLL herr_t H5LTget_dataset_info(hid_t loc_id, const char *dset_name, hsize_t *dims, H5T_class_t *type_class, size_t *type_size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Determines whether a dataset exists. + * + * \param[in] loc_id Identifier of the group containing the dataset + * \param[in] name Dataset name + * + * \return \htri_t + * + * \details H5LTfind_dataset() determines whether a dataset named + * \p name exists in the group specified by \p loc_id. + * + * \p loc_id must be a group identifier and \p name must + * specify a dataset that is a member of that group. + * + */ H5_HLDLL herr_t H5LTfind_dataset(hid_t loc_id, const char *name); /*------------------------------------------------------------------------- @@ -109,39 +618,343 @@ H5_HLDLL herr_t H5LTfind_dataset(hid_t loc_id, const char *name); *------------------------------------------------------------------------- */ +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes a string attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] attr_data Buffer with data to be written to the attribute + * + * \return \herr_t + * + * \details H5LTset_attribute_string() creates and writes a string attribute + * named \p attr_name and attaches it to the object specified by + * the name \p obj_name. If the attribute already exists, + * it is overwritten. + * + */ H5_HLDLL herr_t H5LTset_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, const char *attr_data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_char() creates and writes a numerical attribute + * named \p attr_name and attaches it to the object specified by the + * name \p obj_name. The attribute has a dimensionality of 1. + * The HDF5 datatype of the attribute is #H5T_NATIVE_CHAR. + * + */ H5_HLDLL herr_t H5LTset_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, const char *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_uchar() creates and writes a numerical attribute + * named \p attr_name and attaches it to the object specified by the + * name \p obj_name. The attribute has a dimensionality of 1. + * The HDF5 datatype of the attribute is #H5T_NATIVE_UCHAR. + * + */ H5_HLDLL herr_t H5LTset_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned char *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_short() creates and writes a numerical attribute + * named \p attr_name and attaches it to the object specified by the + * name \p obj_name. The attribute has a dimensionality of 1. + * The HDF5 datatype of the attribute is #H5T_NATIVE_SHORT. + * + */ H5_HLDLL herr_t H5LTset_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, const short *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_ushort() creates and writes a numerical attribute + * named \p attr_name and attaches it to the object specified by the + * name \p obj_name. The attribute has a dimensionality of 1. + * The HDF5 datatype of the attribute is #H5T_NATIVE_USHORT. + * + */ H5_HLDLL herr_t H5LTset_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned short *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_int() creates and writes a numerical integer + * attribute named \p attr_name and attaches it to the object + * specified by the name \p obj_name. The attribute has a + * dimensionality of 1. The HDF5 datatype of the attribute + * is #H5T_NATIVE_INT. + * + */ H5_HLDLL herr_t H5LTset_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, const int *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_uint() creates and writes a numerical integer + * attribute named \p attr_name and attaches it to the object specified + * by the name \p obj_name. The attribute has a dimensionality of 1. + * The HDF5 datatype of the attribute is #H5T_NATIVE_UINT. + * + */ H5_HLDLL herr_t H5LTset_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned int *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_long() creates and writes a numerical + * attribute named \p attr_name and attaches it to the object + * specified by the name \p obj_name. The attribute has a + * dimensionality of 1. The HDF5 datatype of the attribute + * is #H5T_NATIVE_LONG. + * + */ H5_HLDLL herr_t H5LTset_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Location of the object to which the attribute + * is to be attached + * \param[in] obj_name That object's name + * \param[in] attr_name Attribute name + * \param[in] buffer Attribute value + * \param[in] size Attribute size + * + * \return \herr_t + * + * \details H5LTset_attribute_long_long() creates and writes a numerical + * attribute named \p attr_name and attaches it to the object + * specified by the name \p obj_name. + * + * The attribute has a dimensionality of 1 and its HDF5 datatype + * is #H5T_NATIVE_LLONG. + * + */ H5_HLDLL herr_t H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, const long long *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_ulong() creates and writes a numerical + * attribute named \p attr_name and attaches it to the object + * specified by the name \p obj_name. The attribute has a + * dimensionality of 1. The HDF5 datatype of the attribute + * is #H5T_NATIVE_ULONG. + * + */ H5_HLDLL herr_t H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Location of the object to which the attribute + * is to be attached + * \param[in] obj_name That object's name + * \param[in] attr_name Attribute name + * \param[in] buffer Attribute value + * \param[in] size Attribute size + * + * \return \herr_t + * + * \details H5LTset_attribute_ullong() creates and writes a numerical + * attribute named \p attr_name and attaches it to the object + * specified by the name \p obj_name. + * + * The attribute has a dimensionality of 1 and its HDF5 datatype + * is #H5T_NATIVE_ULLONG. + * + */ +H5_HLDLL herr_t H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned long long *buffer, size_t size); + +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_float() creates and writes a numerical + * floating point attribute named \p attr_name and attaches + * it to the object specified by the name \p obj_name. + * The attribute has a dimensionality of 1. The HDF5 datatype + * of the attribute is #H5T_NATIVE_FLOAT. + * + */ H5_HLDLL herr_t H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *buffer, size_t size); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates and writes an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to create the attribute within + * \param[in] obj_name The name of the object to attach the attribute + * \param[in] attr_name The attribute name + * \param[in] buffer Buffer with data to be written to the attribute + * \param[in] size The size of the 1D array (one in the case of a + * scalar attribute). This value is used by + * H5Screate_simple() to create the dataspace. + * + * \return \herr_t + * + * \details H5LTset_attribute_double() creates and writes a numerical + * attribute named \p attr_name and attaches + * it to the object specified by the name \p obj_name. + * The attribute has a dimensionality of 1. The HDF5 datatype + * of the attribute is #H5T_NATIVE_DOUBLE. + * + */ H5_HLDLL herr_t H5LTset_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, const double *buffer, size_t size); @@ -152,39 +965,337 @@ H5_HLDLL herr_t H5LTset_attribute_double(hid_t loc_id, const char *obj_name, con *------------------------------------------------------------------------- */ +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[in] mem_type_id Identifier of the memory datatype + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute() reads an attribute named + * \p attr_name with the memory type \p mem_type_id. + * + */ H5_HLDLL herr_t H5LTget_attribute(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t mem_type_id, void *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_string() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The datatype is a string. + * + * \version 1.8.9 The content of the buffer returned by the Fortran + * subroutine has changed in this release:\n + * If the returned buffer requires padding, + * h5ltget_attribute_string_f() now employs space + * padding; this buffer was previously returned with a C NULL terminator. + * + */ H5_HLDLL herr_t H5LTget_attribute_string(hid_t loc_id, const char *obj_name, const char *attr_name, char *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_char() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The datatype of the attribute + * is #H5T_NATIVE_CHAR. + * + */ H5_HLDLL herr_t H5LTget_attribute_char(hid_t loc_id, const char *obj_name, const char *attr_name, char *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_uchar() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_UCHAR + * + */ H5_HLDLL herr_t H5LTget_attribute_uchar(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned char *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_short() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_SHORT + * + */ H5_HLDLL herr_t H5LTget_attribute_short(hid_t loc_id, const char *obj_name, const char *attr_name, short *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_ushort() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_USHORT. + * + */ H5_HLDLL herr_t H5LTget_attribute_ushort(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned short *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_int() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_INT. + * + */ H5_HLDLL herr_t H5LTget_attribute_int(hid_t loc_id, const char *obj_name, const char *attr_name, int *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_uint() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_INT. + * + */ H5_HLDLL herr_t H5LTget_attribute_uint(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned int *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_long() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_LONG. + * + */ H5_HLDLL herr_t H5LTget_attribute_long(hid_t loc_id, const char *obj_name, const char *attr_name, long *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads a \e long \e long attribute. + * + * \param[in] loc_id Location of the object to which + * the attribute is attached + * \param[in] obj_name That object's name + * \param[in] attr_name Attribute name + * \param[out] data Attribute value + * + * \return \herr_t + * + * \details H5LTget_attribute_long_long() reads the attribute + * specified by \p loc_id and \p obj_name. + * + */ H5_HLDLL herr_t H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, const char *attr_name, long long *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_ulong() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_ULONG. + * + */ H5_HLDLL herr_t H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_ullong() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_ULLONG. + * + */ +H5_HLDLL herr_t H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned long long *data); + +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_float() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_FLOAT. + * + */ H5_HLDLL herr_t H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, float *data); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Reads an attribute from disk. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] data Buffer with data + * + * \return \herr_t + * + * \details H5LTget_attribute_double() reads an attribute named + * \p attr_name that is attached to the object specified + * by the name \p obj_name. The HDF5 datatype of the + * attribute is #H5T_NATIVE_DOUBLE. + * + */ H5_HLDLL herr_t H5LTget_attribute_double(hid_t loc_id, const char *obj_name, const char *attr_name, double *data); @@ -195,8 +1306,55 @@ H5_HLDLL herr_t H5LTget_attribute_double(hid_t loc_id, const char *obj_name, con *------------------------------------------------------------------------- */ +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Gets the dimensionality of an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] rank The dimensionality of the attribute + * + * \return \herr_t + * + * \details H5LTget_attribute_ndims() gets the dimensionality of an attribute + * named \p attr_name that is attached to the object specified + * by the name \p obj_name. + * + */ H5_HLDLL herr_t H5LTget_attribute_ndims(hid_t loc_id, const char *obj_name, const char *attr_name, int *rank); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Gets information about an attribute. + * + * \param[in] loc_id Identifier of the object (dataset or group) + * to read the attribute from + * \param[in] obj_name The name of the object that the attribute is + * attached to + * \param[in] attr_name The attribute name + * \param[out] dims The dimensions of the attribute + * \param[out] type_class The class identifier. #H5T_class_t is + * defined in H5Tpublic.h. For a list of valid class + * types see: H5Tget_class(). + * \param[out] type_size The size of the datatype in bytes + * + * \return \herr_t + * + * \details H5LTget_attribute_info() gets information about an attribute + * named \p attr_name attached to the object specified by + * the name \p obj_name. + * + * \par Example + * \snippet H5LT_examples.c get_attribute_info + * + */ H5_HLDLL herr_t H5LTget_attribute_info(hid_t loc_id, const char *obj_name, const char *attr_name, hsize_t *dims, H5T_class_t *type_class, size_t *type_size); @@ -207,7 +1365,74 @@ H5_HLDLL herr_t H5LTget_attribute_info(hid_t loc_id, const char *obj_name, const *------------------------------------------------------------------------- */ -H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates an HDF5 datatype given a text description. + * + * \param[in] text A character string containing a DDL + * definition of the datatype to be created + * \param[in] lang_type The language used to describe the datatype. + * The only currently supported language is + * #H5LT_DDL. + * + * \return Returns the datatype identifier(non-negative) if successful; + * otherwise returns a negative value. + * + * \details Given a text description of a datatype, this function creates + * an HDF5 datatype and returns the datatype identifier. + * The text description of the datatype has to comply with the + * \p lang_type definition of HDF5 datatypes. + * Currently, only the DDL(#H5LT_DDL) is supported. + * The complete DDL definition of HDF5 datatypes can be found in + * the last chapter of the + * + * HDF5 User's Guide. + * + * \par Example + * An example of DDL definition of \c enum type is shown as follows. + * \snippet H5LT_examples.c enum + * + */ +H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type); + +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Creates a text description of an HDF5 datatype. + * + * \param[in] dtype Identifier of the datatype to be converted + * \param[out] str Buffer for the text description of the datatype + * \param[in] lang_type The language used to describe the datatype. + * The currently supported language is #H5LT_DDL. + * \param[out] len The size of buffer needed to store the text description + * + * \return \herr_t + * + * \details Given an HDF5 datatype identifier, this function creates + * a description of this datatype in \p lang_type language format. + * A preliminary H5LTdtype_to_text() call can be made to determine + * the size of the buffer needed with a NULL passed in for \p str. + * This value is returned as \p len. That value can then be assigned + * to len for a second H5Ttype_to_text() call, which will + * retrieve the actual text description for the datatype. + * + * If \p len is not big enough for the description, the text + * description will be truncated to fit in the buffer. + * + * Currently only DDL (#H5LT_DDL) is supported for \p lang_type. + * The complete DDL definition of HDF5 data types can be found in + * the last chapter of the + * + * HDF5 User's Guide. + * + * \par Example + * An example of DDL definition of \c enum type is shown as follows. + * \snippet H5LT_examples.c enum + * + */ H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len); /*------------------------------------------------------------------------- @@ -217,8 +1442,115 @@ H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, *------------------------------------------------------------------------- */ +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Determines whether an attribute exists. + * + * \param[in] loc_id Identifier of the object to which the attribute + * is expected to be attached + * \param[in] name Attribute name + * + * \return \htri_t + * + * \details H5LTfind_attribute() determines whether an attribute named + * \p name exists attached to the object specified + * by \p loc_id. + * + * \p loc_id must be an object identifier and \p name + * must specify an attribute that is expected to be attached + * to that object. + * + */ H5_HLDLL herr_t H5LTfind_attribute(hid_t loc_id, const char *name); +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Determines whether an HDF5 path is valid and, optionally, + * whether the path resolves to an HDF5 object. + * + * \param[in] loc_id Identifier of an object in the file + * \param[in] path The path to the object to check; + * links in \p path may be of any type. + * \param[in] check_object_valid If TRUE, determine whether the final + * component of \p path resolves to + * an object; if FALSE, do not check. + * + * \return Upon success: + * \return If \p check_object_valid is set to \c FALSE: + * \return Returns \c TRUE if the path is valid; + * otherwise returns \c FALSE. + * \return If \p check_object_valid is set to \c TRUE: + * \return Returns \c TRUE if the path is valid and + * resolves to an HDF5 object; + * otherwise returns \c FALSE. + * + * \return Upon error, returns a negative value. + * + * \details H5LTpath_valid() checks the validity of \p path relative + * to the identifier of an object, \p loc_id. Optionally, + * \p check_object_valid can be set to determine whether the + * final component of \p path resolves to an HDF5 object; + * if not, the final component is a dangling link. + * + * The meaning of the function’s return value depends on the + * value of \p check_object_valid: + * + * If \p check_object_valid is set to \c FALSE, H5LTpath_valid() + * will check all links in \p path to verify that they exist. + * If all the links in \p path exist, the function will + * return \c TRUE; otherwise the function will return \c FALSE. + * + * If \p check_object_valid is set to \c TRUE, + * H5LTpath_valid() will first check the links in \p path, + * as described above. If all the links exist, + * \p check_object_valid will then determine whether the final + * component of \p path resolves to an actual HDF5 object. + * H5LTpath_valid() will return \c TRUE if all the links in + * \p path exist and the final component resolves to an + * actual object; otherwise, it will return \c FALSE. + * + * \p path can be any one of the following: + * + * - An absolute path, which starts with a slash (\c /) + * indicating the file’s root group, followed by the members + * - A relative path with respect to \p loc_id + * - A dot (\c .), if \p loc_id is the object identifier for + * the object itself. + * + * If \p path is an absolute path, then \p loc_id can be an + * identifier for any object in the file as it is used only to + * identify the file. If \p path is a relative path, then + * \p loc_id must be a file or a group identifier. + * + * \note + * Note on Behavior Change: + * The behavior of H5LTpath_valid() was changed in the 1.10.0 release + * in the case where the root group, “/â€, is the value of path. + * This change is described below: + * - Let \p loc_id denote a valid HDF5 file identifier, and let + * \p check_object_valid be set to true or false. + * A call to H5LTpath_valid() with arguments \p loc_id, “/â€, + * and \p check_object_valid returns a positive value; + * in other words, H5LTpath_valid(loc_id, "/", check_object_valid) + * returns a positive value. + * In HDF5 version 1.8.16, this function returns 0. + * - Let ‘root’ denote a valid HDF5 group identifier that refers + * to the root group of an HDF5 file, and let \p check_object_valid + * be set to true or false. + * A call to H5LTpath_valid() with arguments ‘root’, “/â€, and + * \p check_object_valid returns a positive value; + * in other words, H5LTpath_valid(root, "/", check_object_valid) + * returns a positive value. + * In HDF5 version 1.8.16, this function returns 0. + * + * \version 1.10.0 Function behavior changed in this release. + * See the “Note on Behavior Change†section above. + * + */ H5_HLDLL htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid); /*------------------------------------------------------------------------- @@ -228,6 +1560,80 @@ H5_HLDLL htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_obj *------------------------------------------------------------------------- */ +/** + *------------------------------------------------------------------------- + * \ingroup H5LT + * + * \brief Opens an HDF5 file image in memory. + * + * \param[in] buf_ptr A pointer to the supplied initial image + * \param[in] buf_size Size of the supplied buffer + * \param[in] flags Flags specifying whether to open the image + * read-only or read/write, whether HDF5 is to + * take control of the buffer, and instruction + * regarding releasing the buffer. + * + * \return Returns a file identifier if successful; + * otherwise returns a negative value. + * \warning \Bold{Failure Modes:} + * \warning H5LTopen_file_image() will fail if either \p buf_ptr is NULL + * or \p buf_size equals 0 (zero). + * + * + * \details H5LTopen_file_image() opens the HDF5 file image that is + * located in system memory at the address indicated by + * \p buf_ptr of size \p buf_size. + * H5LTopen_file_image() opens a file image with the + * Core driver, #H5FD_CORE. + * + * A value of NULL for \p buf_ptr is invalid and will + * cause the function to fail. + * + * A value of 0 for \p buf_size is invalid and will cause + * the function to fail. + * + * The flags passed in \p flags specify whether to open the image + * read-only or read/write, whether HDF5 is to take control of the + * buffer, and instruction regarding releasing the buffer. + * Valid values are: + * - #H5LT_FILE_IMAGE_OPEN_RW + * - Specifies opening the file image in read/write mode. + * - Default without this flag: File image will be opened read-only. + * + * - #H5LT_FILE_IMAGE_DONT_COPY + * - Specifies to not copy the provided file image buffer; + * the buffer will be used directly. HDF5 will release the + * file image when finished. + * - Default without this flag: Copy the file image buffer and + * open the copied file image. + * + * - #H5LT_FILE_IMAGE_DONT_RELEASE + * - Specifies that HDF5 is not to release the buffer when + * the file opened with H5LTopen_file_image() is closed; + * releasing the buffer will be left to the application. + * - Default without this flag: HDF5 will automatically + * release the file image buffer after the file image is + * closed. This flag is valid only when used with + * #H5LT_FILE_IMAGE_DONT_COPY. + * + * \note **Motivation:** + * \note H5LTopen_file_image() and other elements of HDF5 + * are used to load an image of an HDF5 file into system memory + * and open that image as a regular HDF5 file. An application can + * then use the file without the overhead of disk I/O. + * + * \note **Recommended Reading:** + * \note This function is part of the file image operations feature set. + * It is highly recommended to study the guide + * + * HDF5 File Image Operations before using this feature set.\n + * See the “See Also†section below for links to other elements of + * HDF5 file image operations. + * + * \todo There is no "See Also" section??? + * + * \since 1.8.9 + */ H5_HLDLL hid_t H5LTopen_file_image(void *buf_ptr, size_t buf_size, unsigned flags); #ifdef __cplusplus diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index f5fb99f84b8..4d17dc01ade 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -29,7 +28,7 @@ static H5I_type_t H5PT_ptable_id_type = H5I_UNINIT; #define H5PT_HASH_TABLE_SIZE 64 /* Packet Table private functions */ -static herr_t H5PT_free_id(void *id, void **_ctx); +static herr_t H5PT_free_id(void *id); static herr_t H5PT_close(htbl_t *table); static herr_t H5PT_create_index(htbl_t *table_id); static herr_t H5PT_set_index(htbl_t *table_id, hsize_t pt_index); @@ -87,8 +86,7 @@ H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_si /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) - if ((H5PT_ptable_id_type = - H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + if ((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, H5PT_free_id)) < 0) goto error; /* Get memory for the table identifier */ @@ -208,8 +206,7 @@ H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) - if ((H5PT_ptable_id_type = - H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + if ((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, H5PT_free_id)) < 0) goto error; /* Get memory for the table identifier */ @@ -323,8 +320,7 @@ H5PTopen(hid_t loc_id, const char *dset_name) /* Register the packet table ID type if this is the first table created */ if (H5PT_ptable_id_type < 0) - if ((H5PT_ptable_id_type = - H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, (H5I_free_t)H5PT_free_id)) < 0) + if ((H5PT_ptable_id_type = H5Iregister_type((size_t)H5PT_HASH_TABLE_SIZE, 0, H5PT_free_id)) < 0) goto error; table = (htbl_t *)HDmalloc(sizeof(htbl_t)); @@ -402,7 +398,7 @@ H5PTopen(hid_t loc_id, const char *dset_name) *------------------------------------------------------------------------- */ static herr_t -H5PT_free_id(void *id, void H5_ATTR_UNUSED **_ctx) +H5PT_free_id(void *id) { HDfree(id); return SUCCEED; @@ -858,7 +854,7 @@ herr_t H5PTis_varlen(hid_t table_id) { H5T_class_t type; - htbl_t * table; + htbl_t *table; /* find the table struct from its ID */ if ((table = (htbl_t *)H5Iobject_verify(table_id, H5PT_ptable_id_type)) == NULL) diff --git a/hl/src/H5PTprivate.h b/hl/src/H5PTprivate.h index 9ca7676852a..1e88cec182a 100644 --- a/hl/src/H5PTprivate.h +++ b/hl/src/H5PTprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5PTpublic.h b/hl/src/H5PTpublic.h index d74baa513ed..3016e77ba60 100644 --- a/hl/src/H5PTpublic.h +++ b/hl/src/H5PTpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -18,19 +17,204 @@ extern "C" { #endif +/** \page H5PT_UG The HDF5 High Level Packet Table + * @todo Under Construction + */ + +/**\defgroup H5PT HDF5 Packet Table APIs (H5PT) + * + * Creating and manipulating HDF5 datasets to support append- + * and read-only operations on table data (H5PT) + * + * The HDF5 Packet Table API is designed to allow records to be + * appended to and read from a table. Packet Table datasets are + * chunked, allowing them to grow as needed. + * + * The Packet Table API, with the H5PT prefix, is not to be confused with + * the H5TB Table API (H5TB prefix). The H5TB APIs are stateless + * (H5TB Tables do not need to be opened or closed) but H5PT Packet Tables + * require less performance overhead. Also, H5TB Tables support insertions + * and deletions, while H5PT Packet Tables support only append operations. + * H5TB functions should not be called on tables created with the + * H5PT API, or vice versa. + * + * Packet Tables are datasets in an HDF5 file, so while their contents + * should not be changed outside of the H5PT API calls, the datatypes of + * Packet Tables can be queried using \ref H5Dget_type. + * Packet Tables can also be given attributes using the normal HDF5 APIs. + * + * \note \Bold{Programming hints:} + * \note The following line includes the HDF5 Packet Table package, H5PT, + * in C applications: + * \code #include "hdf5_hl.h" \endcode + * Without this include, an application will not have access to + * these functions. + * + * - \ref H5PTappend + * \n Appends packets to the end of a packet table. + * - \ref H5PTclose + * \n Closes an open packet table. + * - \ref H5PTcreate + * \n Creates a packet table to store fixed-length + * or variable-length packets. + * - \ref H5PTcreate_fl + * \n Creates a packet table to store fixed-length packets. + * - \ref H5PTcreate_index + * \n Resets a packet table's index to the first packet. + * - \ref H5PTfree_vlen_buff + * \n Releases memory allocated in the process of + * reading variable-length packets. + * - \ref H5PTget_dataset + * \n Returns the backend dataset of this packet table. + * - \ref H5PTget_index + * \n Gets the current record index for a packet table + * - \ref H5PTget_next + * \n Reads packets from a packet table starting at the + * current index. + * - \ref H5PTget_num_packets + * \n Returns the number of packets in a packet table. + * - \ref H5PTget_type + * \n Returns the backend datatype of this packet table. + * - \ref H5PTis_valid + * \n Determines whether an identifier points to a packet table. + * - \ref H5PTis_varlen + * \n Determines whether a packet table contains variable-length + * or fixed-length packets. + * - \ref H5PTopen + * \n Opens an existing packet table. + * - \ref H5PTread_packets + * \n Reads a number of packets from a packet table. + * - \ref H5PTset_index + * \n Sets a packet table's index. + * + */ + /*------------------------------------------------------------------------- * Create/Open/Close functions *------------------------------------------------------------------------- */ /* NOTE: H5PTcreate is replacing H5PTcreate_fl for better name due to the removal of H5PTcreate_vl. H5PTcreate_fl may be retired in 1.8.19. */ + +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Creates a packet table to store fixed-length or + * variable-length packets. + * + * \fg_loc_id + * \param[in] dset_name The name of the packet table to create + * \param[in] dtype_id The datatype of the packet + * \param[in] chunk_size The size in number of table entries per chunk + * \param[in] plist_id Identifier of the property list. Can be used to + * specify the compression of the packet table. + * + * \return Returns an identifier for the new packet table or + * #H5I_INVALID_HID on error. + * + * \details The H5PTcreate() creates and opens a packet table named + * \p dset_name attached to the object specified by the + * identifier \p loc_id. The created packet table should be closed + * with H5PTclose(), eventually. + * + * The datatype, \p dtype_id, may specify any datatype, including + * variable-length data. If \p dtype_id specifies a compound + * datatype, one or more fields in that compound type may be + * variable-length. + * + * \p chunk_size is the size in number of table entries per chunk. + * Packet table datasets use HDF5 chunked storage + * to allow them to grow. This value allows the user + * to set the size of a chunk. The chunk size affects + * performance. + * + * \since 1.10.0 and 1.8.17 + * + */ H5_HLDLL hid_t H5PTcreate(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, hid_t plist_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Opens an existing packet table. + * + * \fg_loc_id + * \param[in] dset_name The name of the packet table to open + * + * \return Returns an identifier for the packet table or + * #H5I_INVALID_HID on error. + * + * \details H5PTopen() opens an existing packet table in the file or group + * specified by \p loc_id. \p dset_name is the name of the packet + * table and is used to identify it in the file. This function is + * used to open both fixed-length packet tables and variable-length + * packet tables. The packet table should later be closed with + * H5PTclose(). + * + */ H5_HLDLL hid_t H5PTopen(hid_t loc_id, const char *dset_name); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Closes an open packet table. + * + * \param[in] table_id Identifier of packet table to be closed + * + * \return \herr_t + * + * \details The H5PTclose() ends access to a packet table specified + * by \p table_id. + * + */ H5_HLDLL herr_t H5PTclose(hid_t table_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Creates a packet table to store fixed-length packets + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to create + * \param[in] dtype_id The datatype of a packet. + * \param[in] chunk_size The size in number of table entries per + * chunk. + * \param[in] compression The compression level; + * a value of 0 through 9. + * + * \return Returns an identifier for the packet table or + * #H5I_INVALID_HID on error. + * + * \deprecated This function was deprecated in favor of the function + * H5PTcreate(). + * + * \details The H5PTcreate_fl() creates and opens a packet table + * named \p dset_name attached to the object specified by + * the identifier \p loc_id. It should be closed + * with H5PTclose(). + * + * The datatype, \p dtype_id, may specify any datatype, + * including variable-length data. If \p dtype_id specifies a + * compound datatype, one or more fields in that compound type + * may be variable-length. + * + * \p chunk_size is the size in number of table entries per chunk. + * Packet table datasets use HDF5 chunked storage + * to allow them to grow. This value allows the user + * to set the size of a chunk. The chunk size affects + * performance. + * + * \p compression is the compression level, a value of 0 through 9. + * Level 0 is faster but offers the least compression; + * level 9 is slower but offers maximum compression. + * A setting of -1 indicates that no compression is desired. + * + */ /* This function may be removed from the packet table in release 1.8.19. */ H5_HLDLL hid_t H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id, hsize_t chunk_size, int compression); @@ -39,24 +223,148 @@ H5_HLDLL hid_t H5PTcreate_fl(hid_t loc_id, const char *dset_name, hid_t dtype_id * Write functions *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Appends packets to the end of a packet table. + * + * \param[in] table_id Identifier of packet table to which + * packets should be appended + * \param[in] nrecords Number of packets to be appended + * \param[in] data Buffer holding data to write + * + * \return \herr_t + * + * \details The H5PTappend() writes \p nrecords packets to the end of a + * packet table specified by \p table_id. \p data is a buffer + * containing the data to be written. For a packet table holding + * fixed-length packets, this data should be in the packet + * table's datatype. For a variable-length packet table, + * the data should be in the form of #hvl_t structs. + * + */ H5_HLDLL herr_t H5PTappend(hid_t table_id, size_t nrecords, const void *data); /*------------------------------------------------------------------------- * Read functions *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Reads packets from a packet table starting at the current index. + * + * \param[in] table_id Identifier of packet table to read from + * \param[in] nrecords Number of packets to be read + * \param[out] data Buffer into which to read data + * + * \return \herr_t + * + * \details The H5PTget_next() reads \p nrecords packets starting with + * the "current index" from a packet table specified by \p table_id. + * The packet table's index is set and reset with H5PTset_index() + * and H5PTcreate_index(). \p data is a buffer into which the + * data should be read. + * + * For a packet table holding variable-length records, the data + * returned in the buffer will be in form of a #hvl_t struct + * containing the length of the data and a pointer to it in memory. + * The memory used by this data must be freed using H5PTfree_vlen_buff(). + * + */ H5_HLDLL herr_t H5PTget_next(hid_t table_id, size_t nrecords, void *data); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Reads a number of packets from a packet table. + * + * \param[in] table_id Identifier of packet table to read from + * \param[in] start Packet to start reading from + * \param[in] nrecords Number of packets to be read + * \param[out] data Buffer into which to read data. + * + * \return \herr_t + * + * \details The H5PTread_packets() reads \p nrecords packets starting at + * packet number \p start from a packet table specified by + * \p table_id. \p data is a buffer into which the data should + * be read. + * + * For a packet table holding variable-length records, the data + * returned in the buffer will be in form of #hvl_t structs, + * each containing the length of the data and a pointer to it in + * memory. The memory used by this data must be freed using + * H5PTfree_vlen_buff(). + * + */ H5_HLDLL herr_t H5PTread_packets(hid_t table_id, hsize_t start, size_t nrecords, void *data); /*------------------------------------------------------------------------- * Inquiry functions *------------------------------------------------------------------------- */ + +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Returns the number of packets in a packet table. + * + * \param[in] table_id Identifier of packet table to query + * \param[out] nrecords Number of packets in packet table + * + * \return \herr_t + * + * \details The H5PTget_num_packets() returns by reference the number + * of packets in a packet table specified by \p table_id. + * + */ H5_HLDLL herr_t H5PTget_num_packets(hid_t table_id, hsize_t *nrecords); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Determines whether an identifier points to a packet table. + * + * \param[in] table_id Identifier to query + * + * \return Returns a non-negative value if \p table_id is + * a valid packet table, otherwise returns a negative value. + * + * \details The H5PTis_valid() returns a non-negative value if + * \p table_id corresponds to an open packet table, + * and returns a negative value otherwise. + * + */ H5_HLDLL herr_t H5PTis_valid(hid_t table_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Determines whether a packet table contains + * variable-length or fixed-length packets. + * + * \param[in] table_id Packet table to query + * + * \return Returns 1 for a variable-length packet table, + * 0 for fixed-length, or a negative value on error. + * + * \details The H5PTis_varlen() returns 1 (TRUE) if \p table_id is + * a packet table containing variable-length records. + * It returns 0 (FALSE) if \p table_id is a packet table + * containing fixed-length records. If \p table_id is not a + * packet table, a negative value is returned. + * + * \version 1.10.0 and 1.8.17 Function re-introduced. + * Function had been removed in 1.8.3. + * + */ H5_HLDLL herr_t H5PTis_varlen(hid_t table_id); /*------------------------------------------------------------------------- @@ -66,8 +374,42 @@ H5_HLDLL herr_t H5PTis_varlen(hid_t table_id); *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Returns the backend dataset of this packet table. + * + * \param[in] table_id Identifier of the packet table + * + * \return Returns a dataset identifier or H5I_INVALID_HID on error. + * + * \details The H5PTget_dataset() returns the identifier of the dataset + * storing the packet table \p table_id. This dataset identifier + * will be closed by H5PTclose(). + * + * \since 1.10.0 and 1.8.17 + * + */ H5_HLDLL hid_t H5PTget_dataset(hid_t table_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Returns the backend datatype of this packet table. + * + * \param[in] table_id Identifier of the packet table + * + * \return Returns a datatype identifier or H5I_INVALID_HID on error. + * + * \details The H5PTget_type() returns the identifier of the datatype + * used by the packet table \p table_id. This datatype + * identifier will be closed by H5PTclose(). + * + * \since 1.10.0 and 1.8.17 + * + */ H5_HLDLL hid_t H5PTget_type(hid_t table_id); /*------------------------------------------------------------------------- @@ -77,10 +419,63 @@ H5_HLDLL hid_t H5PTget_type(hid_t table_id); *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Resets a packet table's index to the first packet. + * + * \param[in] table_id Identifier of packet table whose index + * should be initialized. + * + * \return \herr_t + * + * \details Each packet table keeps an index of the "current" packet + * so that \c get_next can iterate through the packets in order. + * H5PTcreate_index() initializes a packet table's index, and + * should be called before using \c get_next. The index must be + * initialized every time a packet table is created or opened; + * this information is lost when the packet table is closed. + * + */ H5_HLDLL herr_t H5PTcreate_index(hid_t table_id); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Sets a packet table's index. + * + * \param[in] table_id Identifier of packet table whose index is to be set + * \param[in] pt_index The packet to which the index should point + * + * \return \herr_t + * + * \details Each packet table keeps an index of the "current" packet + * so that \c get_next can iterate through the packets in order. + * H5PTset_index() sets this index to point to a user-specified + * packet (the packets are zero-indexed). + * + */ H5_HLDLL herr_t H5PTset_index(hid_t table_id, hsize_t pt_index); +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Gets the current record index for a packet table. + * + * \param[in] table_id Table identifier + * \param[out] pt_index Current record index + * + * \return \herr_t + * + * \details The H5PTget_index() returns the current record index + * \p pt_index for the table identified by \p table_id. + * + * \since 1.8.0 + * + */ H5_HLDLL herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index); /*------------------------------------------------------------------------- @@ -90,6 +485,29 @@ H5_HLDLL herr_t H5PTget_index(hid_t table_id, hsize_t *pt_index); *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5PT + * + * \brief Releases memory allocated in the process of reading + * variable-length packets. + * + * \param[in] table_id Packet table whose memory should be freed. + * \param[in] bufflen Size of \p buff + * \param[in] buff Buffer that was used to read in variable-length + * packets + * + * \return \herr_t + * + * \details When variable-length packets are read, memory is automatically + * allocated to hold them, and must be freed. H5PTfree_vlen_buff() + * frees this memory, and should be called whenever packets are + * read from a variable-length packet table. + * + * \version 1.10.0 and 1.8.17 Function re-introduced. + * Function had been removed in 1.8.3. + * + */ H5_HLDLL herr_t H5PTfree_vlen_buff(hid_t table_id, size_t bufflen, void *buff); #ifdef __cplusplus diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index efa61a32eb1..8c37205bec1 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -66,7 +65,7 @@ H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsi hsize_t dims_chunk[1]; hsize_t maxdims[1] = {H5S_UNLIMITED}; char attr_name[255]; - char * member_name = NULL; + char *member_name = NULL; unsigned char *tmp_buf = NULL; hsize_t i; herr_t ret_val = -1; @@ -437,7 +436,7 @@ H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const char *field_nam hssize_t i, j; hsize_t count[1]; hsize_t offset[1]; - char * member_name = NULL; + char *member_name = NULL; size_t size_native; herr_t ret_val = -1; @@ -595,7 +594,7 @@ H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, con hsize_t offset[1]; hsize_t i; size_t size_native; - char * member_name = NULL; + char *member_name = NULL; herr_t ret_val = -1; /* check the arguments */ @@ -899,7 +898,7 @@ H5TBread_fields_name(hid_t loc_id, const char *dset_name, const char *field_name hsize_t offset[1]; hsize_t mem_size[1]; size_t size_native; - char * member_name = NULL; + char *member_name = NULL; hssize_t i, j; herr_t ret_val = -1; @@ -1056,7 +1055,7 @@ H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, cons hsize_t mem_size[1]; hsize_t i; size_t size_native; - char * member_name = NULL; + char *member_name = NULL; herr_t ret_val = -1; /* check the arguments */ @@ -1212,8 +1211,8 @@ H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nr hsize_t mem_size[1]; hsize_t dims[1]; size_t src_size; - size_t * src_offset = NULL; - size_t * src_sizes = NULL; + size_t *src_offset = NULL; + size_t *src_sizes = NULL; unsigned char *tmp_buf = NULL; herr_t ret_val = -1; @@ -1524,8 +1523,8 @@ H5TBadd_records_from(hid_t loc_id, const char *dset_name1, hsize_t start1, hsize hsize_t ntotal_records; size_t type_size1; size_t src_size; - size_t * src_offset = NULL; - size_t * src_sizes = NULL; + size_t *src_offset = NULL; + size_t *src_sizes = NULL; unsigned char *tmp_buf = NULL; herr_t ret_val = -1; @@ -1672,8 +1671,8 @@ H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2, const c size_t type_size; size_t member_offset; size_t src_size; - size_t * src_offset = NULL; - size_t * src_sizes = NULL; + size_t *src_offset = NULL; + size_t *src_sizes = NULL; char attr_name[255]; unsigned char *tmp_buf = NULL; unsigned char *tmp_fill_buf = NULL; @@ -2033,7 +2032,7 @@ H5TBinsert_field(hid_t loc_id, const char *dset_name, const char *field_name, hi hsize_t i; char table_title[255]; char attr_name[255]; - char * member_name = NULL; + char *member_name = NULL; unsigned char *tmp_buf = NULL; unsigned char *tmp_fill_buf = NULL; hbool_t inserted; @@ -2446,7 +2445,7 @@ H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name) hsize_t i; char attr_name[255]; char table_title[255]; - char * member_name = NULL; + char *member_name = NULL; unsigned char *tmp_buf = NULL; unsigned char *tmp_fill_buf = NULL; htri_t has_fill = FALSE; @@ -3207,7 +3206,7 @@ H5TB_attach_attributes(const char *table_title, hid_t loc_id, const char *dset_n hid_t tid) { char attr_name[255]; - char * member_name = NULL; + char *member_name = NULL; hsize_t i; herr_t ret_val = -1; @@ -3272,7 +3271,7 @@ H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size, const si hid_t nmtype_id = H5I_INVALID_HID; size_t size_native; hsize_t nfields = 0; - char ** fnames = NULL; + char **fnames = NULL; unsigned i; hid_t ret_val = -1; diff --git a/hl/src/H5TBprivate.h b/hl/src/H5TBprivate.h index 95b58e6e8ee..ce591689aea 100644 --- a/hl/src/H5TBprivate.h +++ b/hl/src/H5TBprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/hl/src/H5TBpublic.h b/hl/src/H5TBpublic.h index 1750490791f..42585cf012f 100644 --- a/hl/src/H5TBpublic.h +++ b/hl/src/H5TBpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -18,6 +17,74 @@ extern "C" { #endif +/** \page H5TB_UG The HDF5 High Level Table + * @todo Under Construction + */ + +/**\defgroup H5TB HDF5 Table APIs (H5TB) + * + * Creating and manipulating HDF5 datasets intended to be + * interpreted as tables (H5TB) + * + * The HDF5 Table API defines a standard storage for HDF5 datasets + * that are intended to be interpreted as tables. A table is defined + * as a collection of records whose values are stored in fixed-length + * fields. All records have the same structure, and all values in + * each field have the same data type. + * + * \note \Bold{Programming hints:} + * \note To use any of these functions or subroutines, + * you must first include the relevant include file (C) or + * module (Fortran) in your application. + * \note The following line includes the HDF5 Table package, H5TB, + * in C applications: + * \code #include "hdf5_hl.h" \endcode + * \note To include the H5TB module in Fortran applications specify: + * \code use h5tb \endcode + * Fortran applications must also include \ref H5open before + * any HDF5 calls to initialize global variables and \ref H5close + * after all HDF5 calls to close the Fortran interface. + * + * + * + *
+ * + * - Creation + * - \ref H5TBmake_table + * - Storage + * - \ref H5TBappend_records (No Fortran) + * - \ref H5TBwrite_records (No Fortran) + * - \ref H5TBwrite_fields_name + * - \ref H5TBwrite_fields_index + * + * - Modification + * - \ref H5TBdelete_record (No Fortran) + * - \ref H5TBinsert_record (No Fortran) + * - \ref H5TBadd_records_from (No Fortran) + * - \ref H5TBcombine_tables (No Fortran) + * - \ref H5TBinsert_field + * - \ref H5TBdelete_field + * + * + * + * - Retrieval + * - \ref H5TBread_table + * - \ref H5TBread_records (No Fortran) + * - \ref H5TBread_fields_name + * - \ref H5TBread_fields_index + * + * - Query + * - \ref H5TBget_table_info + * - \ref H5TBget_field_info + * + * - Query Table Attributes + * - \ref H5TBAget_fill + * - \ref H5TBAget_title + * + *
+ * + */ + /*------------------------------------------------------------------------- * * Create functions @@ -25,6 +92,38 @@ extern "C" { *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * \brief Creates and writes a table + * + * \param[in] table_title The title of the table + * \fg_loc_id + * \param[in] dset_name The name of the dataset to create + * \param[in] nfields The number of fields + * \param[in] nrecords The number of records + * \param[in] type_size The size in bytes of the structure + * associated with the table; + * This value is obtained with \c sizeof(). + * \param[in] field_names An array containing the names of + * the fields + * \param[in] field_offset An array containing the offsets of + * the fields + * \param[in] field_types An array containing the type of + * the fields + * \param[in] chunk_size The chunk size + * \param[in] fill_data Fill values data + * \param[in] compress Flag that turns compression on or off + * \param[in] buf Buffer with data to be written to the table + * + * \return \herr_t + * + * \details H5TBmake_table() creates and writes a dataset named + * \p dset_name attached to the object specified by the + * identifier loc_id. + * + */ H5_HLDLL herr_t H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsize_t nfields, hsize_t nrecords, size_t type_size, const char *field_names[], const size_t *field_offset, const hid_t *field_types, hsize_t chunk_size, @@ -37,17 +136,128 @@ H5_HLDLL herr_t H5TBmake_table(const char *table_title, hid_t loc_id, const char *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * \brief Adds records to the end of the table + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to overwrite + * \param[in] nrecords The number of records to append + * \param[in] type_size The size of the structure type, + * as calculated by \c sizeof(). + * \param[in] field_offset An array containing the offsets of + * the fields. These offsets can be + * calculated with the #HOFFSET macro + * \param[in] dst_sizes An array containing the sizes of + * the fields + * \param[in] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBappend_records() adds records to the end of the table + * named \p dset_name attached to the object specified by the + * identifier \p loc_id. The dataset is extended to hold the + * new records. + * + */ H5_HLDLL herr_t H5TBappend_records(hid_t loc_id, const char *dset_name, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *dst_sizes, const void *buf); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * \brief Overwrites records + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to overwrite + * \param[in] start The zero index record to start writing + * \param[in] nrecords The number of records to write + * \param[in] type_size The size of the structure type, as + * calculated by \c sizeof(). + * \param[in] field_offset An array containing the offsets of + * the fields. These offsets can be + * calculated with the #HOFFSET macro + * \param[in] dst_sizes An array containing the sizes of + * the fields + * \param[in] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBwrite_records() overwrites records starting at the zero + * index position start of the table named \p dset_name attached + * to the object specified by the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBwrite_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *dst_sizes, const void *buf); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * \brief Overwrites fields + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to overwrite + * \param[in] field_names The names of the fields to write + * \param[in] start The zero index record to start writing + * \param[in] nrecords The number of records to write + * \param[in] type_size The size of the structure type, as + * calculated by \c sizeof(). + * \param[in] field_offset An array containing the offsets of + * the fields. These offsets can be + * calculated with the #HOFFSET macro + * \param[in] dst_sizes An array containing the sizes of + * the fields + * \param[in] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBwrite_fields_name() overwrites one or several fields + * specified by \p field_names with data in \p buf from a + * dataset named \p dset_name attached to the object specified + * by the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *dst_sizes, const void *buf); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * \brief Overwrites fields + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to overwrite + * \param[in] nfields The number of fields to overwrite. + * This parameter is also the size of the + * \p field_index array. + * \param[in] field_index The indexes of the fields to write + * \param[in] start The zero based index record to start writing + * \param[in] nrecords The number of records to write + * \param[in] type_size The size of the structure type, as + * calculated by \c sizeof(). + * \param[in] field_offset An array containing the offsets of + * the fields. These offsets can be + * calculated with the #HOFFSET macro + * \param[in] dst_sizes An array containing the sizes of + * the fields + * \param[in] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBwrite_fields_index() overwrites one or several fields + * specified by \p field_index with a buffer \p buf from a + * dataset named \p dset_name attached to the object + * specified by the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, const int *field_index, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *dst_sizes, @@ -60,18 +270,128 @@ H5_HLDLL herr_t H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsiz *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * \brief Reads a table + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[in] dst_size The size of the structure type, + * as calculated by \c sizeof() + * \param[in] dst_offset An array containing the offsets of + * the fields. These offsets can be + * calculated with the #HOFFSET macro + * \param[in] dst_sizes An array containing the sizes of + * the fields. These sizes can be + * calculated with the sizeof() macro. + * \param[in] dst_buf Buffer with data + * + * \return \herr_t + * + * \details H5TBread_table() reads a table named + * \p dset_name attached to the object specified by + * the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBread_table(hid_t loc_id, const char *dset_name, size_t dst_size, const size_t *dst_offset, const size_t *dst_sizes, void *dst_buf); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * \brief Reads one or several fields. The fields are identified by name. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[in] field_names An array containing the names of the + * fields to read + * \param[in] start The start record to read from + * \param[in] nrecords The number of records to read + * \param[in] type_size The size in bytes of the structure associated + * with the table + * (This value is obtained with \c sizeof().) + * \param[in] field_offset An array containing the offsets of the fields + * \param[in] dst_sizes An array containing the size in bytes of + * the fields + * \param[out] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBread_fields_name() reads the fields identified + * by \p field_names from a dataset named \p dset_name + * attached to the object specified by the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBread_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *dst_sizes, void *buf); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Reads one or several fields. The fields are identified by index. + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[in] nfields The number of fields to read + * (This parameter is also the size of the + * \p field_index array.) + * fields to read + * \param[in] field_index The indexes of the fields to read + * \param[in] start The start record to read from + * \param[in] nrecords The number of records to read + * \param[in] type_size The size in bytes of the structure associated + * with the table + * (This value is obtained with \c sizeof()) + * \param[in] field_offset An array containing the offsets of the fields + * \param[in] dst_sizes An array containing the size in bytes of + * the fields + * \param[out] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBread_fields_index() reads the fields identified + * by \p field_index from a dataset named \p dset_name attached + * to the object specified by the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, const int *field_index, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *dst_sizes, void *buf); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Reads records + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[in] start The start record to read from + * \param[in] nrecords The number of records to read + * \param[in] type_size The size of the structure type, + * as calculated by \c sizeof() + * \param[in] dst_offset An array containing the offsets of the + * fields. These offsets can be calculated + * with the #HOFFSET macro + * \param[in] dst_sizes An array containing the size in bytes of + * the fields + * \param[out] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBread_records() reads some records identified from a dataset + * named \p dset_name attached to the object specified by the + * identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBread_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *dst_offset, const size_t *dst_sizes, void *buf); @@ -83,8 +403,52 @@ H5_HLDLL herr_t H5TBread_records(hid_t loc_id, const char *dset_name, hsize_t st *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Gets the table dimensions + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] nfields The number of fields + * \param[out] nrecords The number of records + * + * \return \herr_t + * + * \details H5TBget_table_info() retrieves the table dimensions from a + * dataset named \p dset_name attached to the object specified + * by the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_t *nrecords); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Gets information about a table + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset to read + * \param[out] field_names An array containing the names of the fields + * \param[out] field_sizes An array containing the size of the fields + * \param[out] field_offsets An array containing the offsets of the fields + * \param[out] type_size The size of the HDF5 datatype associated + * with the table. (More specifically, + * the size in bytes of the HDF5 compound + * datatype used to define a row, or record, + * in the table) + * + * \return \herr_t + * + * \details H5TBget_field_info() gets information about a dataset + * named \p dset_name attached to the object specified + * by the identifier \p loc_id. + * + */ H5_HLDLL herr_t H5TBget_field_info(hid_t loc_id, const char *dset_name, char *field_names[], size_t *field_sizes, size_t *field_offsets, size_t *type_size); @@ -95,21 +459,162 @@ H5_HLDLL herr_t H5TBget_field_info(hid_t loc_id, const char *dset_name, char *fi *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Delete records + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset + * \param[in] start The start record to delete from + * \param[in] nrecords The number of records to delete + * + * \return \herr_t + * + * \details H5TBdelete_record() deletes nrecords number of records starting + * from \p start from the middle of the table \p dset_name + * ("pulling up" all the records after it). + * + */ H5_HLDLL herr_t H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Insert records + * + * \fg_loc_id + * \param[in] dset_name The name of the dataset + * \param[in] start The position to insert + * \param[in] nrecords The number of records to insert + * \param[in] dst_size The size in bytes of the structure + * associated with the table + * \param[in] dst_offset An array containing the offsets of the + * fields + * \param[in] dst_sizes An array containing the size in bytes of + * the fields + * \param[in] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBinsert_record() inserts records into the middle of the table + * ("pushing down" all the records after it) + * + */ H5_HLDLL herr_t H5TBinsert_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t dst_size, const size_t *dst_offset, const size_t *dst_sizes, void *buf); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Add records from first table to second table + * + * \fg_loc_id + * \param[in] dset_name1 The name of the dataset to read the records + * \param[in] start1 The position to read the records from the + * first table + * \param[in] nrecords The number of records to read from the first + * table + * \param[in] dset_name2 The name of the dataset to write the records + * \param[in] start2 The position to write the records on the + * second table + * + * \return \herr_t + * + * \details H5TBadd_records_from() adds records from a dataset named + * \p dset_name1 to a dataset named \p dset_name2. Both tables + * are attached to the object specified by the identifier loc_id. + * + */ H5_HLDLL herr_t H5TBadd_records_from(hid_t loc_id, const char *dset_name1, hsize_t start1, hsize_t nrecords, const char *dset_name2, hsize_t start2); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Combines records from two tables into a third + * + * \param[in] loc_id1 Identifier of the file or group in which + * the first table is located + * \param[in] dset_name1 The name of the first table to combine + * \param[in] loc_id2 Identifier of the file or group in which + * the second table is located + * \param[in] dset_name2 The name of the second table to combine + * \param[in] dset_name3 The name of the new table + * + * \return \herr_t + * + * \details H5TBcombine_tables() combines records from two datasets named + * \p dset_name1 and \p dset_name2, to a new table named + * \p dset_name3. These tables can be located on different files, + * identified by \p loc_id1 and \p loc_id2 (identifiers obtained + * with H5Fcreate()). They can also be located on the same file. + * In this case one uses the same identifier for both parameters + * \p loc_id1 and \p loc_id2. If two files are used, the third + * table is written in the first file. + * + */ H5_HLDLL herr_t H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2, const char *dset_name2, const char *dset_name3); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Insert a new field into a table + * + * \fg_loc_id + * \param[in] dset_name The name of the table + * \param[in] field_name The name of the field to insert + * \param[in] field_type The data type of the field + * \param[in] position The zero based index position where to + * insert the field + * \param[in] fill_data Fill value data for the field. This parameter + * can be NULL + * \param[in] buf Buffer with data + * + * \return \herr_t + * + * \details H5TBinsert_field() inserts a new field named \p field_name into + * the table \p dset_name. Note: this function requires the table + * to be re-created and rewritten in its entirety, and this can result + * in some unused space in the file, and can also take a great deal of + * time if the table is large. + * + */ H5_HLDLL herr_t H5TBinsert_field(hid_t loc_id, const char *dset_name, const char *field_name, hid_t field_type, hsize_t position, const void *fill_data, const void *buf); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Deletes a field from a table + * + * \fg_loc_id + * \param[in] dset_name The name of the table + * \param[in] field_name The name of the field to delete + * + * \return \herr_t + * + * \details H5TBdelete_field() deletes a field named \p field_name from the + * table \p dset_name. Note: this function requires the table to be + * re-created and rewritten in its entirety, and this can result in + * some unused space in the file, and can also take a great deal of + * time if the table is large. + * + */ H5_HLDLL herr_t H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name); /*------------------------------------------------------------------------- @@ -119,8 +624,49 @@ H5_HLDLL herr_t H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *------------------------------------------------------------------------- */ +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Reads a table's title + * + * \fg_loc_id + * \param[out] table_title Buffer for title name + * + * \return \herr_t + * + * \details H5TBget_title() returns the title of the table identified + * by \p loc_id in a buffer \p table_title. + * + */ H5_HLDLL herr_t H5TBAget_title(hid_t loc_id, char *table_title); +/** + * -------------------------------------------------------------------------- + * \ingroup H5TB + * + * + * \brief Reads the table attribute fill values + * + * \fg_loc_id + * \param[in] dset_name Name of table + * \param[in] dset_id Table identifier + * \param[out] dst_buf Buffer of fill values for table fields + * + * \return + * \return A return value of 1 indicates that a fill value is present. + * \return A return value of 0 indicates a fill value is not present. + * \return A return value <0 indicates an error. + * + * \details H5TBget_fill() reads the table attribute fill values into + * the buffer \p dst_buf for the table specified by \p dset_id + * and \p dset_name located in \p loc_id. + * + * \par Example + * \include H5TBAget_fill.c + * + */ H5_HLDLL htri_t H5TBAget_fill(hid_t loc_id, const char *dset_name, hid_t dset_id, unsigned char *dst_buf); #ifdef __cplusplus diff --git a/hl/src/hdf5_hl.h b/hl/src/hdf5_hl.h index 9960b97607d..7757b392e19 100644 --- a/hl/src/hdf5_hl.h +++ b/hl/src/hdf5_hl.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3c22263923..db356e63ae7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -370,14 +370,6 @@ set (H5HL_HDRS IDE_GENERATED_PROPERTIES ("H5HL" "${H5HL_HDRS}" "${H5HL_SOURCES}" ) -set (H5HP_SOURCES - ${HDF5_SRC_DIR}/H5HP.c -) -set (H5HP_HDRS -) -IDE_GENERATED_PROPERTIES ("H5HP" "${H5HP_HDRS}" "${H5HP_SOURCES}" ) - - set (H5I_SOURCES ${HDF5_SRC_DIR}/H5I.c ${HDF5_SRC_DIR}/H5Idbg.c @@ -431,16 +423,6 @@ set (H5MM_HDRS IDE_GENERATED_PROPERTIES ("H5MM" "${H5MM_HDRS}" "${H5MM_SOURCES}" ) -set (H5MP_SOURCES - ${HDF5_SRC_DIR}/H5MP.c - ${HDF5_SRC_DIR}/H5MPtest.c -) - -set (H5MP_HDRS -) -IDE_GENERATED_PROPERTIES ("H5MP" "${H5MP_HDRS}" "${H5MP_SOURCES}" ) - - set (H5O_SOURCES ${HDF5_SRC_DIR}/H5O.c ${HDF5_SRC_DIR}/H5Oainfo.c @@ -733,7 +715,6 @@ set (H5_MODULE_HEADERS ${HDF5_SRC_DIR}/H5Lmodule.h ${HDF5_SRC_DIR}/H5Mmodule.h ${HDF5_SRC_DIR}/H5MFmodule.h - ${HDF5_SRC_DIR}/H5MPmodule.h ${HDF5_SRC_DIR}/H5Omodule.h ${HDF5_SRC_DIR}/H5Pmodule.h ${HDF5_SRC_DIR}/H5PBmodule.h @@ -769,13 +750,11 @@ set (common_SRCS ${H5HF_SOURCES} ${H5HG_SOURCES} ${H5HL_SOURCES} - ${H5HP_SOURCES} ${H5I_SOURCES} ${H5L_SOURCES} ${H5M_SOURCES} ${H5MF_SOURCES} ${H5MM_SOURCES} - ${H5MP_SOURCES} ${H5O_SOURCES} ${H5P_SOURCES} ${H5PB_SOURCES} @@ -818,7 +797,6 @@ set (H5_PUBLIC_HEADERS ${H5M_HDRS} ${H5MF_HDRS} ${H5MM_HDRS} - ${H5MP_HDRS} ${H5O_HDRS} ${H5P_HDRS} ${H5PB_HDRS} @@ -895,8 +873,6 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5HLpkg.h ${HDF5_SRC_DIR}/H5HLprivate.h - ${HDF5_SRC_DIR}/H5HPprivate.h - ${HDF5_SRC_DIR}/H5Ipkg.h ${HDF5_SRC_DIR}/H5Iprivate.h @@ -911,9 +887,6 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5MMprivate.h - ${HDF5_SRC_DIR}/H5MPpkg.h - ${HDF5_SRC_DIR}/H5MPprivate.h - ${HDF5_SRC_DIR}/H5Opkg.h ${HDF5_SRC_DIR}/H5Oprivate.h ${HDF5_SRC_DIR}/H5Oshared.h @@ -1014,6 +987,14 @@ if (BUILD_SHARED_LIBS) endif () if (LOCAL_BATCH_TEST) + configure_file ( + ${HDF5_SOURCE_DIR}/bin/batch/ctest_serial.cmake.in + ${HDF5_BINARY_DIR}/ctest_serial.cmake ESCAPE_QUOTES @ONLY + ) + configure_file ( + ${HDF5_SOURCE_DIR}/bin/batch/ctest_parallel.cmake.in + ${HDF5_BINARY_DIR}/ctest_parallel.cmake ESCAPE_QUOTES @ONLY + ) if (LOCAL_BATCH_SCRIPT_COMMAND STREQUAL "raybsub") configure_file ( ${HDF5_SOURCE_DIR}/bin/batch/${LOCAL_BATCH_SCRIPT_COMMAND} @@ -1034,20 +1015,23 @@ if (LOCAL_BATCH_TEST) endif () endif () +#### make the H5detect program set (lib_prog_deps) -if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") - add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) - target_include_directories (H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") - target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) - TARGET_C_PROPERTIES (H5detect STATIC) - target_link_libraries (H5detect - PRIVATE "$<$:${MPI_C_LIBRARIES}>" $<$,$>:ws2_32.lib> - ) - target_compile_options(H5detect - PRIVATE "$<$:-O0>" - ) - set (lib_prog_deps ${lib_prog_deps} H5detect) +add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) +target_include_directories (H5detect PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) +TARGET_C_PROPERTIES (H5detect STATIC) +target_link_libraries (H5detect + PRIVATE "$<$:MPI::MPI_C>" $<$,$>:ws2_32.lib> +) +target_compile_options(H5detect + PRIVATE "$<$:-O0>" +) +set (lib_prog_deps ${lib_prog_deps} H5detect) +# check if a pregenerated H5Tinit.c file is present +if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") + # execute the H5detect program if (HDF5_BATCH_H5DETECT) configure_file ( ${HDF5_SOURCE_DIR}/bin/batch/${HDF5_BATCH_H5DETECT_SCRIPT}.in.cmake @@ -1055,9 +1039,9 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") ) add_custom_command ( OUTPUT gen_SRCS.stamp1 + BYPRODUCTS H5Tinit.c COMMAND ${HDF5_BATCH_CMD} ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} - BYPRODUCTS H5Tinit.c gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E echo "Executed batch command to create H5Tinit.c" COMMAND ${CMAKE_COMMAND} @@ -1068,31 +1052,30 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") add_custom_target (gen_H5Tinit COMMAND ${CMAKE_COMMAND} -P ${HDF5_SOURCE_DIR}/config/cmake/wait_H5Tinit.cmake ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) else () - add_custom_command (TARGET H5detect POST_BUILD + add_custom_command ( + OUTPUT gen_SRCS.stamp1 + BYPRODUCTS H5Tinit.c COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ARGS H5Tinit.c - BYPRODUCTS H5Tinit.c gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch gen_SRCS.stamp1 DEPENDS H5detect WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Create H5Tinit.c" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) if (BUILD_SHARED_LIBS) - add_custom_command (TARGET H5detect POST_BUILD + add_custom_command ( + OUTPUT shared/shared_gen_SRCS.stamp1 + BYPRODUCTS shared/H5Tinit.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c - BYPRODUCTS shared/H5Tinit.c shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp1 - DEPENDS H5detect H5Tinit.c + DEPENDS H5detect gen_SRCS.stamp1 WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Copy H5Tinit.c to shared folder" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) endif () endif () else () @@ -1108,16 +1091,15 @@ else () if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT shared/shared_gen_SRCS.stamp1 + BYPRODUCTS shared/H5Tinit.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c - BYPRODUCTS shared/H5Tinit.c shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp1 - DEPENDS H5Tinit.c + DEPENDS H5Tinit.c gen_SRCS.stamp1 WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Copy existing H5Tinit.c to shared folder" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) endif () endif () @@ -1128,12 +1110,13 @@ if (HDF5_ENABLE_FORMATTERS) clang_format (HDF5_SRC_DETECT_FORMAT ${HDF5_SRC_DIR}/H5detect.c) endif () +# make the H5make_libsettings program add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c) -target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) TARGET_C_PROPERTIES (H5make_libsettings STATIC) target_link_libraries (H5make_libsettings - PRIVATE "$<$:${MPI_C_LIBRARIES}>" $<$,$>:ws2_32.lib> + PRIVATE "$<$:MPI::MPI_C>" $<$,$>:ws2_32.lib> ) target_compile_options(H5make_libsettings PRIVATE "$<$:-O0>" @@ -1147,10 +1130,12 @@ if (HDF5_ENABLE_FORMATTERS) clang_format (HDF5_SRC_LIBSETTINGS_FORMAT H5make_libsettings) endif () -add_custom_command (TARGET H5make_libsettings POST_BUILD +# execute the H5make_libsettings program +add_custom_command ( + OUTPUT gen_SRCS.stamp2 + BYPRODUCTS H5lib_settings.c COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ARGS H5lib_settings.c - BYPRODUCTS H5lib_settings.c gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} ARGS -E touch gen_SRCS.stamp2 DEPENDS H5make_libsettings @@ -1159,37 +1144,33 @@ add_custom_command (TARGET H5make_libsettings POST_BUILD ) set_source_files_properties (${HDF5_SRC_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE) if (BUILD_SHARED_LIBS) - add_custom_command (TARGET H5make_libsettings POST_BUILD + add_custom_command ( + OUTPUT shared/shared_gen_SRCS.stamp2 + BYPRODUCTS shared/H5lib_settings.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5lib_settings.c shared/H5lib_settings.c - BYPRODUCTS shared/H5lib_settings.c shared/shared_gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp2 - DEPENDS H5make_libsettings H5lib_settings.c + DEPENDS H5make_libsettings gen_SRCS.stamp2 WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR} COMMENT "Copy H5lib_settings.c to shared folder" ) - set_source_files_properties (${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE) endif () -## all_packages="AC,B,B2,D,F,FA,FL,FS,HL,I,O,S,ST,T,Z" -#all_packages="AC,B2,CX,D,F,HL,I,O,S,ST,T,Z" -option (HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF) - #----------------------------------------------------------------------------- # Add H5Tinit source to build - generated by H5detect/CMake at configure time #----------------------------------------------------------------------------- -if (NOT ONLY_SHARED_LIBS) +if (BUILD_STATIC_LIBS) set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c) add_custom_target (gen_${HDF5_LIB_TARGET} ALL - DEPENDS ${lib_prog_deps} ${gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2 + DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2 COMMENT "Generation target files" ) add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS}) target_include_directories (${HDF5_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" - INTERFACE "$/include>;$" + PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + INTERFACE "$/include>;$" ) target_compile_options(${HDF5_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_compile_definitions(${HDF5_LIB_TARGET} @@ -1197,17 +1178,18 @@ if (NOT ONLY_SHARED_LIBS) ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS} PRIVATE - $<$:H5_DEBUG_API> # Enable tracing of the API - $<$:H5Z_DEBUG;H5T_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> + "$<$:H5_DEBUG_API>" # Enable tracing of the API + "$<$:${HDF5_DEBUG_APIS}>" + "$<$:${HDF5_DEVELOPER_DEFS}>" ) TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC) target_link_libraries (${HDF5_LIB_TARGET} - PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} "$<$:${MPI_C_LIBRARIES}>" - PUBLIC $<$>:${CMAKE_DL_LIBS}> + PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} + PUBLIC "$<$>:${CMAKE_DL_LIBS}>" "$<$:MPI::MPI_C>" ) if (NOT WIN32) target_link_libraries (${HDF5_LIB_TARGET} - PRIVATE $<$:Threads::Threads> + PRIVATE "$<$:Threads::Threads>" ) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET}) @@ -1221,15 +1203,15 @@ endif () if (BUILD_SHARED_LIBS) set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c) add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL - DEPENDS ${lib_prog_deps} ${shared_gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 + DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 COMMENT "Shared generation target files" ) add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS}) target_include_directories (${HDF5_LIBSH_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" PUBLIC "$<$:${HDFS_INCLUDE_DIR}>" - INTERFACE "$/include>;$" + INTERFACE "$/include>;$" ) target_compile_options(${HDF5_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_compile_definitions(${HDF5_LIBSH_TARGET} @@ -1238,14 +1220,16 @@ if (BUILD_SHARED_LIBS) ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS} PRIVATE - $<$:H5_HAVE_THREADSAFE> - $<$:H5_DEBUG_API> # Enable tracing of the API - $<$:H5Z_DEBUG;H5T_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> + "$<$:H5_HAVE_THREADSAFE>" + "$<$:H5_DEBUG_API>" # Enable tracing of the API + "$<$:${HDF5_DEBUG_APIS}>" + "$<$:${HDF5_DEVELOPER_DEFS}>" ) TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_LIBSH_TARGET} - PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} "$<$:${MPI_C_LIBRARIES}>" $<$:Threads::Threads> - PUBLIC $<$>:${CMAKE_DL_LIBS}> + PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS} + "$<$:Threads::Threads>" + PUBLIC "$<$>:${CMAKE_DL_LIBS}>" "$<$:MPI::MPI_C>" ) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED "LIB") @@ -1259,7 +1243,7 @@ endif () # Add Target to clang-format #----------------------------------------------------------------------------- if (HDF5_ENABLE_FORMATTERS) - if (NOT ONLY_SHARED_LIBS) + if (BUILD_STATIC_LIBS) clang_format (HDF5_SRC_FORMAT ${HDF5_LIB_TARGET}) else () clang_format (HDF5_SRC_FORMAT ${HDF5_LIBSH_TARGET}) @@ -1289,7 +1273,7 @@ if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) INSTALL_TARGET_PDB (${HDF5_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} libraries) endif () - if (NOT ONLY_SHARED_LIBS) + if (BUILD_STATIC_LIBS) INSTALL_TARGET_PDB (${HDF5_LIB_TARGET} ${HDF5_INSTALL_LIB_DIR} libraries) endif () @@ -1311,24 +1295,34 @@ endif () #----------------------------------------------------------------------------- set (_PKG_CONFIG_PREFIX ${CMAKE_INSTALL_PREFIX}) set (_PKG_CONFIG_EXEC_PREFIX \${prefix}) -set (_PKG_CONFIG_LIBDIR \${exec_prefix}/lib) -set (_PKG_CONFIG_INCLUDEDIR \${prefix}/include) +set (_PKG_CONFIG_LIBDIR \${exec_prefix}/${HDF5_INSTALL_LIB_DIR}) +set (_PKG_CONFIG_INCLUDEDIR \${prefix}/${HDF5_INSTALL_INCLUDE_DIR}) set (_PKG_CONFIG_LIBNAME "${HDF5_LIB_CORENAME}") set (_PKG_CONFIG_VERSION "${HDF5_PACKAGE_VERSION}") +set (PKGCONFIG_LIBNAME "${HDF5_LIB_CORENAME}") +if (${HDF_CFG_NAME} MATCHES "Debug" OR ${HDF_CFG_NAME} MATCHES "Developer") + set (PKGCONFIG_LIBNAME "${PKGCONFIG_LIBNAME}${CMAKE_DEBUG_POSTFIX}") +endif () -foreach (libs ${LINK_LIBS} ${LINK_COMP_LIBS}) +foreach (libs ${LINK_LIBS}) set (_PKG_CONFIG_LIBS_PRIVATE "${_PKG_CONFIG_LIBS_PRIVATE} -l${libs}") endforeach () -if (NOT ONLY_SHARED_LIBS) - set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${HDF5_LIB_CORENAME}") +# The settings for the compression libs depends on if they have pkconfig support +# Assuming they don't +foreach (libs ${LINK_COMP_LIBS}) +# set (_PKG_CONFIG_REQUIRES_PRIVATE "${_PKG_CONFIG_REQUIRES_PRIVATE} -l${libs}") + set (_PKG_CONFIG_LIBS_PRIVATE "${_PKG_CONFIG_LIBS_PRIVATE} -l${libs}") +endforeach () + +if (BUILD_STATIC_LIBS) + set (_PKG_CONFIG_LIBS "${_PKG_CONFIG_LIBS} -l${PKGCONFIG_LIBNAME}") endif () if (BUILD_SHARED_LIBS) - set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${HDF5_LIB_CORENAME}") + set (_PKG_CONFIG_SH_LIBS "${_PKG_CONFIG_SH_LIBS} -l${PKGCONFIG_LIBNAME}") endif () set (_PKG_CONFIG_REQUIRES) -set (_PKG_CONFIG_REQUIRES_PRIVATE) configure_file ( ${HDF_CONFIG_DIR}/libhdf5.pc.in @@ -1378,50 +1372,14 @@ endif () # Option to build documentation #----------------------------------------------------------------------------- if (DOXYGEN_FOUND) - set (DOXYGEN_PACKAGE ${HDF5_PACKAGE_NAME}) - set (DOXYGEN_VERSION_STRING ${HDF5_PACKAGE_VERSION_STRING}) - set (DOXYGEN_INCLUDE_ALIASES_PATH ${HDF5_DOXYGEN_DIR}) - set (DOXYGEN_INCLUDE_ALIASES aliases) - set (DOXYGEN_VERBATIM_VARS DOXYGEN_INCLUDE_ALIASES) - set (DOXYGEN_PROJECT_LOGO ${HDF5_DOXYGEN_DIR}/img/HDFG-logo.png) - set (DOXYGEN_PROJECT_BRIEF "C-API Reference") - set (DOXYGEN_INPUT_DIRECTORY "${HDF5_SRC_DIR} ${HDF5_DOXYGEN_DIR}/dox ${HDF5_GENERATED_SOURCE_DIR}") - set (DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES) - set (DOXYGEN_MACRO_EXPANSION YES) - set (DOXYGEN_OUTPUT_DIRECTORY ${HDF5_BINARY_DIR}/hdf5lib_docs) - set (DOXYGEN_EXAMPLES_DIRECTORY "${HDF5_DOXYGEN_DIR}/examples ${HDF5_SRC_DIR} ${HDF5_SOURCE_DIR}/examples ${HDF5_TEST_SRC_DIR}") - set (DOXYGEN_LAYOUT_FILE ${HDF5_DOXYGEN_DIR}/hdf5doxy_layout.xml) - set (DOXYGEN_HTML_HEADER ${HDF5_DOXYGEN_DIR}/hdf5_header.html) - set (DOXYGEN_HTML_FOOTER ${HDF5_DOXYGEN_DIR}/hdf5_footer.html) - set (DOXYGEN_HTML_EXTRA_STYLESHEET ${HDF5_DOXYGEN_DIR}/hdf5doxy.css) - set (DOXYGEN_HTML_EXTRA_FILES "${HDF5_DOXYGEN_DIR}/hdf5_navtree_hacks.js ${HDF5_DOXYGEN_DIR}/img/ftv2node.png ${HDF5_DOXYGEN_DIR}/img/ftv2pnode.png") - set (DOXYGEN_SERVER_BASED_SEARCH NO) - set (DOXYGEN_EXTERNAL_SEARCH NO) - set (DOXYGEN_SEARCHENGINE_URL) - -# This configure and custom target work together + # This custom target and doxygen/configure work together # Replace variables inside @@ with the current values - configure_file (${HDF5_DOXYGEN_DIR}/Doxyfile.in ${HDF5_BINARY_DIR}/Doxyfile @ONLY) add_custom_target (hdf5lib_doc ALL COMMAND ${DOXYGEN_EXECUTABLE} ${HDF5_BINARY_DIR}/Doxyfile DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c WORKING_DIRECTORY ${HDF5_SRC_DIR} COMMENT "Generating HDF5 library Source API documentation with Doxygen" VERBATIM ) -# This cmake function requires that the non-default doxyfile settings are provided with set (DOXYGEN_xxx) commands -# In addition the doxyfile aliases @INCLUDE option is not supported and would need to be provided in a set (DOXYGEN_ALIASES) command. -# doxygen_add_docs (hdf5lib_doc -## ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${HDF5_DOXYGEN_DIR}/dox -# ${DOXYGEN_INPUT_DIRECTORY} -# ALL -# WORKING_DIRECTORY ${HDF5_SRC_DIR} -# COMMENT "Generating HDF5 library Source Documentation" -# ) - install ( - DIRECTORY ${HDF5_BINARY_DIR}/hdf5lib_docs/html - DESTINATION ${HDF5_INSTALL_DATA_DIR} - COMPONENT Documents - ) if (NOT TARGET doxygen) add_custom_target (doxygen) diff --git a/src/H5.c b/src/H5.c index 572e5e58f37..ffb4dd11152 100644 --- a/src/H5.c +++ b/src/H5.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -63,9 +62,9 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Library Private Variables */ /*****************************/ -/* HDF5 API Entered variable */ -/* (move to H5.c when new FUNC_ENTER macros in actual use -QAK) */ -hbool_t H5_api_entered_g = FALSE; +/* Library incompatible release versions */ +const unsigned VERS_RELEASE_EXCEPTIONS[] = {0}; +const unsigned VERS_RELEASE_EXCEPTIONS_SIZE = 0; /* statically initialize block for pthread_once call used in initializing */ /* the first global mutex */ @@ -210,7 +209,7 @@ H5_init_library(void) * Install atexit() library cleanup routines unless the H5dont_atexit() * has been called. Once we add something to the atexit() list it stays * there permanently, so we set H5_dont_atexit_g after we add it to prevent - * adding it again later if the library is cosed and reopened. + * adding it again later if the library is closed and reopened. */ if (!H5_dont_atexit_g) { @@ -268,13 +267,13 @@ H5_init_library(void) } /* end H5_init_library() */ /*------------------------------------------------------------------------- - * Function: H5_term_library + * Function: H5_term_library * - * Purpose: Terminate interfaces in a well-defined order due to - * dependencies among the interfaces, then terminate - * library-specific data. + * Purpose: Terminate interfaces in a well-defined order due to + * dependencies among the interfaces, then terminate + * library-specific data. * - * Return: void + * Return: void * *------------------------------------------------------------------------- */ @@ -460,22 +459,22 @@ H5_term_library(void) } /* end H5_term_library() */ /*------------------------------------------------------------------------- - * Function: H5dont_atexit + * Function: H5dont_atexit * - * Purpose: Indicates that the library is not to clean up after itself - * when the application exits by calling exit() or returning - * from main(). This function must be called before any other - * HDF5 function or constant is used or it will have no effect. + * Purpose: Indicates that the library is not to clean up after itself + * when the application exits by calling exit() or returning + * from main(). This function must be called before any other + * HDF5 function or constant is used or it will have no effect. * - * If this function is used then certain memory buffers will not - * be de-allocated nor will open files be flushed automatically. - * The application may still call H5close() explicitly to - * accomplish these things. + * If this function is used then certain memory buffers will not + * be de-allocated nor will open files be flushed automatically. + * The application may still call H5close() explicitly to + * accomplish these things. * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative if this function is called more than - * once or if it is called too late. + * Failure: negative if this function is called more than + * once or if it is called too late. * *------------------------------------------------------------------------- */ @@ -496,19 +495,19 @@ H5dont_atexit(void) } /* end H5dont_atexit() */ /*------------------------------------------------------------------------- - * Function: H5garbage_collect + * Function: H5garbage_collect * - * Purpose: Walks through all the garbage collection routines for the - * library, which are supposed to free any unused memory they have - * allocated. + * Purpose: Walks through all the garbage collection routines for the + * library, which are supposed to free any unused memory they have + * allocated. * * These should probably be registered dynamically in a linked list of * functions to call, but there aren't that many right now, so we * hard-wire them... * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * *------------------------------------------------------------------------- */ @@ -529,9 +528,9 @@ H5garbage_collect(void) } /* end H5garbage_collect() */ /*------------------------------------------------------------------------- - * Function: H5set_free_list_limits + * Function: H5set_free_list_limits * - * Purpose: Sets limits on the different kinds of free lists. Setting a value + * Purpose: Sets limits on the different kinds of free lists. Setting a value * of -1 for a limit means no limit of that type. These limits are global * for the entire library. Each "global" limit only applies to free lists * of that type, so if an application sets a limit of 1 MB on each of the @@ -549,9 +548,9 @@ H5garbage_collect(void) * int blk_global_lim; IN: The limit on all "block" free list memory used * int blk_list_lim; IN: The limit on memory used in each "block" free list * - * Return: Success: non-negative + * Return: Success: non-negative * - * Failure: negative + * Failure: negative * *------------------------------------------------------------------------- */ @@ -575,11 +574,11 @@ H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, } /* end H5set_free_list_limits() */ /*------------------------------------------------------------------------- - * Function: H5get_free_list_sizes + * Function: H5get_free_list_sizes * - * Purpose: Gets the current size of the different kinds of free lists that - * the library uses to manage memory. The free list sizes can be set with - * H5set_free_list_limits and garbage collected with H5garbage_collect. + * Purpose: Gets the current size of the different kinds of free lists that + * the library uses to manage memory. The free list sizes can be set with + * H5set_free_list_limits and garbage collected with H5garbage_collect. * These lists are global for the entire library. * * Parameters: @@ -588,8 +587,8 @@ H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, * size_t *blk_size; OUT: The current size of all "block" free list memory used * size_t *fac_size; OUT: The current size of all "factory" free list memory used * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * * Programmer: Quincey Koziol * Friday, March 6, 2020 @@ -597,12 +596,13 @@ H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, *------------------------------------------------------------------------- */ herr_t -H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size) +H5get_free_list_sizes(size_t *reg_size /*out*/, size_t *arr_size /*out*/, size_t *blk_size /*out*/, + size_t *fac_size /*out*/) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE4("e", "*z*z*z*z", reg_size, arr_size, blk_size, fac_size); + H5TRACE4("e", "xxxx", reg_size, arr_size, blk_size, fac_size); /* Call the free list function to actually get the sizes */ if (H5FL_get_free_list_sizes(reg_size, arr_size, blk_size, fac_size) < 0) @@ -613,23 +613,23 @@ H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size } /* end H5get_free_list_sizes() */ /*------------------------------------------------------------------------- - * Function: H5get_alloc_stats + * Function: H5get_alloc_stats * - * Purpose: Gets the memory allocation statistics for the library, if the - * --enable-memory-alloc-sanity-check option was given when building the + * Purpose: Gets the memory allocation statistics for the library, if the + * --enable-memory-alloc-sanity-check option was given when building the * library. Applications can check whether this option was enabled by - * detecting if the 'H5_MEMORY_ALLOC_SANITY_CHECK' macro is defined. This - * option is enabled by default for debug builds of the library and - * disabled by default for non-debug builds. If the option is not enabled, - * all the values returned with be 0. These statistics are global for the - * entire library, but don't include allocations from chunked dataset I/O - * filters or non-native VOL connectors. + * detecting if the 'H5_MEMORY_ALLOC_SANITY_CHECK' macro is defined. This + * option is enabled by default for debug builds of the library and + * disabled by default for non-debug builds. If the option is not enabled, + * all the values returned with be 0. These statistics are global for the + * entire library, but don't include allocations from chunked dataset I/O + * filters or non-native VOL connectors. * * Parameters: * H5_alloc_stats_t *stats; OUT: Memory allocation statistics * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * * Programmer: Quincey Koziol * Saturday, March 7, 2020 @@ -637,12 +637,12 @@ H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size *------------------------------------------------------------------------- */ herr_t -H5get_alloc_stats(H5_alloc_stats_t *stats) +H5get_alloc_stats(H5_alloc_stats_t *stats /*out*/) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("e", "*x", stats); + H5TRACE1("e", "x", stats); /* Call the internal allocation stat routine to get the values */ if (H5MM_get_alloc_stats(stats) < 0) @@ -678,7 +678,7 @@ H5get_alloc_stats(H5_alloc_stats_t *stats) static void H5__debug_mask(const char *s) { - FILE * stream = stderr; + FILE *stream = stderr; char pkg_name[32], *rest; size_t i; hbool_t clear; @@ -762,12 +762,12 @@ H5__debug_mask(const char *s) #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- - * Function: H5__mpi_delete_cb + * Function: H5__mpi_delete_cb * - * Purpose: Callback attribute on MPI_COMM_SELF to terminate the HDF5 + * Purpose: Callback attribute on MPI_COMM_SELF to terminate the HDF5 * library when the communicator is destroyed, i.e. on MPI_Finalize. * - * Return: MPI_SUCCESS + * Return: MPI_SUCCESS * *------------------------------------------------------------------------- */ @@ -781,28 +781,28 @@ H5__mpi_delete_cb(MPI_Comm H5_ATTR_UNUSED comm, int H5_ATTR_UNUSED keyval, void #endif /*H5_HAVE_PARALLEL*/ /*------------------------------------------------------------------------- - * Function: H5get_libversion + * Function: H5get_libversion * - * Purpose: Returns the library version numbers through arguments. MAJNUM - * will be the major revision number of the library, MINNUM the - * minor revision number, and RELNUM the release revision number. + * Purpose: Returns the library version numbers through arguments. MAJNUM + * will be the major revision number of the library, MINNUM the + * minor revision number, and RELNUM the release revision number. * - * Note: When printing an HDF5 version number it should be printed as + * Note: When printing an HDF5 version number it should be printed as * - * printf("%u.%u.%u", maj, min, rel) or - * printf("version %u.%u release %u", maj, min, rel) + * printf("%u.%u.%u", maj, min, rel) or + * printf("version %u.%u release %u", maj, min, rel) * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ herr_t -H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) +H5get_libversion(unsigned *majnum /*out*/, unsigned *minnum /*out*/, unsigned *relnum /*out*/) { herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE3("e", "*Iu*Iu*Iu", majnum, minnum, relnum); + H5TRACE3("e", "xxx", majnum, minnum, relnum); /* Set the version information */ if (majnum) @@ -817,17 +817,20 @@ H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) } /* end H5get_libversion() */ /*------------------------------------------------------------------------- - * Function: H5check_version + * Function: H5check_version * - * Purpose: Verifies that the arguments match the version numbers - * compiled into the library. This function is intended to be - * called from user to verify that the versions of header files - * compiled into the application match the version of the hdf5 - * library. + * Purpose: Verifies that the arguments match the version numbers + * compiled into the library. This function is intended to be + * called from user to verify that the versions of header files + * compiled into the application match the version of the hdf5 + * library. + * Within major.minor.release version, the expectation + * is that all release versions are compatible, exceptions to + * this rule must be added to the VERS_RELEASE_EXCEPTIONS list. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: abort() + * Failure: abort() * *------------------------------------------------------------------------- */ @@ -840,6 +843,15 @@ H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum) "linked with a different version of static or shared HDF5 library.\n" \ "You should recompile the application or check your shared library related\n" \ "settings such as 'LD_LIBRARY_PATH'.\n" +#define RELEASE_MISMATCH_WARNING \ + "Warning! ***HDF5 library release mismatched error***\n" \ + "The HDF5 header files used to compile this application are not compatible with\n" \ + "the version used by the HDF5 library to which this application is linked.\n" \ + "Data corruption or segmentation faults may occur if the application continues.\n" \ + "This can happen when an application was compiled by one version of HDF5 but\n" \ + "linked with an incompatible version of static or shared HDF5 library.\n" \ + "You should recompile the application or check your shared library related\n" \ + "settings such as 'LD_LIBRARY_PATH'.\n" herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) @@ -848,7 +860,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) char substr[] = H5_VERS_SUBRELEASE; static int checked = 0; /* If we've already checked the version info */ static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */ - static const char * version_mismatch_warning = VERSION_MISMATCH_WARNING; + static const char *version_mismatch_warning = VERSION_MISMATCH_WARNING; + static const char *release_mismatch_warning = RELEASE_MISMATCH_WARNING; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API_NOINIT_NOERR_NOFS @@ -868,7 +881,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) disable_version_check = (unsigned int)HDstrtol(s, NULL, 0); } - if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum || H5_VERS_RELEASE != relnum) { + /* H5_VERS_MAJOR and H5_VERS_MINOR must match */ + if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum) { switch (disable_version_check) { case 0: HDfprintf(stderr, "%s%s", version_mismatch_warning, @@ -903,7 +917,52 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) break; } /* end switch */ - } /* end if */ + } /* end if (H5_VERS_MAJOR != majnum || H5_VERS_MINOR != minnum) */ + + /* H5_VERS_RELEASE should be compatible, we will only add checks for exceptions */ + /* Library develop release versions are incompatible by design */ + if (H5_VERS_RELEASE != relnum) { + for (unsigned i = 0; i < VERS_RELEASE_EXCEPTIONS_SIZE; i++) { + /* Check for incompatible headers or incompatible library */ + if (VERS_RELEASE_EXCEPTIONS[i] == relnum || VERS_RELEASE_EXCEPTIONS[i] == H5_VERS_RELEASE) { + switch (disable_version_check) { + case 0: + HDfprintf( + stderr, "%s%s", release_mismatch_warning, + "You can, at your own risk, disable this warning by setting the environment\n" + "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n" + "Setting it to 2 or higher will suppress the warning messages totally.\n"); + /* Mention the versions we are referring to */ + HDfprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, + relnum, (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, + (unsigned)H5_VERS_RELEASE); + + /* Bail out now. */ + HDfputs("Bye...\n", stderr); + HDabort(); + case 1: + /* continue with a warning */ + /* Note that the warning message is embedded in the format string.*/ + HDfprintf(stderr, + "%s'HDF5_DISABLE_VERSION_CHECK' " + "environment variable is set to %d, application will\n" + "continue at your own risk.\n", + release_mismatch_warning, disable_version_check); + /* Mention the versions we are referring to */ + HDfprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, + relnum, (unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, + (unsigned)H5_VERS_RELEASE); + break; + default: + /* 2 or higher: continue silently */ + break; + } /* end switch */ + + } /* end if */ + + } /* end for */ + + } /* end if (H5_VERS_RELEASE != relnum) */ /* Indicate that the version check has been performed */ checked = 1; @@ -914,12 +973,9 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) * Check only the first sizeof(lib_str) char. Assume the information * will fit within this size or enough significance. */ - HDsnprintf(lib_str, sizeof(lib_str), "HDF5 library version: %d.%d.%d", H5_VERS_MAJOR, H5_VERS_MINOR, - H5_VERS_RELEASE); - if (*substr) { - HDstrncat(lib_str, "-", (size_t)1); - HDstrncat(lib_str, substr, (sizeof(lib_str) - HDstrlen(lib_str)) - 1); - } /* end if */ + HDsnprintf(lib_str, sizeof(lib_str), "HDF5 library version: %d.%d.%d%s%s", H5_VERS_MAJOR, + H5_VERS_MINOR, H5_VERS_RELEASE, (*substr ? "-" : ""), substr); + if (HDstrcmp(lib_str, H5_lib_vers_info_g) != 0) { HDfputs("Warning! Library version information error.\n" "The HDF5 library version information are not " @@ -948,7 +1004,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) * is failing inexplicably, then try calling this function * first. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -967,11 +1023,11 @@ H5open(void) } /* end H5open() */ /*------------------------------------------------------------------------- - * Function: H5close + * Function: H5close * - * Purpose: Terminate the library and release all resources. + * Purpose: Terminate the library and release all resources. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -992,9 +1048,9 @@ H5close(void) } /* end H5close() */ /*------------------------------------------------------------------------- - * Function: H5allocate_memory + * Function: H5allocate_memory * - * Purpose: Allocate a memory buffer with the semantics of malloc(). + * Purpose: Allocate a memory buffer with the semantics of malloc(). * * NOTE: This function is intended for use with filter * plugins so that all allocation and free operations @@ -1032,9 +1088,9 @@ H5allocate_memory(size_t size, hbool_t clear) } /* end H5allocate_memory() */ /*------------------------------------------------------------------------- - * Function: H5resize_memory + * Function: H5resize_memory * - * Purpose: Resize a memory buffer with the semantics of realloc(). + * Purpose: Resize a memory buffer with the semantics of realloc(). * * NOTE: This function is intended for use with filter * plugins so that all allocation and free operations @@ -1069,14 +1125,14 @@ H5resize_memory(void *mem, size_t size) } /* end H5resize_memory() */ /*------------------------------------------------------------------------- - * Function: H5free_memory + * Function: H5free_memory * - * Purpose: Frees memory allocated by the library that it is the user's + * Purpose: Frees memory allocated by the library that it is the user's * responsibility to free. Ensures that the same library * that was used to allocate the memory frees it. Passing * NULL pointers is allowed. * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1093,31 +1149,34 @@ H5free_memory(void *mem) } /* end H5free_memory() */ /*------------------------------------------------------------------------- - * Function: H5is_library_threadsafe + * Function: H5is_library_threadsafe * - * Purpose: Checks to see if the library was built with thread-safety + * Purpose: Checks to see if the library was built with thread-safety * enabled. * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5is_library_threadsafe(hbool_t *is_ts) +H5is_library_threadsafe(hbool_t *is_ts /*out*/) { - FUNC_ENTER_API_NOINIT - H5TRACE1("e", "*b", is_ts); + herr_t ret_value = SUCCEED; /* Return value */ - HDassert(is_ts); + FUNC_ENTER_API_NOINIT + H5TRACE1("e", "x", is_ts); - /* At this time, it is impossible for this to fail. */ + if (is_ts) { #ifdef H5_HAVE_THREADSAFE - *is_ts = TRUE; + *is_ts = TRUE; #else /* H5_HAVE_THREADSAFE */ - *is_ts = FALSE; + *is_ts = FALSE; #endif /* H5_HAVE_THREADSAFE */ + } + else + ret_value = FAIL; - FUNC_LEAVE_API_NOINIT(SUCCEED) + FUNC_LEAVE_API_NOINIT(ret_value) } /* end H5is_library_threadsafe() */ #if defined(H5_HAVE_THREADSAFE) && defined(H5_BUILT_AS_DYNAMIC_LIB) && defined(H5_HAVE_WIN32_API) && \ diff --git a/src/H5A.c b/src/H5A.c index 3d20f83701b..6b4d74c2bb2 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -260,8 +259,8 @@ H5A_term_package(void) hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id) { - void * attr = NULL; /* Attribute created */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + void *attr = NULL; /* Attribute created */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -344,8 +343,8 @@ hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id) { - void * attr = NULL; /* attr object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -420,8 +419,8 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid hid_t H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { - void * attr = NULL; /* attr object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; @@ -490,8 +489,8 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t aapl_id, hid_t lapl_id) { - void * attr = NULL; /* attr object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; @@ -568,8 +567,8 @@ hid_t H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t aapl_id, hid_t lapl_id) { - void * attr = NULL; /* Attribute opened */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *attr = NULL; /* Attribute opened */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -642,8 +641,8 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_ herr_t H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) { - H5VL_object_t *vol_obj; /* Attribute object for ID */ - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* Attribute object for ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); @@ -685,13 +684,13 @@ H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) This function reads a complete attribute from disk. --------------------------------------------------------------------------*/ herr_t -H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) +H5Aread(hid_t attr_id, hid_t dtype_id, void *buf /*out*/) { - H5VL_object_t *vol_obj; /* Attribute object for ID */ - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* Attribute object for ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); + H5TRACE3("e", "iix", attr_id, dtype_id, buf); /* Check arguments */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) @@ -849,14 +848,14 @@ H5Aget_create_plist(hid_t attr_id) properly terminate the string. --------------------------------------------------------------------------*/ ssize_t -H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) +H5Aget_name(hid_t attr_id, size_t buf_size, char *buf /*out*/) { - H5VL_object_t * vol_obj = NULL; /* Attribute object for ID */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ H5VL_loc_params_t loc_params; ssize_t ret_value = -1; FUNC_ENTER_API((-1)) - H5TRACE3("Zs", "iz*s", attr_id, buf_size, buf); + H5TRACE3("Zs", "izx", attr_id, buf_size, buf); /* check arguments */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) @@ -898,7 +897,7 @@ ssize_t H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ @@ -995,14 +994,14 @@ H5Aget_storage_size(hid_t attr_id) *------------------------------------------------------------------------- */ herr_t -H5Aget_info(hid_t attr_id, H5A_info_t *ainfo) +H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", attr_id, ainfo); + H5TRACE2("e", "ix", attr_id, ainfo); /* Check args */ if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) @@ -1036,15 +1035,15 @@ H5Aget_info(hid_t attr_id, H5A_info_t *ainfo) *------------------------------------------------------------------------- */ herr_t -H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo, +H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE5("e", "i*s*s*xi", loc_id, obj_name, attr_name, ainfo, lapl_id); + H5TRACE5("e", "i*s*sxi", loc_id, obj_name, attr_name, ainfo, lapl_id); /* Check args */ if (H5I_ATTR == H5I_get_type(loc_id)) @@ -1094,14 +1093,14 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H */ herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, - H5A_info_t *ainfo, hid_t lapl_id) + H5A_info_t *ainfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*sIiIoh*xi", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id); + H5TRACE7("e", "i*sIiIohxi", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id); /* Check args */ if (H5I_ATTR == H5I_get_type(loc_id)) @@ -1175,7 +1174,7 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) /* Avoid thrashing things if the names are the same */ if (HDstrcmp(old_name, new_name)) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; loc_params.type = H5VL_OBJECT_BY_SELF; @@ -1232,7 +1231,7 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, /* Avoid thrashing things if the names are the same */ if (HDstrcmp(old_attr_name, new_attr_name)) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; /* Verify access property list and set up collective metadata if appropriate */ @@ -1279,7 +1278,7 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, if all attributes were processed. DESCRIPTION - This function interates over the attributes of dataset or group + This function iterates over the attributes of dataset or group specified with 'loc_id' & 'obj_name'. For each attribute of the object, the 'op_data' and some additional information (specified below) are passed to the 'op' function. The iteration begins with the '*idx' @@ -1300,17 +1299,17 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, attribute. --------------------------------------------------------------------------*/ herr_t -H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, - void *op_data) +H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx /*in_out */, + H5A_operator2_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIo*hx*x", loc_id, idx_type, order, idx, op, op_data); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1318,10 +1317,11 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *i if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + /* Set the location access parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - /* get the loc object */ + /* Get the loc object */ if (NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") @@ -1357,7 +1357,7 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *i if all attributes were processed. DESCRIPTION - This function interates over the attributes of dataset or group + This function iterates over the attributes of dataset or group specified with 'loc_id' & 'obj_name'. For each attribute of the object, the 'op_data' and some additional information (specified below) are passed to the 'op' function. The iteration begins with the '*idx' @@ -1379,9 +1379,9 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *i --------------------------------------------------------------------------*/ herr_t H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, - hsize_t *idx, H5A_operator2_t op, void *op_data, hid_t lapl_id) + hsize_t *idx /*in_out */, H5A_operator2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object location */ + H5VL_object_t *vol_obj = NULL; /* Object location */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1402,6 +1402,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set the location access parameters */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.obj_type = H5I_get_type(loc_id); loc_params.loc_data.loc_by_name.name = obj_name; @@ -1437,7 +1438,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i herr_t H5Adelete(hid_t loc_id, const char *name) { - H5VL_object_t * vol_obj = NULL; + H5VL_object_t *vol_obj = NULL; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1492,7 +1493,7 @@ H5Adelete(hid_t loc_id, const char *name) herr_t H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1511,7 +1512,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid if (H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Fill in location struct fields */ + /* Set the location access parameters */ loc_params.type = H5VL_OBJECT_BY_NAME; loc_params.loc_data.loc_by_name.name = obj_name; loc_params.loc_data.loc_by_name.lapl_id = lapl_id; @@ -1558,7 +1559,7 @@ herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1648,7 +1649,7 @@ H5Aclose(hid_t attr_id) htri_t H5Aexists(hid_t obj_id, const char *attr_name) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; htri_t ret_value; /* Return value */ @@ -1683,7 +1684,7 @@ H5Aexists(hid_t obj_id, const char *attr_name) * Purpose: Checks if an attribute with a given name exists on an object. * * Return: Success: TRUE/FALSE - * Failure: Negative + * Failure: Negative * * Programmer: Quincey Koziol * Thursday, November 1, 2007 @@ -1693,7 +1694,7 @@ H5Aexists(hid_t obj_id, const char *attr_name) htri_t H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; htri_t ret_value; /* Return value */ diff --git a/src/H5AC.c b/src/H5AC.c index 2eadd2102c2..9c1a2aeb514 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -232,7 +231,7 @@ H5AC_term_package(void) hbool_t H5AC_cache_image_pending(const H5F_t *f) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -333,7 +332,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co aux_ptr->sync_point_done = NULL; aux_ptr->p0_image_len = 0; - HDsprintf(prefix, "%d:", mpi_rank); + HDsnprintf(prefix, sizeof(prefix), "%d:", mpi_rank); if (mpi_rank == 0) { if (NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) @@ -908,7 +907,7 @@ herr_t H5AC_mark_entry_dirty(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -962,7 +961,7 @@ herr_t H5AC_mark_entry_clean(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1015,7 +1014,7 @@ herr_t H5AC_mark_entry_unserialized(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1057,7 +1056,7 @@ herr_t H5AC_mark_entry_serialized(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1155,7 +1154,7 @@ herr_t H5AC_pin_protected_entry(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1229,7 +1228,7 @@ H5AC_prep_for_file_close(H5F_t *f) * metadata cache flush. * * Initially, this means setting up the slist prior to the - * flush. We do this in a seperate call because + * flush. We do this in a separate call because * H5F__flush_phase2() make repeated calls to H5AC_flush(). * Handling this detail in separate calls allows us to avoid * the overhead of setting up and taking down the skip list @@ -1281,7 +1280,7 @@ H5AC_prep_for_file_flush(H5F_t *f) * flush. * * Initially, this means taking down the slist after the - * flush. We do this in a seperate call because + * flush. We do this in a separate call because * H5F__flush_phase2() make repeated calls to H5AC_flush(). * Handling this detail in separate calls allows us to avoid * the overhead of setting up and taking down the skip list @@ -1336,7 +1335,7 @@ herr_t H5AC_create_flush_dependency(void *parent_thing, void *child_thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1458,7 +1457,7 @@ herr_t H5AC_resize_entry(void *thing, size_t new_size) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1470,21 +1469,82 @@ H5AC_resize_entry(void *thing, size_t new_size) cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Resize the entry */ - if (H5C_resize_entry(thing, new_size) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry") - #ifdef H5_HAVE_PARALLEL - { + /* Log the generation of dirty bytes of metadata iff: + * + * 1) The entry is clean on entry, and this resize will dirty it + * (i.e. the current and new sizes are different), and + * + * 2) This is a parallel computation -- which it is if the aux_ptr + * is non-null. + * + * A few points to note about this section of the code: + * + * 1) This call must occur before the call to H5C_resize_entry() since + * H5AC__log_dirtied_entry() expects the target entry to be clean + * on entry. + * + * 2) This code has some basic issues in terms of the number of bytes + * added to the dirty bytes count. + * + * First, it adds the initial entry size to aux_ptr->dirty_bytes, + * not the final size. Note that this code used to use the final + * size, but code to support this has been removed from + * H5AC__log_dirtied_entry() for reasons unknown since I wrote this + * code. + * + * As long as all ranks do the same thing here, this probably doesn't + * matter much, although it will delay initiation of sync points. + * + * A more interesting point is that this code will not increment + * aux_ptr->dirty_bytes if a dirty entry is resized. At first glance + * this seems major, as particularly with the older file formats, + * resizes can be quite large. However, this is probably not an + * issue either, since such resizes will be accompanied by large + * amounts of dirty metadata creation in other areas -- which will + * cause aux_ptr->dirty_bytes to be incremented. + * + * The bottom line is that this code is probably OK, but the above + * points should be kept in mind. + * + * One final observation: This comment is occasioned by a bug caused + * by moving the call to H5AC__log_dirtied_entry() after the call to + * H5C_resize_entry(), and then only calling H5AC__log_dirtied_entry() + * if entry_ptr->is_dirty was false. + * + * Since H5C_resize_entry() marks the target entry dirty unless there + * is not change in size, this had the effect of not calling + * H5AC__log_dirtied_entry() when it should be, and corrupting + * the cleaned and dirtied lists used by rank 0 in the parallel + * version of the metadata cache. + * + * The point here is that you should be very careful when working with + * this code, and not modify it unless you fully understand it. + * + * JRM -- 2/28/22 + */ + + if ((!entry_ptr->is_dirty) && (entry_ptr->size != new_size)) { + + /* the entry is clean, and will be marked dirty in the resize + * operation. + */ H5AC_aux_t *aux_ptr; aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if ((!entry_ptr->is_dirty) && (NULL != aux_ptr)) + + if (NULL != aux_ptr) { + if (H5AC__log_dirtied_entry(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") + } } #endif /* H5_HAVE_PARALLEL */ + /* Resize the entry */ + if (H5C_resize_entry(thing, new_size) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry") + done: /* If currently logging, generate a message */ if (cache_ptr != NULL && cache_ptr->log_info != NULL) @@ -1512,7 +1572,7 @@ herr_t H5AC_unpin_entry(void *thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1554,7 +1614,7 @@ herr_t H5AC_destroy_flush_dependency(void *parent_thing, void *child_thing) { H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ - H5C_t * cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1666,9 +1726,14 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, un if (H5AC__log_dirtied_entry((H5AC_info_t *)thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log dirtied entry") - if (deleted && aux_ptr->mpi_rank == 0) - if (H5AC__log_deleted_entry((H5AC_info_t *)thing) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5AC__log_deleted_entry() failed") + if (deleted && aux_ptr->mpi_rank == 0) { + if (H5AC__log_deleted_entry((H5AC_info_t *)thing) < 0) { + /* If we fail to log the deleted entry, push an error but still + * participate in a possible sync point ahead + */ + HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "H5AC__log_deleted_entry() failed") + } + } } /* end if */ #endif /* H5_HAVE_PARALLEL */ @@ -2710,7 +2775,7 @@ herr_t H5AC_remove_entry(void *_entry) { H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ - H5C_t * cache = NULL; /* Pointer to the entry's associated metadata cache */ + H5C_t *cache = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5ACdbg.c b/src/H5ACdbg.c index 2d24adb7bbf..b08eb57f5aa 100644 --- a/src/H5ACdbg.c +++ b/src/H5ACdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -197,11 +196,11 @@ H5AC_get_entry_ptr_from_addr(const H5F_t *f, haddr_t addr, void **entry_ptr_ptr) * If either the parent or the child is not in the metadata * cache, the function sets *fd_exists_ptr to FALSE. * - * If both are in the cache, the childs list of parents is + * If both are in the cache, the child's list of parents is * searched for the proposed parent. If the proposed parent - * is found in the childs parent list, the function sets + * is found in the child's parent list, the function sets * *fd_exists_ptr to TRUE. In all other non-error cases, - * the function sets *fd_exists_ptr FALSE. + * the function sets *fd_exists_ptr to FALSE. * * Return: SUCCEED on success/FAIL on failure. Note that * *fd_exists_ptr is undefined on failure. @@ -299,7 +298,7 @@ H5AC_verify_entry_type(const H5F_t *f, haddr_t addr, const H5AC_class_t *expecte hbool_t H5AC_get_serialization_in_progress(H5F_t *f) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -337,7 +336,7 @@ H5AC_get_serialization_in_progress(H5F_t *f) hbool_t H5AC_cache_is_clean(const H5F_t *f, H5AC_ring_t inner_ring) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5ACmpio.c b/src/H5ACmpio.c index ef85c6d3177..cbd00fc2866 100644 --- a/src/H5ACmpio.c +++ b/src/H5ACmpio.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -75,7 +74,7 @@ typedef struct H5AC_slist_entry_t { /* User data for address list building callbacks */ typedef struct H5AC_addr_list_ud_t { H5AC_aux_t *aux_ptr; /* 'Auxiliary' parallel cache info */ - haddr_t * addr_buf_ptr; /* Array to store addresses */ + haddr_t *addr_buf_ptr; /* Array to store addresses */ unsigned u; /* Counter for position in array */ } H5AC_addr_list_ud_t; @@ -208,7 +207,7 @@ H5AC__set_write_done_callback(H5C_t *cache_ptr, void (*write_done)(void)) herr_t H5AC_add_candidate(H5AC_t *cache_ptr, haddr_t addr) { - H5AC_aux_t * aux_ptr; + H5AC_aux_t *aux_ptr; H5AC_slist_entry_t *slist_entry_ptr = NULL; herr_t ret_value = SUCCEED; /* Return value */ @@ -269,7 +268,7 @@ static herr_t H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr) { H5AC_aux_t *aux_ptr = NULL; - haddr_t * haddr_buf_ptr = NULL; + haddr_t *haddr_buf_ptr = NULL; int mpi_result; unsigned num_entries; herr_t ret_value = SUCCEED; /* Return value */ @@ -305,8 +304,10 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, had * are used to receiving from process 0, and also load it * into a buffer for transmission. */ - if (H5AC__copy_candidate_list_to_buffer(cache_ptr, &chk_num_entries, &haddr_buf_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate buffer.") + if (H5AC__copy_candidate_list_to_buffer(cache_ptr, &chk_num_entries, &haddr_buf_ptr) < 0) { + /* Push an error, but still participate in following MPI_Bcast */ + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate buffer.") + } HDassert(chk_num_entries == num_entries); HDassert(haddr_buf_ptr != NULL); @@ -348,7 +349,7 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, unsigned *num_entries_ptr, had static herr_t H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5AC_slist_entry_t * slist_entry_ptr = (H5AC_slist_entry_t *)_item; /* Address of item */ + H5AC_slist_entry_t *slist_entry_ptr = (H5AC_slist_entry_t *)_item; /* Address of item */ H5AC_addr_list_ud_t *udata = (H5AC_addr_list_ud_t *)_udata; /* Context for callback */ haddr_t addr; @@ -399,7 +400,7 @@ H5AC__broadcast_clean_list_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_uda static herr_t H5AC__broadcast_clean_list(H5AC_t *cache_ptr) { - haddr_t * addr_buf_ptr = NULL; + haddr_t *addr_buf_ptr = NULL; H5AC_aux_t *aux_ptr; int mpi_result; unsigned num_entries = 0; @@ -429,18 +430,23 @@ H5AC__broadcast_clean_list(H5AC_t *cache_ptr) /* allocate a buffer to store the list of entry base addresses in */ buf_size = sizeof(haddr_t) * num_entries; - if (NULL == (addr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for addr buffer") - - /* Set up user data for callback */ - udata.aux_ptr = aux_ptr; - udata.addr_buf_ptr = addr_buf_ptr; - udata.u = 0; - - /* Free all the clean list entries, building the address list in the callback */ - /* (Callback also removes the matching entries from the dirtied list) */ - if (H5SL_free(aux_ptr->c_slist_ptr, H5AC__broadcast_clean_list_cb, &udata) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "Can't build address list for clean entries") + if (NULL == (addr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) { + /* Push an error, but still participate in following MPI_Bcast */ + HDONE_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for addr buffer") + } + else { + /* Set up user data for callback */ + udata.aux_ptr = aux_ptr; + udata.addr_buf_ptr = addr_buf_ptr; + udata.u = 0; + + /* Free all the clean list entries, building the address list in the callback */ + /* (Callback also removes the matching entries from the dirtied list) */ + if (H5SL_free(aux_ptr->c_slist_ptr, H5AC__broadcast_clean_list_cb, &udata) < 0) { + /* Push an error, but still participate in following MPI_Bcast */ + HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "Can't build address list for clean entries") + } + } /* Now broadcast the list of cleaned entries */ if (MPI_SUCCESS != @@ -540,7 +546,7 @@ H5AC__construct_candidate_list(H5AC_t *cache_ptr, H5AC_aux_t H5_ATTR_NDEBUG_UNUS static herr_t H5AC__copy_candidate_list_to_buffer_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5AC_slist_entry_t * slist_entry_ptr = (H5AC_slist_entry_t *)_item; /* Address of item */ + H5AC_slist_entry_t *slist_entry_ptr = (H5AC_slist_entry_t *)_item; /* Address of item */ H5AC_addr_list_ud_t *udata = (H5AC_addr_list_ud_t *)_udata; /* Context for callback */ FUNC_ENTER_STATIC_NOERR @@ -594,9 +600,9 @@ static herr_t H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, haddr_t **haddr_buf_ptr_ptr) { - H5AC_aux_t * aux_ptr = NULL; + H5AC_aux_t *aux_ptr = NULL; H5AC_addr_list_ud_t udata; - haddr_t * haddr_buf_ptr = NULL; + haddr_t *haddr_buf_ptr = NULL; size_t buf_size; unsigned num_entries = 0; herr_t ret_value = SUCCEED; /* Return value */ @@ -668,8 +674,8 @@ H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, unsigned *num_entri herr_t H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; - H5AC_aux_t * aux_ptr; + H5AC_t *cache_ptr; + H5AC_aux_t *aux_ptr; H5AC_slist_entry_t *slist_entry_ptr = NULL; haddr_t addr; @@ -722,7 +728,7 @@ H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr) herr_t H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; herr_t ret_value = SUCCEED; /* Return value */ @@ -800,7 +806,7 @@ H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) herr_t H5AC__log_cleaned_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; FUNC_ENTER_PACKAGE_NOERR @@ -863,7 +869,7 @@ herr_t H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, unsigned flags) { hbool_t cleared; - H5AC_aux_t * aux_ptr; + H5AC_aux_t *aux_ptr; H5AC_slist_entry_t *slist_entry_ptr = NULL; herr_t ret_value = SUCCEED; /* Return value */ @@ -930,7 +936,7 @@ H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, unsig herr_t H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; herr_t ret_value = SUCCEED; /* Return value */ @@ -1013,7 +1019,7 @@ H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) * dirty bytes count. * * The rank 0 process then removes any references to the - * entry under its old address from the cleands and dirtied + * entry under its old address from the cleaned and dirtied * lists, and inserts an entry in the dirtied list under the * new address. * @@ -1028,7 +1034,7 @@ H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) herr_t H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; hbool_t entry_in_cache; hbool_t entry_dirty; @@ -1133,7 +1139,7 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) * * While the list of candidate cache entries is prepared * elsewhere, this function is the main routine for distributing - * and applying the list. It must be run simultaniously on + * and applying the list. It must be run simultaneously on * all processes that have the relevant file open. To ensure * proper synchronization, there is a barrier at the beginning * of this function. @@ -1208,9 +1214,9 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) static herr_t H5AC__propagate_and_apply_candidate_list(H5F_t *f) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; - haddr_t * candidates_list_ptr = NULL; + haddr_t *candidates_list_ptr = NULL; int mpi_result; unsigned num_candidates = 0; herr_t ret_value = SUCCEED; /* Return value */ @@ -1312,7 +1318,7 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) * * This function is the main routine for handling this * notification procedure. It must be called - * simultaniously on all processes that have the relevant + * simultaneously on all processes that have the relevant * file open. To this end, it is called only during a * sync point, with a barrier prior to the call. * @@ -1374,7 +1380,7 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f) static herr_t H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; herr_t ret_value = SUCCEED; /* Return value */ @@ -1449,8 +1455,10 @@ H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, haddr_t * /* allocate buffers to store the list of entry base addresses in */ buf_size = sizeof(haddr_t) * num_entries; - if (NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for haddr buffer") + if (NULL == (haddr_buf_ptr = (haddr_t *)H5MM_malloc(buf_size))) { + /* Push an error, but still participate in following MPI_Bcast */ + HDONE_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for haddr buffer") + } /* Now receive the list of candidate entries */ if (MPI_SUCCESS != @@ -1493,9 +1501,9 @@ H5AC__receive_haddr_list(MPI_Comm mpi_comm, unsigned *num_entries_ptr, haddr_t * static herr_t H5AC__receive_and_apply_clean_list(H5F_t *f) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; - haddr_t * haddr_buf_ptr = NULL; + haddr_t *haddr_buf_ptr = NULL; unsigned num_entries = 0; herr_t ret_value = SUCCEED; /* Return value */ @@ -1633,9 +1641,9 @@ H5AC__receive_candidate_list(const H5AC_t *cache_ptr, unsigned *num_entries_ptr, static herr_t H5AC__rsp__dist_md_write__flush(H5F_t *f) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; - haddr_t * haddr_buf_ptr = NULL; + haddr_t *haddr_buf_ptr = NULL; int mpi_result; unsigned num_entries = 0; herr_t ret_value = SUCCEED; /* Return value */ @@ -1779,7 +1787,7 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f) static herr_t H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; hbool_t evictions_enabled; herr_t ret_value = SUCCEED; /* Return value */ @@ -1801,10 +1809,14 @@ H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) if (evictions_enabled) { /* construct candidate list -- process 0 only */ - if (aux_ptr->mpi_rank == 0) + if (aux_ptr->mpi_rank == 0) { + /* If constructing candidate list fails, push an error but still participate + * in collective operations during following candidate list propagation + */ if (H5AC__construct_candidate_list(cache_ptr, aux_ptr, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate list.") + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't construct candidate list.") + } /* propagate and apply candidate list -- all processes */ if (H5AC__propagate_and_apply_candidate_list(f) < 0) @@ -1856,7 +1868,7 @@ H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f) static herr_t H5AC__rsp__p0_only__flush(H5F_t *f) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; int mpi_result; herr_t ret_value = SUCCEED; /* Return value */ @@ -1900,15 +1912,21 @@ H5AC__rsp__p0_only__flush(H5F_t *f) aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if (result < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush.") - - /* this code exists primarily for the test bed -- it allows us to - * enforce POSIX semantics on the server that pretends to be a - * file system in our parallel tests. - */ - if (aux_ptr->write_done) - (aux_ptr->write_done)(); + if (result < 0) { + /* If write operation fails, push an error but still participate + * in collective operations during following cache entry + * propagation + */ + HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush.") + } + else { + /* this code exists primarily for the test bed -- it allows us to + * enforce POSIX semantics on the server that pretends to be a + * file system in our parallel tests. + */ + if (aux_ptr->write_done) + (aux_ptr->write_done)(); + } } /* end if */ /* Propagate cleaned entries to other ranks. */ @@ -1964,7 +1982,7 @@ H5AC__rsp__p0_only__flush(H5F_t *f) static herr_t H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; hbool_t evictions_enabled; herr_t ret_value = SUCCEED; /* Return value */ @@ -2020,15 +2038,21 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) aux_ptr->write_permitted = FALSE; /* Check for error on the write operation */ - if (result < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_flush_to_min_clean() failed.") - - /* this call exists primarily for the test code -- it is used - * to enforce POSIX semantics on the process used to simulate - * reads and writes in t_cache.c. - */ - if (aux_ptr->write_done) - (aux_ptr->write_done)(); + if (result < 0) { + /* If write operation fails, push an error but still participate + * in collective operations during following cache entry + * propagation + */ + HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_flush_to_min_clean() failed.") + } + else { + /* this call exists primarily for the test code -- it is used + * to enforce POSIX semantics on the process used to simulate + * reads and writes in t_cache.c. + */ + if (aux_ptr->write_done) + (aux_ptr->write_done)(); + } } /* end if */ if (H5AC__propagate_flushed_and_still_clean_entries_list(f) < 0) @@ -2073,7 +2097,7 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f) herr_t H5AC__run_sync_point(H5F_t *f, int sync_point_op) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5AC_aux_t *aux_ptr; herr_t ret_value = SUCCEED; /* Return value */ @@ -2094,11 +2118,11 @@ H5AC__run_sync_point(H5F_t *f, int sync_point_op) (sync_point_op == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED)); #if H5AC_DEBUG_DIRTY_BYTES_CREATION - HDfprintf(stdout, "%d:H5AC_propagate...:%u: (u/uu/i/iu/r/ru) = %zu/%u/%zu/%u/%zu/%u\n", aux_ptr->mpi_rank, + HDfprintf(stdout, "%d:H5AC_propagate...:%u: (u/uu/i/iu/m/mu) = %zu/%u/%zu/%u/%zu/%u\n", aux_ptr->mpi_rank, aux_ptr->dirty_bytes_propagations, aux_ptr->unprotect_dirty_bytes, aux_ptr->unprotect_dirty_bytes_updates, aux_ptr->insert_dirty_bytes, - aux_ptr->insert_dirty_bytes_updates, aux_ptr->rename_dirty_bytes, - aux_ptr->rename_dirty_bytes_updates); + aux_ptr->insert_dirty_bytes_updates, aux_ptr->move_dirty_bytes, + aux_ptr->move_dirty_bytes_updates); #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ /* clear collective access flag on half of the entries in the @@ -2162,8 +2186,8 @@ H5AC__run_sync_point(H5F_t *f, int sync_point_op) aux_ptr->unprotect_dirty_bytes_updates = 0; aux_ptr->insert_dirty_bytes = 0; aux_ptr->insert_dirty_bytes_updates = 0; - aux_ptr->rename_dirty_bytes = 0; - aux_ptr->rename_dirty_bytes_updates = 0; + aux_ptr->move_dirty_bytes = 0; + aux_ptr->move_dirty_bytes_updates = 0; #endif /* H5AC_DEBUG_DIRTY_BYTES_CREATION */ done: diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 7da46a05448..5f59c96efad 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -124,7 +123,7 @@ H5FL_EXTERN(H5AC_aux_t); * Maintaining this count is easy for all processes not on process 0 -- * all that is necessary is to add the size of the entry to the total * whenever there is an insertion, a move of a previously clean entry, - * or whever a previously clean entry is marked dirty in an unprotect. + * or wherever a previously clean entry is marked dirty in an unprotect. * * On process 0, we have to be careful not to count dirty bytes twice. * If an entry is marked dirty, flushed, and marked dirty again, all @@ -293,12 +292,12 @@ H5FL_EXTERN(H5AC_aux_t); * dirtied flag set and the entry does not already appear * in the dirty entry list. * - * Entries are added to the dirty entry list whever they cause + * Entries are added to the dirty entry list wherever they cause * the dirty bytes count to be increased. They are removed * when they appear in a clean entries broadcast. Note that * moves must be reflected in the dirty entry list. * - * To reitterate, this field is only used on process 0 -- it + * To reiterate, this field is only used on process 0 -- it * should be NULL on all other processes. * * c_slist_ptr: Pointer to an instance of H5SL_t used to maintain a list @@ -346,7 +345,7 @@ H5FL_EXTERN(H5AC_aux_t); * * The following field supports the metadata cache image feature. * - * p0_image_len: unsiged integer containing the length of the metadata cache + * p0_image_len: unsigned integer containing the length of the metadata cache * image constructed by MPI process 0. This field should be 0 * if the value is unknown, or if cache image is not enabled. * diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 283989da4ef..6beec5d6c27 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -28,7 +27,7 @@ #include "H5ACpublic.h" /*public prototypes */ -/* Pivate headers needed by this header */ +/* Private headers needed by this header */ #include "H5private.h" /* Generic Functions */ #include "H5Cprivate.h" /* Cache */ #include "H5Fprivate.h" /* File access */ @@ -234,27 +233,27 @@ typedef struct H5AC_proxy_entry_t { /* hbool_t evictions_enabled = */ TRUE, \ /* hbool_t set_initial_size = */ TRUE, \ /* size_t initial_size = */ ( 2 * 1024 * 1024), \ - /* double min_clean_fraction = */ 0.3f, \ + /* double min_clean_fraction = */ 0.3, \ /* size_t max_size = */ (32 * 1024 * 1024), \ /* size_t min_size = */ (1 * 1024 * 1024), \ /* long int epoch_length = */ 50000, \ /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, \ - /* double lower_hr_threshold = */ 0.9f, \ - /* double increment = */ 2.0f, \ + /* double lower_hr_threshold = */ 0.9, \ + /* double increment = */ 2.0, \ /* hbool_t apply_max_increment = */ TRUE, \ /* size_t max_increment = */ (4 * 1024 * 1024), \ /* enum H5C_cache_flash_incr_mode */ \ /* flash_incr_mode = */ H5C_flash_incr__add_space, \ - /* double flash_multiple = */ 1.0f, \ - /* double flash_threshold = */ 0.25f, \ + /* double flash_multiple = */ 1.0, \ + /* double flash_threshold = */ 0.25, \ /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold, \ - /* double upper_hr_threshold = */ 0.999f, \ - /* double decrement = */ 0.9f, \ + /* double upper_hr_threshold = */ 0.999, \ + /* double decrement = */ 0.9, \ /* hbool_t apply_max_decrement = */ TRUE, \ /* size_t max_decrement = */ (1 * 1024 * 1024), \ /* int epochs_before_eviction = */ 3, \ /* hbool_t apply_empty_reserve = */ TRUE, \ - /* double empty_reserve = */ 0.1f, \ + /* double empty_reserve = */ 0.1, \ /* size_t dirty_bytes_threshold = */ (256 * 1024), \ /* int metadata_write_strategy = */ \ H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ @@ -270,29 +269,29 @@ typedef struct H5AC_proxy_entry_t { /* hbool_t evictions_enabled = */ TRUE, \ /* hbool_t set_initial_size = */ TRUE, \ /* size_t initial_size = */ ( 2 * 1024 * 1024), \ - /* double min_clean_fraction = */ 0.01f, \ + /* double min_clean_fraction = */ 0.01, \ /* size_t max_size = */ (32 * 1024 * 1024), \ /* size_t min_size = */ ( 1 * 1024 * 1024), \ /* long int epoch_length = */ 50000, \ /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, \ - /* double lower_hr_threshold = */ 0.9f, \ - /* double increment = */ 2.0f, \ + /* double lower_hr_threshold = */ 0.9, \ + /* double increment = */ 2.0, \ /* hbool_t apply_max_increment = */ TRUE, \ /* size_t max_increment = */ (4 * 1024 * 1024), \ /* enum H5C_cache_flash_incr_mode */ \ /* flash_incr_mode = */ H5C_flash_incr__add_space, \ - /* double flash_multiple = */ 1.4f, \ - /* double flash_threshold = */ 0.25f, \ + /* double flash_multiple = */ 1.4, \ + /* double flash_threshold = */ 0.25, \ /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out_with_threshold,\ - /* double upper_hr_threshold = */ 0.999f, \ - /* double decrement = */ 0.9f, \ + /* double upper_hr_threshold = */ 0.999, \ + /* double decrement = */ 0.9, \ /* hbool_t apply_max_decrement = */ TRUE, \ /* size_t max_decrement = */ (1 * 1024 * 1024), \ /* int epochs_before_eviction = */ 3, \ /* hbool_t apply_empty_reserve = */ TRUE, \ - /* double empty_reserve = */ 0.1f, \ + /* double empty_reserve = */ 0.1, \ /* size_t dirty_bytes_threshold = */ (256 * 1024), \ - /* int metadata_write_strategy = */ \ + /* int metadata_write_strategy = */ \ H5AC__DEFAULT_METADATA_WRITE_STRATEGY \ } #endif /* H5_HAVE_PARALLEL */ @@ -388,7 +387,7 @@ H5_DLL herr_t H5AC_prep_for_file_close(H5F_t *f); H5_DLL herr_t H5AC_prep_for_file_flush(H5F_t *f); H5_DLL herr_t H5AC_secure_from_file_flush(H5F_t *f); H5_DLL herr_t H5AC_create_flush_dependency(void *parent_thing, void *child_thing); -H5_DLL void * H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, unsigned flags); +H5_DLL void *H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, unsigned flags); H5_DLL herr_t H5AC_resize_entry(void *thing, size_t new_size); H5_DLL herr_t H5AC_unpin_entry(void *thing); H5_DLL herr_t H5AC_destroy_flush_dependency(void *parent_thing, void *child_thing); diff --git a/src/H5ACproxy_entry.c b/src/H5ACproxy_entry.c index b3d31b27084..c7dd2453d45 100644 --- a/src/H5ACproxy_entry.c +++ b/src/H5ACproxy_entry.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -245,7 +244,7 @@ H5AC_proxy_entry_remove_parent(H5AC_proxy_entry_t *pentry, void *_parent) static int H5AC__proxy_entry_add_child_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5AC_info_t * parent = (H5AC_info_t *)_item; /* Pointer to the parent entry */ + H5AC_info_t *parent = (H5AC_info_t *)_item; /* Pointer to the parent entry */ H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_udata; /* Pointer to the proxy entry */ int ret_value = H5_ITER_CONT; /* Callback return value */ @@ -338,7 +337,7 @@ H5AC_proxy_entry_add_child(H5AC_proxy_entry_t *pentry, H5F_t *f, void *child) static int H5AC__proxy_entry_remove_child_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5AC_info_t * parent = (H5AC_info_t *)_item; /* Pointer to the parent entry */ + H5AC_info_t *parent = (H5AC_info_t *)_item; /* Pointer to the parent entry */ H5AC_proxy_entry_t *pentry = (H5AC_proxy_entry_t *)_udata; /* Pointer to the proxy entry */ int ret_value = H5_ITER_CONT; /* Callback return value */ diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index f8f4f289c0d..0967f77dc26 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -28,10 +27,6 @@ #include "H5public.h" #include "H5Cpublic.h" -#ifdef __cplusplus -extern "C" { -#endif - /**************************************************************************** * * structure H5AC_cache_config_t @@ -76,7 +71,7 @@ extern "C" { * * *** DEPRECATED *** Use H5Fstart/stop logging functions instead * - * The trace file is a debuging feature that allow the capture of + * The trace file is a debugging feature that allow the capture of * top level metadata cache requests for purposes of debugging and/or * optimization. This field should normally be set to FALSE, as * trace file collection imposes considerable overhead. @@ -123,7 +118,7 @@ extern "C" { * H5C_incr__off ) && ( decr_mode == H5C_decr__off )). There * is no logical reason why this should be so, but it simplifies * implementation and testing, and I can't think of any reason - * why it would be desireable. If you can think of one, I'll + * why it would be desirable. If you can think of one, I'll * revisit the issue. * * set_initial_size: Boolean flag indicating whether the size of the @@ -396,7 +391,7 @@ extern "C" { * * When the sync point is reached (or when there is a user generated * flush), process zero flushes sufficient entries to bring it into - * complience with its min clean size (or flushes all dirty entries in + * compliance with its min clean size (or flushes all dirty entries in * the case of a user generated flush), broad casts the list of * entries just cleaned to all the other processes, and then exits * the sync point. @@ -567,7 +562,7 @@ typedef struct H5AC_cache_config_t { * The value must lie in the interval [0.0, 1.0]. 0.01 is a good place to * start in the serial case. In the parallel case, a larger value is needed * -- see the overview of the metadata cache in the - * “Metadata Caching in HDF5†section of the -- HDF5 User’s Guide + * “Metadata Caching in HDF5†section of the -- \ref UG * for details. */ size_t max_size; @@ -576,7 +571,7 @@ typedef struct H5AC_cache_config_t { size_t min_size; /**< Lower bound (in bytes) on the range of values that the - * adaptive cache resize code can select as the mininum cache * size. */ + * adaptive cache resize code can select as the minimum cache * size. */ long int epoch_length; /**< Number of cache accesses between runs of the adaptive cache resize @@ -708,13 +703,13 @@ typedef struct H5AC_cache_config_t { * of bytes of dirty metadata created since the last synchronization exceeds * this limit.\n This field only applies to the parallel case. While it is * ignored elsewhere, it can still draw a value out of bounds error.\n It - * must be consistant across all caches on any given file.\n By default, + * must be consistent across all caches on any given file.\n By default, * this field is set to 256 KB. It shouldn't be more than half the current * max cache size times the min clean fraction. */ int metadata_write_strategy; /**< Desired metadata write strategy. The valid values for this field - * are:\n #H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: Specifies tha only + * are:\n #H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: Specifies the only * process zero is allowed to write dirty metadata to disk.\n * #H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: Specifies that process zero * still makes the decisions as to what entries should be flushed, but the @@ -764,7 +759,7 @@ typedef struct H5AC_cache_image_config_t { * H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX (100). * * \ref H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE means that no limit is - * imposed on number of times a prefeteched entry can appear in subsequent + * imposed on number of times a prefetched entry can appear in subsequent * cache images. * * A value of 0 prevents prefetched entries from being included in cache @@ -783,7 +778,4 @@ typedef struct H5AC_cache_image_config_t { //! -#ifdef __cplusplus -} -#endif #endif diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 3274dd78534..8db9c3da01c 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -51,11 +50,11 @@ */ typedef struct H5A_fh_ud_cmp_t { /* downward */ - H5F_t * f; /* Pointer to file that fractal heap is in */ - const char * name; /* Name of attribute to compare */ + H5F_t *f; /* Pointer to file that fractal heap is in */ + const char *name; /* Name of attribute to compare */ const H5A_dense_bt2_name_rec_t *record; /* v2 B-tree record for attribute */ H5A_bt2_found_t found_op; /* Callback when correct attribute is found */ - void * found_op_data; /* Callback data when correct attribute is found */ + void *found_op_data; /* Callback data when correct attribute is found */ /* upward */ int cmp; /* Comparison of two attribute names */ @@ -148,7 +147,7 @@ static herr_t H5A__dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata) { H5A_fh_ud_cmp_t *udata = (H5A_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */ - H5A_t * attr = NULL; /* Pointer to attribute created from heap object */ + H5A_t *attr = NULL; /* Pointer to attribute created from heap object */ hbool_t took_ownership = FALSE; /* Whether the "found" operator took ownership of the attribute */ herr_t ret_value = SUCCEED; /* Return value */ @@ -177,7 +176,7 @@ H5A__dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata) } /* end if */ done: - /* Release the space allocated for the attrbute */ + /* Release the space allocated for the attribute */ if (attr && !took_ownership) H5O_msg_free(H5O_ATTR_ID, attr); @@ -200,7 +199,7 @@ H5A__dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata) static herr_t H5A__dense_btree2_name_store(void *_nrecord, const void *_udata) { - const H5A_bt2_ud_ins_t * udata = (const H5A_bt2_ud_ins_t *)_udata; + const H5A_bt2_ud_ins_t *udata = (const H5A_bt2_ud_ins_t *)_udata; H5A_dense_bt2_name_rec_t *nrecord = (H5A_dense_bt2_name_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -231,7 +230,7 @@ H5A__dense_btree2_name_store(void *_nrecord, const void *_udata) static herr_t H5A__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { - const H5A_bt2_ud_common_t * bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; + const H5A_bt2_ud_common_t *bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; const H5A_dense_bt2_name_rec_t *bt2_rec = (const H5A_dense_bt2_name_rec_t *)_bt2_rec; herr_t ret_value = SUCCEED; /* Return value */ @@ -248,7 +247,7 @@ H5A__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int *result = 1; else { H5A_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */ - H5HF_t * fheap; /* Fractal heap handle to use for finding object */ + H5HF_t *fheap; /* Fractal heap handle to use for finding object */ /* Sanity check */ HDassert(bt2_udata->name_hash == bt2_rec->hash); @@ -386,7 +385,7 @@ H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_ static herr_t H5A__dense_btree2_corder_store(void *_nrecord, const void *_udata) { - const H5A_bt2_ud_ins_t * udata = (const H5A_bt2_ud_ins_t *)_udata; + const H5A_bt2_ud_ins_t *udata = (const H5A_bt2_ud_ins_t *)_udata; H5A_dense_bt2_corder_rec_t *nrecord = (H5A_dense_bt2_corder_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -416,7 +415,7 @@ H5A__dense_btree2_corder_store(void *_nrecord, const void *_udata) static herr_t H5A__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { - const H5A_bt2_ud_common_t * bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; + const H5A_bt2_ud_common_t *bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; const H5A_dense_bt2_corder_rec_t *bt2_rec = (const H5A_dense_bt2_corder_rec_t *)_bt2_rec; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Adense.c b/src/H5Adense.c index 1575f3ce7bc..f9daf624e3a 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -68,10 +67,10 @@ */ typedef struct H5A_bt2_od_wrt_t { /* downward */ - H5F_t * f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ H5HF_t *fheap; /* Fractal heap handle to operate on */ H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ - H5A_t * attr; /* Attribute to write */ + H5A_t *attr; /* Attribute to write */ haddr_t corder_bt2_addr; /* v2 B-tree address of creation order index */ } H5A_bt2_od_wrt_t; @@ -81,7 +80,7 @@ typedef struct H5A_bt2_od_wrt_t { */ typedef struct { /* downward (internal) */ - H5F_t * f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ H5HF_t *fheap; /* Fractal heap handle */ H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ hsize_t count; /* # of attributes examined */ @@ -90,7 +89,7 @@ typedef struct { hid_t loc_id; /* Object ID for application callback */ hsize_t skip; /* Number of attributes to skip */ const H5A_attr_iter_op_t *attr_op; /* Callback for each attribute */ - void * op_data; /* Callback data for each attribute */ + void *op_data; /* Callback data for each attribute */ /* upward */ int op_ret; /* Return value from callback */ @@ -103,7 +102,7 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t * f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ const H5A_dense_bt2_name_rec_t *record; /* v2 B-tree record for attribute */ /* upward */ @@ -126,9 +125,9 @@ typedef struct H5A_bt2_ud_rm_t { */ typedef struct H5A_bt2_ud_rmbi_t { /* downward */ - H5F_t * f; /* Pointer to file that fractal heap is in */ - H5HF_t * fheap; /* Fractal heap handle */ - H5HF_t * shared_fheap; /* Fractal heap handle for shared messages */ + H5F_t *f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle */ + H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ H5_index_t idx_type; /* Index type for operation */ haddr_t other_bt2_addr; /* v2 B-tree address of "other" index */ } H5A_bt2_ud_rmbi_t; @@ -170,9 +169,9 @@ H5A__dense_create(H5F_t *f, H5O_ainfo_t *ainfo) { H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for names */ - H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for names */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -334,12 +333,12 @@ H5A_t * H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t attr_sharable; /* Flag indicating attributes are shareable */ htri_t attr_exists; /* Attribute exists in v2 B-tree */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -356,7 +355,7 @@ H5A__dense_open(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't determine if attributes are shared") - /* Get handle for shared message heap, if attributes are sharable */ + /* Get handle for shared message heap, if attributes are shareable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ @@ -421,14 +420,14 @@ herr_t H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) { H5A_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */ - H5HF_t * fheap = NULL; /* Fractal heap handle for attributes */ - H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5WB_t * wb = NULL; /* Wrapped buffer for attribute data */ + H5HF_t *fheap = NULL; /* Fractal heap handle for attributes */ + H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing message */ unsigned mesg_flags = 0; /* Flags for storing message */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + htri_t attr_sharable; /* Flag indicating attributes are shareable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -442,7 +441,7 @@ H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") - /* Get handle for shared message heap, if attributes are sharable */ + /* Get handle for shared message heap, if attributes are shareable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ @@ -487,7 +486,7 @@ H5A__dense_insert(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) udata.id = attr->sh_loc.u.heap_id; } /* end if */ else { - void * attr_ptr; /* Pointer to serialized message */ + void *attr_ptr; /* Pointer to serialized message */ size_t attr_size; /* Size of serialized attribute in the heap */ /* Find out the size of buffer needed for serialized message */ @@ -610,9 +609,9 @@ static herr_t H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) { H5A_dense_bt2_name_rec_t *record = (H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ - H5A_bt2_od_wrt_t * op_data = (H5A_bt2_od_wrt_t *)_op_data; /* "op data" from v2 B-tree modify */ - H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ - H5WB_t * wb = NULL; /* Wrapped buffer for attribute data */ + H5A_bt2_od_wrt_t *op_data = (H5A_bt2_od_wrt_t *)_op_data; /* "op data" from v2 B-tree modify */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ uint8_t attr_buf[H5A_ATTR_BUF_SIZE]; /* Buffer for serializing attribute */ herr_t ret_value = SUCCEED; /* Return value */ @@ -661,7 +660,7 @@ H5A__dense_write_bt2_cb(void *_record, void *_op_data, hbool_t *changed) *changed = TRUE; } /* end if */ else { - void * attr_ptr; /* Pointer to serialized message */ + void *attr_ptr; /* Pointer to serialized message */ size_t attr_size; /* Size of serialized attribute in the heap */ /* Find out the size of buffer needed for serialized attribute */ @@ -723,10 +722,10 @@ H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ H5A_bt2_od_wrt_t op_data; /* "Op data" for v2 B-tree modify */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t attr_sharable; /* Flag indicating attributes are shareable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -742,7 +741,7 @@ H5A__dense_write(H5F_t *f, const H5O_ainfo_t *ainfo, H5A_t *attr) if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") - /* Get handle for shared message heap, if attributes are sharable */ + /* Get handle for shared message heap, if attributes are shareable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ @@ -859,12 +858,12 @@ herr_t H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, const char *new_name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order ndex */ - H5A_t * attr_copy = NULL; /* Copy of attribute to rename */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order ndex */ + H5A_t *attr_copy = NULL; /* Copy of attribute to rename */ + htri_t attr_sharable; /* Flag indicating attributes are shareable */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ htri_t attr_exists; /* Attribute exists in v2 B-tree */ herr_t ret_value = SUCCEED; /* Return value */ @@ -881,7 +880,7 @@ H5A__dense_rename(H5F_t *f, const H5O_ainfo_t *ainfo, const char *old_name, cons if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") - /* Get handle for shared message heap, if attributes are sharable */ + /* Get handle for shared message heap, if attributes are shareable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ @@ -1050,7 +1049,7 @@ H5A__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) --bt2_udata->skip; else { H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ - H5HF_t * fheap; /* Fractal heap handle for attribute storage */ + H5HF_t *fheap; /* Fractal heap handle for attribute storage */ /* Check for iterating over shared attribute */ if (record->flags & H5O_MSG_FLAG_SHARED) @@ -1136,10 +1135,10 @@ H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ herr_t ret_value = FAIL; /* Return value */ @@ -1178,7 +1177,7 @@ H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t /* Check on iteration order */ if (order == H5_ITER_NATIVE && H5F_addr_defined(bt2_addr)) { H5A_bt2_ud_it_t udata; /* User data for iterator callback */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + htri_t attr_sharable; /* Flag indicating attributes are shareable */ /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) @@ -1188,7 +1187,7 @@ H5A__dense_iterate(H5F_t *f, hid_t loc_id, const H5O_ainfo_t *ainfo, H5_index_t if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") - /* Get handle for shared message heap, if attributes are sharable */ + /* Get handle for shared message heap, if attributes are shareable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ @@ -1268,8 +1267,8 @@ static herr_t H5A__dense_remove_bt2_cb(const void *_record, void *_udata) { const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; - H5A_bt2_ud_rm_t * udata = (H5A_bt2_ud_rm_t *)_udata; /* User data for callback */ - H5A_t * attr = *(H5A_t **)udata->common.found_op_data; /* Pointer to attribute to remove */ + H5A_bt2_ud_rm_t *udata = (H5A_bt2_ud_rm_t *)_udata; /* User data for callback */ + H5A_t *attr = *(H5A_t **)udata->common.found_op_data; /* Pointer to attribute to remove */ H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1331,11 +1330,11 @@ herr_t H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { H5A_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - H5A_t * attr_copy = NULL; /* Copy of attribute to remove */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5A_t *attr_copy = NULL; /* Copy of attribute to remove */ + htri_t attr_sharable; /* Flag indicating attributes are shareable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1353,7 +1352,7 @@ H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") - /* Get handle for shared message heap, if attributes are sharable */ + /* Get handle for shared message heap, if attributes are shareable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ @@ -1416,10 +1415,10 @@ H5A__dense_remove(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) static herr_t H5A__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { - H5HF_t * fheap; /* Fractal heap handle */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5HF_t *fheap; /* Fractal heap handle */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; /* v2 B-tree record */ - H5A_bt2_ud_rmbi_t * bt2_udata = (H5A_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */ + H5A_bt2_ud_rmbi_t *bt2_udata = (H5A_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */ H5A_fh_ud_cp_t fh_udata; /* User data for fractal heap 'op' callback */ H5O_shared_t sh_loc; /* Shared message info for attribute */ hbool_t use_sh_loc; /* Whether to use the attribute's shared location or the separate one */ @@ -1543,10 +1542,10 @@ herr_t H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for operation */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1582,7 +1581,7 @@ H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type /* If there is an index defined for the field, use it */ if (H5F_addr_defined(bt2_addr)) { H5A_bt2_ud_rmbi_t udata; /* User data for v2 B-tree record removal */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + htri_t attr_sharable; /* Flag indicating attributes are shareable */ /* Open the fractal heap */ if (NULL == (fheap = H5HF_open(f, ainfo->fheap_addr))) @@ -1592,7 +1591,7 @@ H5A__dense_remove_by_idx(H5F_t *f, const H5O_ainfo_t *ainfo, H5_index_t idx_type if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") - /* Get handle for shared message heap, if attributes are sharable */ + /* Get handle for shared message heap, if attributes are shareable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ @@ -1669,10 +1668,10 @@ htri_t H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) { H5A_bt2_ud_common_t udata; /* User data for v2 B-tree modify */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5HF_t * shared_fheap = NULL; /* Fractal heap handle for shared header messages */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t attr_sharable; /* Flag indicating attributes are sharable */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5HF_t *shared_fheap = NULL; /* Fractal heap handle for shared header messages */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t attr_sharable; /* Flag indicating attributes are shareable */ htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_PACKAGE @@ -1690,7 +1689,7 @@ H5A__dense_exists(H5F_t *f, const H5O_ainfo_t *ainfo, const char *name) if ((attr_sharable = H5SM_type_shared(f, H5O_ATTR_ID)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't determine if attributes are shared") - /* Get handle for shared message heap, if attributes are sharable */ + /* Get handle for shared message heap, if attributes are shareable */ if (attr_sharable) { haddr_t shared_fheap_addr; /* Address of fractal heap to use */ @@ -1755,7 +1754,7 @@ H5A__dense_delete_bt2_cb(const void *_record, void *_bt2_udata) const H5A_dense_bt2_name_rec_t *record = (const H5A_dense_bt2_name_rec_t *)_record; /* Record from B-tree */ H5A_bt2_ud_common_t *bt2_udata = (H5A_bt2_ud_common_t *)_bt2_udata; /* User data for callback */ - H5A_t * attr = NULL; /* Attribute being removed */ + H5A_t *attr = NULL; /* Attribute being removed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1816,7 +1815,7 @@ herr_t H5A__dense_delete(H5F_t *f, H5O_ainfo_t *ainfo) { H5A_bt2_ud_common_t udata; /* v2 B-tree user data for deleting attributes */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index e43706f0ba9..ef84c173c10 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -106,8 +105,8 @@ hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id) { - void * attr = NULL; /* attr object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -180,8 +179,8 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t hid_t H5Aopen_name(hid_t loc_id, const char *name) { - void * attr = NULL; /* attr object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -245,8 +244,8 @@ H5Aopen_name(hid_t loc_id, const char *name) hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { - void * attr = NULL; /* attr object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + void *attr = NULL; /* attr object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -309,7 +308,7 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) int H5Aget_num_attrs(hid_t loc_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5O_info2_t oinfo; int ret_value = -1; @@ -351,7 +350,7 @@ H5Aget_num_attrs(hid_t loc_id) last operator if it was non-zero, or zero if all attributes were processed. DESCRIPTION - This function interates over the attributes of dataset or group + This function iterates over the attributes of dataset or group specified with 'loc_id'. For each attribute of the object, the 'op_data' and some additional information (specified below) are passed to the 'op' function. The iteration begins with the '*attr_number' diff --git a/src/H5Aint.c b/src/H5Aint.c index 0609f24b5c7..e68dfc43f6d 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -53,7 +52,7 @@ /* Data exchange structure to use when building table of compact attributes for an object */ typedef struct { - H5F_t * f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ H5A_attr_table_t *atable; /* Pointer to attribute table to build */ size_t curr_attr; /* Current attribute to operate on */ hbool_t bogus_crt_idx; /* Whether bogus creation index values need to be set */ @@ -68,11 +67,11 @@ typedef struct { /* Data exchange structure to use when copying an attribute from _SRC to _DST */ typedef struct { const H5O_ainfo_t *ainfo; /* dense information */ - H5F_t * file; /* file */ - hbool_t * recompute_size; /* Flag to indicate if size changed */ - H5O_copy_t * cpy_info; /* Information on copying options */ - const H5O_loc_t * oloc_src; - H5O_loc_t * oloc_dst; + H5F_t *file; /* file */ + hbool_t *recompute_size; /* Flag to indicate if size changed */ + H5O_copy_t *cpy_info; /* Information on copying options */ + const H5O_loc_t *oloc_src; + H5O_loc_t *oloc_dst; } H5A_dense_file_cp_ud_t; /********************/ @@ -132,11 +131,11 @@ H5FL_SEQ_DEFINE(H5A_t_ptr); H5A_t * H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type, const H5S_t *space, hid_t acpl_id) { - H5A_t * attr = NULL; /* Attribute created */ + H5A_t *attr = NULL; /* Attribute created */ hssize_t snelmts; /* elements in attribute */ size_t nelmts; /* elements in attribute */ htri_t exists; /* Whether attribute exists */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->oloc->addr) @@ -298,8 +297,8 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - H5A_t * attr = NULL; /* Attribute from object header */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *attr = NULL; /* Attribute from object header */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -458,8 +457,8 @@ H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - H5A_t * attr = NULL; /* Attribute from object header */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *attr = NULL; /* Attribute from object header */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -520,8 +519,8 @@ H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_n H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - H5A_t * attr = NULL; /* Attribute from object header */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *attr = NULL; /* Attribute from object header */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -583,8 +582,8 @@ H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_n herr_t H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) { - uint8_t * tconv_buf = NULL; /* datatype conv buffer*/ - uint8_t * bkg_buf = NULL; /* background buffer */ + uint8_t *tconv_buf = NULL; /* datatype conv buffer*/ + uint8_t *bkg_buf = NULL; /* background buffer */ hssize_t snelmts; /* elements in attribute */ size_t nelmts; /* elements in attribute*/ H5T_path_t *tpath = NULL; /* type conversion info */ @@ -626,6 +625,8 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) /* Check for type conversion required */ if (!H5T_path_noop(tpath)) { + H5T_bkg_t need_bkg; /* Background buffer type */ + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->shared->dt, H5T_COPY_ALL), FALSE)) < 0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL), FALSE)) < 0) @@ -635,12 +636,25 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) buf_size = nelmts * MAX(src_type_size, dst_type_size); if (NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed") - if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) - HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the buffer for conversion */ H5MM_memcpy(tconv_buf, attr->shared->data, (src_type_size * nelmts)); + /* Check if we need a background buffer */ + need_bkg = H5T_path_bkg(tpath); + + if (need_bkg) { + /* Allocate background buffer */ + if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed") + + /* Copy the application buffer into the background buffer if necessary */ + if (need_bkg == H5T_BKG_YES) { + HDassert(buf_size >= (dst_type_size * nelmts)); + H5MM_memcpy(bkg_buf, buf, dst_type_size * nelmts); + } + } + /* Perform datatype conversion. */ if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") @@ -691,9 +705,8 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) herr_t H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) { - uint8_t * tconv_buf = NULL; /* datatype conv buffer */ - hbool_t tconv_owned = FALSE; /* Whether the datatype conv buffer is owned by attribute */ - uint8_t * bkg_buf = NULL; /* temp conversion buffer */ + uint8_t *tconv_buf = NULL; /* datatype conv buffer */ + uint8_t *bkg_buf = NULL; /* temp conversion buffer */ hssize_t snelmts; /* elements in attribute */ size_t nelmts; /* elements in attribute */ H5T_path_t *tpath = NULL; /* conversion information*/ @@ -709,6 +722,10 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) HDassert(mem_type); HDassert(buf); + /* Patch the top level file pointer in attr->shared->dt->shared->u.vlen.f if needed */ + if (H5T_patch_vlen_file(attr->shared->dt, H5F_VOL_OBJ(attr->oloc.file)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "can't patch VL datatype file pointer") + /* Get # of elements for attribute's dataspace */ if ((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") @@ -727,6 +744,8 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) /* Check for type conversion required */ if (!H5T_path_noop(tpath)) { + H5T_bkg_t need_bkg; /* Background buffer type */ + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL), FALSE)) < 0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->shared->dt, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") @@ -735,12 +754,33 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) buf_size = nelmts * MAX(src_type_size, dst_type_size); if (NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size))) HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed") - if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Copy the user's data into the buffer for conversion */ H5MM_memcpy(tconv_buf, buf, (src_type_size * nelmts)); + /* Check if we need a background buffer */ + if (H5T_detect_class(attr->shared->dt, H5T_VLEN, FALSE)) + need_bkg = H5T_BKG_YES; + else + need_bkg = H5T_path_bkg(tpath); + + if (need_bkg) { + /* Use the existing attribute data buffer, if present, as the background buffer, + * otherwise allocate one. Note we don't need to track which one it is since both + * use the "attr_buf" free list block. */ + if (attr->shared->data) { + bkg_buf = attr->shared->data; + attr->shared->data = NULL; + + /* Clear background buffer if it's not supposed to be initialized with file + * contents */ + if (need_bkg == H5T_BKG_TEMP) + HDmemset(bkg_buf, 0, dst_type_size * nelmts); + } + else if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed") + } + /* Perform datatype conversion */ if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") @@ -751,7 +791,7 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) /* Set the pointer to the attribute data to the converted information */ attr->shared->data = tconv_buf; - tconv_owned = TRUE; + tconv_buf = NULL; } /* end if */ /* No type conversion necessary */ else { @@ -777,7 +817,7 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - if (tconv_buf && !tconv_owned) + if (tconv_buf) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); if (bkg_buf) bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf); @@ -1028,9 +1068,9 @@ H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo) H5A_t * H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr) { - H5A_t * new_attr = NULL; + H5A_t *new_attr = NULL; hbool_t allocated_attr = FALSE; /* Whether the attribute was allocated */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1436,11 +1476,12 @@ H5A__compact_build_table(H5F_t *f, H5O_t *oh, H5_index_t idx_type, H5_iter_order atable->nattrs = 0; /* Set up user data for iteration */ - udata.f = f; - udata.atable = atable; - udata.curr_attr = 0; - udata.bogus_crt_idx = (hbool_t)( - (oh->version == H5O_VERSION_1 || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) ? TRUE : FALSE); + udata.f = f; + udata.atable = atable; + udata.curr_attr = 0; + udata.bogus_crt_idx = + (hbool_t)((oh->version == H5O_VERSION_1 || !(oh->flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) ? TRUE + : FALSE); /* Iterate over existing attributes, checking for attribute with same name */ op.op_type = H5O_MESG_OP_LIB; @@ -2015,18 +2056,18 @@ H5A_t * H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t H5_ATTR_NDEBUG_UNUSED *cpy_info) { - H5A_t * attr_dst = NULL; /* Destination attribute */ + H5A_t *attr_dst = NULL; /* Destination attribute */ hid_t tid_src = -1; /* Datatype ID for source datatype */ hid_t tid_dst = -1; /* Datatype ID for destination datatype */ hid_t tid_mem = -1; /* Datatype ID for memory datatype */ - void * buf = NULL; /* Buffer for copying data */ - void * reclaim_buf = NULL; /* Buffer for reclaiming data */ - void * bkg_buf = NULL; /* Background buffer */ + void *buf = NULL; /* Buffer for copying data */ + void *reclaim_buf = NULL; /* Buffer for reclaiming data */ + void *bkg_buf = NULL; /* Background buffer */ hid_t buf_sid = -1; /* ID for buffer dataspace */ hssize_t sdst_nelmts; /* # of elements in destination attribute (signed) */ size_t dst_nelmts; /* # of elements in destination attribute */ size_t dst_dt_size; /* Size of destination attribute datatype */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -2132,11 +2173,11 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s /* Check if we need to convert data */ if (H5T_detect_class(attr_src->shared->dt, H5T_VLEN, FALSE) > 0) { H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */ - H5T_t * dt_mem; /* Memory datatype */ + H5T_t *dt_mem; /* Memory datatype */ size_t src_dt_size; /* Source datatype size */ size_t tmp_dt_size; /* Temp. datatype size */ size_t max_dt_size; /* Max atatype size */ - H5S_t * buf_space; /* Dataspace describing buffer */ + H5S_t *buf_space; /* Dataspace describing buffer */ hsize_t buf_dim; /* Dimension for buffer */ size_t nelmts; /* Number of elements in buffer */ size_t buf_size; /* Size of copy buffer */ @@ -2151,7 +2192,7 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s if ((tid_mem = H5I_register(H5I_DATATYPE, dt_mem, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register memory datatype") - /* create variable-length datatype at the destinaton file */ + /* create variable-length datatype at the destination file */ if ((tid_dst = H5I_register(H5I_DATATYPE, attr_dst->shared->dt, FALSE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register destination file datatype") @@ -2387,7 +2428,7 @@ static herr_t H5A__dense_post_copy_file_cb(const H5A_t *attr_src, void *_udata) { H5A_dense_file_cp_ud_t *udata = (H5A_dense_file_cp_ud_t *)_udata; - H5A_t * attr_dst = NULL; + H5A_t *attr_dst = NULL; herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -2573,7 +2614,7 @@ H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5 hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ hid_t obj_loc_id = H5I_INVALID_HID; /* ID for object located */ H5A_attr_iter_op_t attr_op; /* Attribute operator */ - void * temp_obj = NULL; + void *temp_obj = NULL; H5I_type_t obj_type; herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Amodule.h b/src/H5Amodule.h index c89c93f0d6f..0c31f71fad2 100644 --- a/src/H5Amodule.h +++ b/src/H5Amodule.h @@ -29,41 +29,359 @@ #define H5_MY_PKG_ERR H5E_ATTR #define H5_MY_PKG_INIT YES -/**\defgroup H5A H5A +/** \page H5A_UG HDF5 Attributes * - * Use the functions in this module to manage HDF5 attributes. + * \section sec_attribute HDF5 Attributes * - * The Attribute Interface, H5A, provides a mechanism for attaching additional - * information to a dataset, group, or named datatype. + * An HDF5 attribute is a small metadata object describing the nature and/or intended usage of a primary data + * object. A primary data object may be a dataset, group, or committed datatype. * - * Attributes are accessed by opening the object that they are attached to and - * are not independent objects. Typically an attribute is small in size and - * contains user metadata about the object that it is attached to. + * \subsection subsec_attribute_intro Introduction * - * Attributes look similar to HDF5 datasets in that they have a datatype and - * dataspace. However, they do not support partial I/O operations and cannot be - * compressed or extended. + * Attributes are assumed to be very small as data objects go, so storing them as standard HDF5 datasets would + * be quite inefficient. HDF5 attributes are therefore managed through a special attributes interface, + * \ref H5A, which is designed to easily attach attributes to primary data objects as small datasets + * containing metadata information and to minimize storage requirements. + * + * Consider, as examples of the simplest case, a set of laboratory readings taken under known temperature and + * pressure conditions of 18.0 degrees Celsius and 0.5 atmospheres, respectively. The temperature and pressure + * stored as attributes of the dataset could be described as the following name/value pairs: + * \li temp=18.0 + * \li pressure=0.5 + * + * While HDF5 attributes are not standard HDF5 datasets, they have much in common: + * \li An attribute has a user-defined dataspace and the included metadata has a user-assigned datatype + * \li Metadata can be of any valid HDF5 datatype + * \li Attributes are addressed by name + * + * But there are some very important differences: + * \li There is no provision for special storage such as compression or chunking + * \li There is no partial I/O or sub-setting capability for attribute data + * \li Attributes cannot be shared + * \li Attributes cannot have attributes + * \li Being small, an attribute is stored in the object header of the object it describes and is thus + * attached directly to that object + * + * \subsection subsec_error_H5A Attribute Function Summaries + * @see H5A reference manual + * + * \subsection subsec_attribute_program Programming Model for Attributes + * + * The figure below shows the UML model for an HDF5 attribute and its associated dataspace and datatype. + * + * + * + * + *
+ * \image html UML_Attribute.jpg "The UML model for an HDF5 attribute" + *
+ * + * Creating an attribute is similar to creating a dataset. To create an attribute, the application must + * specify the object to which the attribute is attached, the datatype and dataspace of the attribute + * data, and the attribute creation property list. + * + * The following steps are required to create and write an HDF5 attribute: + * \li Obtain the object identifier for the attribute’s primary data object + * \li Define the characteristics of the attribute and specify the attribute creation property list + *
  • Define the datatype
  • + *
  • Define the dataspace
  • + *
  • Specify the attribute creation property list
+ * \li Create the attribute + * \li Write the attribute data (optional) + * \li Close the attribute (and datatype, dataspace, and attribute creation property list, if necessary) + * \li Close the primary data object (if appropriate) + * + * The following steps are required to open and read/write an existing attribute. Since HDF5 attributes + * allow no partial I/O, you need specify only the attribute and the attribute’s memory datatype to read it: + * \li Obtain the object identifier for the attribute’s primary data object + * \li Obtain the attribute’s name or index + * \li Open the attribute + * \li Get attribute dataspace and datatype (optional) + * \li Specify the attribute’s memory type + * \li Read and/or write the attribute data + * \li Close the attribute + * \li Close the primary data object (if appropriate) * * - * + * * * * - * + * * * * * *
CreateRead
CreateUpdate
- * \snippet H5A_examples.c create + * \snippet{lineno} H5A_examples.c create * - * \snippet H5A_examples.c read + * \snippet{lineno} H5A_examples.c update *
UpdateDelete
ReadDelete
- * \snippet H5A_examples.c update + * \snippet{lineno} H5A_examples.c read * - * \snippet H5A_examples.c delete + * \snippet{lineno} H5A_examples.c delete *
* + * \subsection subsec_attribute_work Working with Attributes + * + * \subsubsection subsubsec_attribute_work_struct The Structure of an Attribute + * + * An attribute has two parts: name and value(s). + * + * HDF5 attributes are sometimes discussed as name/value pairs in the form name=value. + * + * An attribute’s name is a null-terminated ASCII or UTF-8 character string. Each attribute attached to an + * object has a unique name. + * + * The value portion of the attribute contains one or more data elements of the same datatype. + * + * HDF5 attributes have all the characteristics of HDF5 datasets except that there is no partial I/O + * capability. In other words, attributes can be written and read only in full with no sub-setting. + * + * \subsubsection subsubsec_attribute_work_create Creating, Writing, and Reading Attributes + * + * If attributes are used in an HDF5 file, these functions will be employed: \ref H5Acreate, \ref H5Awrite, + * and \ref H5Aread. \ref H5Acreate and \ref H5Awrite are used together to place the attribute in the file. If + * an attribute is to be used and is not currently in memory, \ref H5Aread generally comes into play + * usually in concert with one each of the H5Aget_* and H5Aopen_* functions. + * + * To create an attribute, call H5Acreate: + * \code + * hid_t H5Acreate (hid_t loc_id, const char *name, + * hid_t type_id, hid_t space_id, hid_t create_plist, + * hid_t access_plist) + * \endcode + * loc_id identifies the object (dataset, group, or committed datatype) to which the attribute is to be + * attached. name, type_id, space_id, and create_plist convey, respectively, the attribute’s name, datatype, + * dataspace, and attribute creation property list. The attribute’s name must be locally unique: it must be + * unique within the context of the object to which it is attached. + * + * \ref H5Acreate creates the attribute in memory. The attribute does not exist in the file until + * \ref H5Awrite writes it there. + * + * To write or read an attribute, call H5Awrite or H5Aread, respectively: + * \code + * herr_t H5Awrite (hid_t attr_id, hid_t mem_type_id, const void *buf) + * herr_t H5Aread (hid_t attr_id, hid_t mem_type_id, void *buf) + * \endcode + * attr_id identifies the attribute while mem_type_id identifies the in-memory datatype of the attribute data. + * + * \ref H5Awrite writes the attribute data from the buffer buf to the file. \ref H5Aread reads attribute data + * from the file into buf. + * + * The HDF5 Library converts the metadata between the in-memory datatype, mem_type_id, and the in-file + * datatype, defined when the attribute was created, without user intervention. + * + * \subsubsection subsubsec_attribute_work_access Accessing Attributes by Name or Index + * + * Attributes can be accessed by name or index value. The use of an index value makes it possible to iterate + * through all of the attributes associated with a given object. + * + * To access an attribute by its name, use the \ref H5Aopen_by_name function. \ref H5Aopen_by_name returns an + * attribute identifier that can then be used by any function that must access an attribute such as \ref + * H5Aread. Use the function \ref H5Aget_name to determine an attribute’s name. + * + * To access an attribute by its index value, use the \ref H5Aopen_by_idx function. To determine an attribute + * index value when it is not already known, use the H5Oget_info function. \ref H5Aopen_by_idx is generally + * used in the course of opening several attributes for later access. Use \ref H5Aiterate if the intent is to + * perform the same operation on every attribute attached to an object. + * + * \subsubsection subsubsec_attribute_work_info Obtaining Information Regarding an Object’s Attributes + * + * In the course of working with HDF5 attributes, one may need to obtain any of several pieces of information: + * \li An attribute name + * \li The dataspace of an attribute + * \li The datatype of an attribute + * \li The number of attributes attached to an object + * + * To obtain an attribute’s name, call H5Aget_name with an attribute identifier, attr_id: + * \code + * ssize_t H5Aget_name (hid_t attr_id, size_t buf_size, char *buf) + * \endcode + * As with other attribute functions, attr_id identifies the attribute; buf_size defines the size of the + * buffer; and buf is the buffer to which the attribute’s name will be read. + * + * If the length of the attribute name, and hence the value required for buf_size, is unknown, a first call + * to \ref H5Aget_name will return that size. If the value of buf_size used in that first call is too small, + * the name will simply be truncated in buf. A second \ref H5Aget_name call can then be used to retrieve the + * name in an appropriately-sized buffer. + * + * To determine the dataspace or datatype of an attribute, call \ref H5Aget_space or \ref H5Aget_type, + * respectively: \code hid_t H5Aget_space (hid_t attr_id) hid_t H5Aget_type (hid_t attr_id) \endcode \ref + * H5Aget_space returns the dataspace identifier for the attribute attr_id. \ref H5Aget_type returns the + * datatype identifier for the attribute attr_id. + * + * To determine the number of attributes attached to an object, use the \ref H5Oget_info function. The + * function signature is below. \code herr_t H5Oget_info( hid_t object_id, H5O_info_t *object_info ) \endcode + * The number of attributes will be returned in the object_info buffer. This is generally the preferred first + * step in determining attribute index values. If the call returns N, the attributes attached to the object + * object_id have index values of 0 through N-1. + * + * \subsubsection subsubsec_attribute_work_iterate Iterating across an Object’s Attributes + * + * It is sometimes useful to be able to perform the identical operation across all of the attributes attached + * to an object. At the simplest level, you might just want to open each attribute. At a higher level, you + * might wish to perform a rather complex operation on each attribute as you iterate across the set. + * + * To iterate an operation across the attributes attached to an object, one must make a series of calls to + * \ref H5Aiterate + * \code + * herr_t H5Aiterate (hid_t obj_id, H5_index_t index_type, + * H5_iter_order_t order, hsize_t *n, H5A_operator2_t op, + * void *op_data) + * \endcode + * \ref H5Aiterate successively marches across all of the attributes attached to the object specified in + * loc_id, performing the operation(s) specified in op_func with the data specified in op_data on each + * attribute. + * + * When \ref H5Aiterate is called, index contains the index of the attribute to be accessed in this call. When + * \ref H5Aiterate returns, index will contain the index of the next attribute. If the returned index is the + * null pointer, then all attributes have been processed, and the iterative process is complete. + * + * op_func is a user-defined operation that adheres to the \ref H5A_operator_t prototype. This prototype and + * certain requirements imposed on the operator’s behavior are described in the \ref H5Aiterate entry in the + * \ref RM. + * + * op_data is also user-defined to meet the requirements of op_func. Beyond providing a parameter with which + * to pass this data, HDF5 provides no tools for its management and imposes no restrictions. + * + * \subsubsection subsubsec_attribute_work_delete Deleting an Attribute + * + * Once an attribute has outlived its usefulness or is no longer appropriate, it may become necessary to + * delete it. + * + * To delete an attribute, call \ref H5Adelete + * \code + * herr_t H5Adelete (hid_t loc_id, const char *name) + * \endcode + * \ref H5Adelete removes the attribute name from the group, dataset, or committed datatype specified in + * loc_id. + * + * \ref H5Adelete must not be called if there are any open attribute identifiers on the object loc_id. Such a + * call can cause the internal attribute indexes to change; future writes to an open attribute would then + * produce unintended results. + * + * \subsubsection subsubsec_attribute_work_close Closing an Attribute + * + * As is the case with all HDF5 objects, once access to an attribute it is no longer needed, that attribute + * must be closed. It is best practice to close it as soon as practicable; it is mandatory that it be closed + * prior to the H5close call closing the HDF5 Library. + * + * To close an attribute, call \ref H5Aclose + * \code + * herr_t H5Aclose (hid_t attr_id) + * \endcode + * \ref H5Aclose closes the specified attribute by terminating access to its identifier, attr_id. + * + * \subsection subsec_attribute_special Special Issues + * + * Some special issues for attributes are discussed below. + * + *

Large Numbers of Attributes Stored in Dense Attribute Storage

+ * + * The dense attribute storage scheme was added in version 1.8 so that datasets, groups, and committed + * datatypes that have large numbers of attributes could be processed more quickly. + * + * Attributes start out being stored in an object's header. This is known as compact storage. For more + * information, see "Storage Strategies." + * + * As the number of attributes grows, attribute-related performance slows. To improve performance, dense + * attribute storage can be initiated with the H5Pset_attr_phase_change function. See the HDF5 Reference + * Manual for more information. + * + * When dense attribute storage is enabled, a threshold is defined for the number of attributes kept in + * compact storage. When the number is exceeded, the library moves all of the attributes into dense storage + * at another location. The library handles the movement of attributes and the pointers between the locations + * automatically. If some of the attributes are deleted so that the number falls below the threshold, then + * the attributes are moved back to compact storage by the library. + * + * The improvements in performance from using dense attribute storage are the result of holding attributes + * in a heap and indexing the heap with a B-tree. + * + * Note that there are some disadvantages to using dense attribute storage. One is that this is a new feature. + * Datasets, groups, and committed datatypes that use dense storage cannot be read by applications built with + * earlier versions of the library. Another disadvantage is that attributes in dense storage cannot be + * compressed. + * + *

Large Attributes Stored in Dense Attribute Storage

+ * + * We generally consider the maximum size of an attribute to be 64K bytes. The library has two ways of storing + * attributes larger than 64K bytes: in dense attribute storage or in a separate dataset. Using dense + * attribute storage is described in this section, and storing in a separate dataset is described in the next + * section. + * + * To use dense attribute storage to store large attributes, set the number of attributes that will be stored + * in compact storage to 0 with the H5Pset_attr_phase_change function. This will force all attributes to be + * put into dense attribute storage and will avoid the 64KB size limitation for a single attribute in compact + * attribute storage. + * + * The example code below illustrates how to create a large attribute that will be kept in dense storage. + * + * + * + * + * + * + *
Create
+ * \snippet{lineno} H5A_examples.c create + *
+ * + *

Large Attributes Stored in a Separate Dataset

+ * + * In addition to dense attribute storage (see above), a large attribute can be stored in a separate dataset. + * In the figure below, DatasetA holds an attribute that is too large for the object header in Dataset1. By + * putting a pointer to DatasetA as an attribute in Dataset1, the attribute becomes available to those + * working with Dataset1. + * This way of handling large attributes can be used in situations where backward compatibility is important + * and where compression is important. Applications built with versions before 1.8.x can read large + * attributes stored in separate datasets. Datasets can be compressed while attributes cannot. + * + * + * + * + *
+ * \image html Shared_Attribute.jpg "A large or shared HDF5 attribute and its associated dataset(s)" + *
+ * Note: In the figure above, DatasetA is an attribute of Dataset1 that is too large to store in Dataset1's + * header. DatasetA is associated with Dataset1 by means of an object reference pointer attached as an + * attribute to Dataset1. The attribute in DatasetA can be shared among multiple datasets by means of + * additional object reference pointers attached to additional datasets. + * + *

Shared Attributes

+ * + * Attributes written and managed through the \ref H5A interface cannot be shared. If shared attributes are + * required, they must be handled in the manner described above for large attributes and illustrated in + * the figure above. + * + *

Attribute Names

+ * + * While any ASCII or UTF-8 character may be used in the name given to an attribute, it is usually wise + * to avoid the following kinds of characters: + * \li Commonly used separators or delimiters such as slash, backslash, colon, and semi-colon (\, /, :, ;) + * \li Escape characters + * \li Wild cards such as asterisk and question mark (*, ?) + * NULL can be used within a name, but HDF5 names are terminated with a NULL: whatever comes after the NULL + * will be ignored by HDF5. + * + * The use of ASCII or UTF-8 characters is determined by the character encoding property. See + * #H5Pset_char_encoding in the \ref RM. + * + *

No Special I/O or Storage

+ * + * HDF5 attributes have all the characteristics of HDF5 datasets except the following: + * \li Attributes are written and read only in full: there is no provision for partial I/O or sub-setting + * \li No special storage capability is provided for attributes: there is no compression or chunking, and + * attributes are not extendable + * + * Previous Chapter \ref sec_dataspace - Next Chapter \ref sec_error + * + * \defgroup H5A Attributes (H5A) + * + * An HDF5 attribute is a small metadata object describing the nature and/or intended usage of a primary data + * object. A primary data object may be a dataset, group, or committed datatype. + * + * @see sec_attribute + * */ #endif /* H5Amodule_H */ diff --git a/src/H5Apkg.h b/src/H5Apkg.h index 48adeef24d2..54c866291e8 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -72,7 +71,7 @@ typedef struct H5A_shared_t { uint8_t version; /* Version to encode attribute with */ - char * name; /* Attribute's name */ + char *name; /* Attribute's name */ H5T_cset_t encoding; /* Character encoding of attribute name */ H5T_t *dt; /* Attribute's datatype */ @@ -81,7 +80,7 @@ typedef struct H5A_shared_t { H5S_t *ds; /* Attribute's dataspace */ size_t ds_size; /* Size of dataspace on disk */ - void * data; /* Attribute data (on a temporary basis) */ + void *data; /* Attribute data (on a temporary basis) */ size_t data_size; /* Size of data on disk */ H5O_msg_crt_idx_t crt_idx; /* Attribute's creation index in the object header */ unsigned nrefs; /* Ref count for times this object is referred */ @@ -126,15 +125,15 @@ typedef herr_t (*H5A_bt2_found_t)(const H5A_t *attr, hbool_t *took_ownership, vo */ typedef struct H5A_bt2_ud_common_t { /* downward */ - H5F_t * f; /* Pointer to file that fractal heap is in */ - H5HF_t * fheap; /* Fractal heap handle */ - H5HF_t * shared_fheap; /* Fractal heap handle for shared messages */ - const char * name; /* Name of attribute to compare */ + H5F_t *f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle */ + H5HF_t *shared_fheap; /* Fractal heap handle for shared messages */ + const char *name; /* Name of attribute to compare */ uint32_t name_hash; /* Hash of name of attribute to compare */ uint8_t flags; /* Flags for attribute storage location */ H5O_msg_crt_idx_t corder; /* Creation order value of attribute to compare */ H5A_bt2_found_t found_op; /* Callback when correct attribute is found */ - void * found_op_data; /* Callback data when correct attribute is found */ + void *found_op_data; /* Callback data when correct attribute is found */ } H5A_bt2_ud_common_t; /* diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h index 3ed0239d5bc..33f0134004f 100644 --- a/src/H5Aprivate.h +++ b/src/H5Aprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -71,11 +70,11 @@ typedef struct H5A_attr_iter_op_t { /* General attribute routines */ H5_DLL herr_t H5A_init(void); H5_DLL struct H5O_loc_t *H5A_oloc(H5A_t *attr); -H5_DLL H5G_name_t *H5A_nameof(H5A_t *attr); -H5_DLL H5T_t *H5A_type(const H5A_t *attr); -H5_DLL hid_t H5A_get_space(H5A_t *attr); -H5_DLL herr_t H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, - H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, - const H5A_attr_iter_op_t *attr_op, void *op_data); +H5_DLL H5G_name_t *H5A_nameof(H5A_t *attr); +H5_DLL H5T_t *H5A_type(const H5A_t *attr); +H5_DLL hid_t H5A_get_space(H5A_t *attr); +H5_DLL herr_t H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, + H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, + const H5A_attr_iter_op_t *attr_op, void *op_data); #endif /* H5Aprivate_H */ diff --git a/src/H5Apublic.h b/src/H5Apublic.h index 01986683b77..09b969bd5af 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -78,11 +77,11 @@ extern "C" { * * \return \herr_t * - * \details H5Aclose() terminates access to the attribute specified by - * \p attr_id by releasing the identifier. + * \details H5Aclose() terminates access to the attribute through + * \p attr_id and releases the identifier. * - * \attention Further use of a released attribute identifier is illegal; a - * function using such an identifier will generate an error. + * \par Example + * \snippet H5A_examples.c create * * \since 1.0.0 * @@ -110,27 +109,19 @@ H5_DLL herr_t H5Aclose(hid_t attr_id); * The attribute name, \p attr_name, must be unique for the object. * * The attribute is created with the specified datatype and dataspace, - * \p type_id and \p space_id, which are created with the H5T and - * H5S interfaces, respectively. + * \p type_id and \p space_id. * - * If \p type_id is either a fixed-length or variable-length string, - * it is important to set the string length when defining the - * datatype. String datatypes are derived from #H5T_C_S1 (or - * #H5T_FORTRAN_S1 for Fortran), which defaults to 1 character in - * size. See H5Tset_size() and Creating variable-length string - * datatypes. - * - * The access property list is currently unused, but will be used in - * the future. This property list should currently be #H5P_DEFAULT. + * \plist_unused{acpl} * * The attribute identifier returned by this function must be released * with H5Aclose() resource leaks will develop. * - * \note The \p aapl parameter is currently not used; specify #H5P_DEFAULT. - * * \note If \p loc_id is a file identifier, the attribute will be attached * that file’s root group. * + * \par Example + * \snippet H5A_examples.c create + * * \since 1.8.0 * * \see H5Aclose() @@ -160,28 +151,19 @@ H5_DLL hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_ * attached to the object specified by \p loc_id and \p obj_name. * * \p loc_id is a location identifier; \p obj_name is the object - * name relative to \p loc_id. If \p loc_id fully specifies the - * object to which the attribute is to be attached, \p obj_name - * should be '.' (a dot). + * name relative to \p loc_id. * * The attribute name, \p attr_name, must be unique for the object. * * The attribute is created with the specified datatype and - * dataspace, \p type_id and \p space_id, which are created with - * the H5T and H5S interfaces respectively. + * dataspace, \p type_id and \p space_id. * - * The attribute creation and access property lists are currently - * unused, but will be used in the future for optional attribute - * creation and access properties. These property lists should - * currently be #H5P_DEFAULT. + * \plist_unused{aapl} * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to access * the object, \p obj_name. * - * The attribute identifier returned by this function must be - * released with H5close() or resource leaks will develop. - * * \since 1.8.0 * */ @@ -200,10 +182,14 @@ H5_DLL hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *a * * \details H5Adelete() removes the attribute specified by its name, * \p attr_name, from a file, dataset, group, or named datatype. - * This function should not be used when attribute identifiers - * are open on \p loc_id as it may cause the internal indexes of - * the attributes to change and future writes to the open - * attributes to produce incorrect results. + * + * \attention This function should not be used when other attribute identifiers + * are open on \p loc_id. This may cause the internal indexes of + * the attributes to change and future writes to the open + * attributes to produce incorrect results. + * + * \par Example + * \snippet H5A_examples.c delete * * \since 1.0.0 * @@ -230,27 +216,16 @@ H5_DLL herr_t H5Adelete(hid_t loc_id, const char *attr_name); * * The object from which the attribute is to be removed is * specified by a location identifier and name, \p loc_id and - * \p obj_name, respectively. If \p loc_id fully specifies the - * object from which the attribute is to be removed, \p obj_name - * should be '.' (a dot). + * \p obj_name, respectively. * * The attribute to be removed is specified by a position in an - * index, \p n. The type of index is specified by \p idx_type and - * may be #H5_INDEX_NAME, for an alpha-numeric index by name, or - * #H5_INDEX_CRT_ORDER, for an index by creation order. The order - * in which the index is to be traversed is specified by \p order - * and may be #H5_ITER_INC (increment) for top-down iteration, - * #H5_ITER_DEC (decrement) for bottom-up iteration, or - * #H5_ITER_NATIVE, in which case HDF5 will iterate in the - * fastest-available order. For example, if \p idx_type, \p order, + * index, \p n. The type of index is specified by \p idx_type. + * The order in which the index is to be traversed is specified by + * \p order. For example, if \p idx_type, \p order, * and \p n are set to #H5_INDEX_NAME, #H5_ITER_INC, and 5, - * respectively, the fifth attribute by alpha-numeric order of + * respectively, the fifth attribute in lexicographic order of * attribute names will be removed. * - * For a discussion of \p idx_type and \p order, the valid values - * of those parameters, and the use of \p n, see the description - * of H5Aiterate2(). - * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to access * the object, \p obj_name. @@ -278,9 +253,6 @@ H5_DLL herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t id * from an object specified by location and name, \p loc_id and * \p obj_name, respectively. * - * If \p loc_id fully specifies the object from which the - * attribute is to be removed, \p obj_name should be '.' (a dot). - * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to * access the object, \p obj_name. @@ -329,9 +301,7 @@ H5_DLL htri_t H5Aexists(hid_t obj_id, const char *attr_name); * \p loc_id specifies a location in the file containing the object. * \p obj_name is the name of the object to which the attribute is * attached and can be a relative name, relative to \p loc_id, - * or an absolute name, based in the root group of the file. If - * \p loc_id fully specifies the object, \p obj_name should be '.' - * (a dot). + * or an absolute name, based in the root group of the file. * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to access @@ -355,9 +325,6 @@ H5_DLL htri_t H5Aexists_by_name(hid_t obj_id, const char *obj_name, const char * * creation property list associated with the attribute specified * by \p attr_id. * - * The creation property list identifier should be released with - * H5Pclose(). - * * \since 1.8.0 * */ @@ -374,32 +341,9 @@ H5_DLL hid_t H5Aget_create_plist(hid_t attr_id); * \return \herr_t * * \details H5Aget_info() retrieves attribute information, locating the - * attribute with an attribute identifier, \p attr_id, which is - * the identifier returned by H5Aopen() or H5Aopen_by_idx(). The + * attribute with an attribute identifier, \p attr_id. The * attribute information is returned in the \p ainfo struct. * - * The \p ainfo struct is defined as follows: - * \snippet this H5A_info_t_snip - * - * \p corder_valid indicates whether the creation order data is - * valid for this attribute. Note that if creation order is not - * being tracked, no creation order data will be valid. Valid - * values are \c TRUE and \c FALSE. - * - * \p corder is a positive integer containing the creation - * order of the attribute. This value is 0-based, so, for - * example, the third attribute created will have a \p corder - * value of 2. - * - * \p cset indicates the character set used for the attribute’s - * name; valid values are defined in H5Tpublic.h and include - * the following: - * \csets - * This value is set with H5Pset_char_encoding(). - * - * \p data_size indicates the size, in the number of characters, - * of the attribute. - * * \since 1.8.0 * */ @@ -427,16 +371,9 @@ H5_DLL herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/); * The attribute is located by its index position and the attribute * information is returned in the \p ainfo struct. * - * If \p loc_id fully specifies the object to which the attribute - * is attached, \p obj_name should be '.' (a dot). - * * The attribute is located by means of an index type, an index * traversal order, and a position in the index, \p idx_type, - * \p order and \p n, respectively. These parameters and their - * valid values are discussed in the description of H5Aiterate2(). - * - * The \p ainfo struct, which will contain the returned attribute - * information, is described in H5Aget_info(). + * \p order and \p n, respectively. * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to access @@ -454,8 +391,7 @@ H5_DLL herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t * \brief Retrieves attribute information, by attribute name * * \fgdt_loc_id - * - * \param[in] obj_name Name of object to which attribute is attached, + * \param[in] obj_name Name of the object to which an attribute is attached, * relative to location * \param[in] attr_name Attribute name * \param[out] ainfo Struct containing returned attribute information @@ -468,11 +404,6 @@ H5_DLL herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t * location and name, \p loc_id and \p obj_name, respectively. * The attribute information is returned in the \p ainfo struct. * - * If \p loc_id fully specifies the object to which the attribute - * is attached, \p obj_name should be '.' (a dot). - * - * The \p ainfo struct is described in H5Aget_info(). - * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to * access the object, \p obj_name. @@ -503,8 +434,8 @@ H5_DLL herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char * string terminator is stored in the last position of the buffer * to properly terminate the string. * - * If the user only wants to find out the size of this name, the - * values 0 and NULL can be passed in for the parameters + * If the user only wants to retrieve the name length, the + * values 0 and NULL should be passed for the parameters * \p bufsize and \p buf. * * \since 1.0.0 @@ -515,7 +446,7 @@ H5_DLL ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf); /** * \ingroup H5A * - * \brief Gets an attribute name, by attribute index position + * \brief Gets an attribute name by attribute index position * * \fgdt_loc_id * \param[in] obj_name Name of object to which attribute is attached, @@ -536,13 +467,9 @@ H5_DLL ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf); * located by its index position, the size of the name is specified * in \p size, and the attribute name is returned in \p name. * - * If \p loc_id fully specifies the object to which the attribute - * is attached, \p obj_name should be '.' (a dot). - * * The attribute is located by means of an index type, an index * traversal order, and a position in the index, \p idx_type, - * \p order and \p n, respectively. These parameters and their - * valid values are discussed in the description of H5Aiterate2(). + * \p order and \p n, respectively. * * If the attribute name’s size is unknown, the values 0 and NULL * can be passed in for the parameters \p size and \p name. The @@ -582,7 +509,7 @@ H5_DLL hid_t H5Aget_space(hid_t attr_id); /** * \ingroup H5A * - * \brief Returns the amount of storage required for an attribute + * \brief Returns the amount of storage used to store an attribute * * \attr_id * @@ -600,17 +527,16 @@ H5_DLL hsize_t H5Aget_storage_size(hid_t attr_id); /** * \ingroup H5A * - * \brief Gets an attribute datatype + * \brief Gets an attribute's datatype * * \attr_id * * \return \hid_t{datatype} * - * \details H5Aget_type() retrieves a copy of the datatype for an attribute. + * \details H5Aget_type() retrieves a copy of the attribute's datatype. * The datatype is reopened if it is a named type before returning * it to the application. The datatypes returned by this function - * are always read-only. If an error occurs when atomizing the - * return datatype, then the datatype is closed. + * are always read-only. * * The datatype identifier returned from this function must be * released with H5Tclose() or resource leaks will develop. @@ -623,7 +549,7 @@ H5_DLL hid_t H5Aget_type(hid_t attr_id); /** * \ingroup H5A * - * \brief Calls user-defined function for each attribute on an object + * \brief Calls a user-defined function for each attribute on an object * * \fgdt_loc_id * \param[in] idx_type Type of index @@ -650,24 +576,13 @@ H5_DLL hid_t H5Aget_type(hid_t attr_id); * are specified by three parameters: the index type, * \p idx_type; the order in which the index is to be traversed, * \p order; and the attribute’s position in the index, \p idx. - * - * The type of index specified by \p idx_type can be one of the - * following: - * - * \indexes - * - * The order in which the index is to be traversed, as specified - * by \p order, can be one of the following: - * - * \orders - * * The next attribute to be operated on is specified by \p idx, * a position in the index. * * For example, if \p idx_type, \p order, and \p idx are set to * #H5_INDEX_NAME, #H5_ITER_INC, and 5, respectively, the attribute * in question is the fifth attribute from the beginning of the - * alpha-numeric index of attribute names. If \p order were set to + * alphanumeric index of attribute names. If \p order were set to * #H5_ITER_DEC, it would be the fifth attribute from the end of * the index. * @@ -677,11 +592,6 @@ H5_DLL hid_t H5Aget_type(hid_t attr_id); * the value returned identifies the parameter to be operated on * in the next step of the iteration. * - * \p op is a user-defined function whose prototype is defined - * as follows: - * \snippet this H5A_operator2_t_snip - * \click4more - * * \note This function is also available through the H5Aiterate() macro. * * \since 1.8.0 @@ -717,31 +627,17 @@ H5_DLL herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t ord * additional information as defined below, is passed to a * user-defined function, \p op, which operates on that attribute. * - * If \p loc_id fully specifies the object to which these - * attributes are attached, \p obj_name should be '.' (a dot). - * * The order of the iteration and the attributes iterated over * are specified by three parameters: the index type, \p idx_type; * the order in which the index is to be traversed, \p order; * and the attribute’s position in the index, \p idx. - * - * The type of index specified by \p idx_type can be one of the - * following: - * - * \indexes - * - * The order in which the index is to be traversed, as specified - * by \p order, can be one of the following: - * - * \orders - * * The next attribute to be operated on is specified by \p idx, * a position in the index. * * For example, if \p idx_type, \p order, and \p idx are set to * #H5_INDEX_NAME, #H5_ITER_INC, and 5, respectively, the attribute * in question is the fifth attribute from the beginning of the - * alpha-numeric index of attribute names. If \p order were set to + * alphanumeric index of attribute names. If \p order were set to * #H5_ITER_DEC, it would be the fifth attribute from the end of * the index. * @@ -751,25 +647,6 @@ H5_DLL herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t ord * the value returned identifies the parameter to be operated on in * the next step of the iteration. * - * \p op is a user-defined function whose prototype is defined - * as follows: - * \snippet this H5A_operator2_t_snip - * \click4more - * - * Valid return values from an operator and the resulting - * H5Aiterate_by_name() and \p op behavior are as follows: - * - * \li Zero causes the iterator to continue, returning zero when - * all attributes have been processed. - * \li A positive value causes the iterator to immediately return - * that positive value, indicating short-circuit success. - * The iterator can be restarted at the next attribute, as - * indicated by the return value of \p idx. - * \li A negative value causes the iterator to immediately return - * that value, indicating failure. The iterator can be - * restarted at the next attribute, as indicated by the return - * value of \p idx. - * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to access * the object, \p obj_name. @@ -796,8 +673,7 @@ H5_DLL herr_t H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t * \details H5Aopen() opens an existing attribute, \p attr_name, that is * attached to object specified by an object identifier, \p obj_id. * - * The attribute access property list, \p aapl_id, is currently unused - * and should be #H5P_DEFAULT. + * \plist_unused{aapl_id} * * This function, H5Aopen_by_idx() or H5Aopen_by_name() must be called * before the attribute can be accessed for any further purpose, @@ -806,6 +682,9 @@ H5_DLL herr_t H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t * The attribute identifier returned by this function must be released * with H5Aclose() or resource leaks will develop. * + * \par Example + * \snippet H5A_examples.c read + * * \since 1.8.0 * * \see H5Aclose(), H5Acreate() @@ -830,17 +709,13 @@ H5_DLL hid_t H5Aopen(hid_t obj_id, const char *attr_name, hid_t aapl_id); * * \details H5Aopen_by_idx() opens an existing attribute that is attached * to an object specified by location and name, \p loc_id and - * \p obj_name, respectively. If \p loc_id fully specifies the - * object to which the attribute is attached, \p obj_name, should - * be '.' (a dot). + * \p obj_name, respectively. * * The attribute is identified by an index type, an index traversal * order, and a position in the index, \p idx_type, \p order and - * \p n, respectively. These parameters and their valid values are - * discussed in the description of H5Aiterate2(). + * \p n, respectively. * - * The attribute access property list, \p aapl_id, is currently - * unused and should currently be #H5P_DEFAULT. + * \plist_unused{aapl_id} * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to access @@ -879,11 +754,9 @@ H5_DLL hid_t H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_t * * \p loc_id specifies a location from which the target object can * be located and \p obj_name is an object name relative to - * \p loc_id. If \p loc_id fully specifies the object to which the - * attribute is attached, \p obj_name should be '.' (a dot). + * \p loc_id. * - * The attribute access property list, \p aapl_id, is currently - * unused and should currently be #H5P_DEFAULT. + * \plist_unused{aapl_id} * * The link access property list, \p lapl_id, may provide * information regarding the properties of links required to access @@ -920,6 +793,9 @@ H5_DLL hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *att * Datatype conversion takes place at the time of a read or write and * is automatic. * + * \par Example + * \snippet H5A_examples.c read + * * \version 1.8.8 Fortran updated to Fortran2003. * \version 1.4.2 The \p dims parameter was added to the Fortran API in this * release. @@ -967,15 +843,12 @@ H5_DLL herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name * attribute's in-memory datatype is specified with \p type_id. * The entire attribute is written from \p buf to the file. * - * If \p type_id is either a fixed-length or variable-length string, - * it is important to set the string length when defining the datatype. - * String datatypes are derived from #H5T_C_S1 (or #H5T_FORTRAN_S1 for - * Fortran codes), which defaults to 1 character in size. - * See H5Tset_size() and Creating variable-length string datatypes. - * * Datatype conversion takes place at the time of a read or write and * is automatic. * + * \par Example + * \snippet H5A_examples.c update + * * \version 1.8.8 Fortran updated to Fortran2003. * \version 1.4.2 Fortran \p dims parameter added in this release * \since 1.0.0 @@ -1057,9 +930,9 @@ typedef herr_t (*H5A_operator1_t)(hid_t location_id /*in*/, const char *attr_nam * * \return \hid_tv{attribute} * - * \note The \p acpl parameters is currently not used; specify #H5P_DEFAULT. + * \deprecation_note{H5Acreate2()} * - * \deprecated Deprecated in favor of H5Acreate2() + * \plist_unused{acpl} * * \details H5Acreate1() creates an attribute, \p name, which is attached * to the object specified by the identifier \p loc_id. @@ -1067,18 +940,7 @@ typedef herr_t (*H5A_operator1_t)(hid_t location_id /*in*/, const char *attr_nam * The attribute name, \p name, must be unique for the object. * * The attribute is created with the specified datatype and dataspace, - * \p type_id and \p space_id, which are created with the H5T and - * H5S interfaces, respectively. - * - * If \p type_id is either a fixed-length or variable-length string, - * it is important to set the string length when defining the - * datatype. String datatypes are derived from #H5T_C_S1 (or - * #H5T_FORTRAN_S1 for Fortran), which defaults to 1 character in - * size. See H5Tset_size() and Creating variable-length string - * datatypes. - * - * The attribute identifier returned by this function must be released - * with H5Aclose() resource leaks will develop. + * \p type_id and \p space_id. * * \since 1.8.0 * @@ -1100,8 +962,7 @@ H5_DLL hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t spa * \return Returns the number of attributes if successful; otherwise returns * a negative value. * - * \deprecated This function is deprecated in favor of the functions - * H5Oget_info(), H5Oget_info_by_name(), and H5Oget_info_by_idx(). + * \deprecation_note{H5Oget_info(), H5Oget_info_by_name(), and H5Oget_info_by_idx()} * * \details H5Aget_num_attrs() returns the number of attributes attached to * the object specified by its identifier, \p loc_id. @@ -1124,8 +985,7 @@ H5_DLL int H5Aget_num_attrs(hid_t loc_id); * * \return \herr_t * - * \deprecated This function is deprecated in favor of the function - * H5Aiterate2(). + * \deprecation_note{H5Aiterate2()} * * \details H5Aiterate1() iterates over the attributes of the object * specified by its identifier, \p loc_id. The object can be a @@ -1137,10 +997,6 @@ H5_DLL int H5Aget_num_attrs(hid_t loc_id); * \p op, is returned in \p idx. If \p idx is the null pointer, * then all attributes are processed. * - * \p op is a user-defined function whose prototype is defined as follows: - * \snippet this H5A_operator1_t_snip - * \click4more - * * \version 1.8.0 The function \p H5Aiterate was renamed to H5Aiterate1() * and deprecated in this release. * \since 1.0.0 @@ -1158,8 +1014,7 @@ H5_DLL herr_t H5Aiterate1(hid_t loc_id, unsigned *idx, H5A_operator1_t op, void * * \return \hid_tv{attribute} * - * \deprecated This function is deprecated in favor of the function - * H5Aopen_by_idx(). + * \deprecation_note{H5Aopen_by_idx()} * * \details H5Aopen_idx() opens an attribute which is attached to the * object specified with \p loc_id . The location object may be @@ -1185,8 +1040,7 @@ H5_DLL hid_t H5Aopen_idx(hid_t loc_id, unsigned idx); * * \return \hid_tv{attribute} * - * \deprecated This function is deprecated in favor of the function - * H5Aopen_by_name(). + * \deprecation_note{H5Aopen_by_name()} * * \details H5Aopen_name() opens an attribute specified by its name, * \p name, which is attached to the object specified with diff --git a/src/H5Atest.c b/src/H5Atest.c index 62d608e1444..09d04cfa8ae 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -113,7 +112,7 @@ H5A__is_shared_test(hid_t attr_id) herr_t H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) { - H5A_t * attr; /* Attribute object for ID */ + H5A_t *attr; /* Attribute object for ID */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5B.c b/src/H5B.c index 55732fa8d6d..a90a2f9ea55 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -130,13 +129,13 @@ /* "user data" for iterating over B-tree (collects B-tree metadata size) */ typedef struct H5B_iter_ud_t { H5B_info_t *bt_info; /* Information about B-tree */ - void * udata; /* Node type's 'udata' for loading & iterator callback */ + void *udata; /* Node type's 'udata' for loading & iterator callback */ } H5B_info_ud_t; /* Convenience struct for the arguments needed to unprotect a b-tree after a * call to H5B__iterate_helper() or H5B__split() */ typedef struct H5B_ins_ud_t { - H5B_t * bt; /* B-tree */ + H5B_t *bt; /* B-tree */ haddr_t addr; /* B-tree address */ unsigned cache_flags; /* Cache flags for H5AC_unprotect() */ } H5B_ins_ud_t; @@ -206,7 +205,7 @@ H5FL_SEQ_DEFINE_STATIC(size_t); herr_t H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p /*out*/) { - H5B_t * bt = NULL; + H5B_t *bt = NULL; H5B_shared_t *shared = NULL; /* Pointer to shared B-tree info */ herr_t ret_value = SUCCEED; @@ -289,9 +288,9 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *addr_p /*out htri_t H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) { - H5B_t * bt = NULL; - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_t *bt = NULL; + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned idx = 0, lt = 0, rt; /* Final, left & right key indices */ int cmp = 1; /* Key comparison value */ @@ -383,7 +382,7 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) static herr_t H5B__split(H5F_t *f, H5B_ins_ud_t *bt_ud, unsigned idx, void *udata, H5B_ins_ud_t *split_bt_ud /*out*/) { - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned nleft, nright; /* Number of keys in left & right halves */ double split_ratios[3]; /* B-tree split ratios */ @@ -548,9 +547,9 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) unsigned level; H5B_ins_ud_t bt_ud = H5B_INS_UD_T_NULL; /* (Old) root node */ H5B_ins_ud_t split_bt_ud = H5B_INS_UD_T_NULL; /* Split B-tree node */ - H5B_t * new_root_bt = NULL; /* New root node */ - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_t *new_root_bt = NULL; /* New root node */ + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ H5B_ins_t my_ins = H5B_INS_ERROR; herr_t ret_value = SUCCEED; @@ -692,7 +691,7 @@ H5B__insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx, haddr_t child, H5 const void *md_key) { H5B_shared_t *shared; /* Pointer to shared B-tree info */ - uint8_t * base; /* Base offset for move */ + uint8_t *base; /* Base offset for move */ FUNC_ENTER_STATIC_NOERR @@ -777,9 +776,9 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, uint8 hbool_t *lt_key_changed, uint8_t *md_key, void *udata, uint8_t *rt_key, hbool_t *rt_key_changed, H5B_ins_ud_t *split_bt_ud /*out*/) { - H5B_t * bt; /* Convenience pointer to B-tree */ - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_t *bt; /* Convenience pointer to B-tree */ + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned lt = 0, idx = 0, rt; /* Left, final & right index values */ int cmp = -1; /* Key comparison value */ @@ -1038,7 +1037,7 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, uint8 } else if (H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) { unsigned *tmp_bt_flags_ptr = NULL; - H5B_t * tmp_bt; + H5B_t *tmp_bt; /* * If this node is full then split it before inserting the new child. @@ -1114,9 +1113,9 @@ H5B__insert_helper(H5F_t *f, H5B_ins_ud_t *bt_ud, const H5B_class_t *type, uint8 static herr_t H5B__iterate_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_operator_t op, void *udata) { - H5B_t * bt = NULL; /* Pointer to current B-tree node */ - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_t *bt = NULL; /* Pointer to current B-tree node */ + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned u; /* Local index variable */ herr_t ret_value = H5_ITER_CONT; /* Return value */ @@ -1227,10 +1226,10 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, u hbool_t *lt_key_changed /*out*/, void *udata, uint8_t *rt_key /*out*/, hbool_t *rt_key_changed /*out*/) { - H5B_t * bt = NULL, *sibling = NULL; + H5B_t *bt = NULL, *sibling = NULL; unsigned bt_flags = H5AC__NO_FLAGS_SET; - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned idx = 0, lt = 0, rt; /* Final, left & right indices */ int cmp = 1; /* Key comparison value */ @@ -1458,7 +1457,7 @@ H5B__remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type, int level, u */ if (type->critical_key == H5B_LEFT) /* Slide the rightmost key down one, overwriting the left key of - * the deleted (righmost) child */ + * the deleted (rightmost) child */ HDmemmove(H5B_NKEY(bt, shared, bt->nchildren - 1), H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey); else { @@ -1598,9 +1597,9 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) herr_t H5B_delete(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) { - H5B_t * bt = NULL; /* B-tree node being operated on */ - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_t *bt = NULL; /* B-tree node being operated on */ + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1775,9 +1774,9 @@ H5B_shared_free(void *_shared) static H5B_t * H5B__copy(const H5B_t *old_bt) { - H5B_t * new_node = NULL; + H5B_t *new_node = NULL; H5B_shared_t *shared; /* Pointer to shared B-tree info */ - H5B_t * ret_value = NULL; /* Return value */ + H5B_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1839,9 +1838,9 @@ H5B__copy(const H5B_t *old_bt) static herr_t H5B__get_info_helper(H5F_t *f, const H5B_class_t *type, haddr_t addr, const H5B_info_ud_t *info_udata) { - H5B_t * bt = NULL; /* Pointer to current B-tree node */ - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_t *bt = NULL; /* Pointer to current B-tree node */ + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned level; /* Node level */ size_t sizeof_rnode; /* Size of raw (disk) node */ @@ -1994,8 +1993,8 @@ H5B_get_info(H5F_t *f, const H5B_class_t *type, haddr_t addr, H5B_info_t *bt_inf htri_t H5B_valid(H5F_t *f, const H5B_class_t *type, haddr_t addr) { - H5B_t * bt = NULL; /* The B-tree */ - H5UC_t * rc_shared; /* Ref-counted shared info */ + H5B_t *bt = NULL; /* The B-tree */ + H5UC_t *rc_shared; /* Ref-counted shared info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ htri_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5B2.c b/src/H5B2.c index 5453387d7d0..5748d3ead23 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -126,10 +125,10 @@ H5FL_DEFINE_STATIC(H5B2_t); H5B2_t * H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) { - H5B2_t * bt2 = NULL; /* Pointer to the B-tree */ + H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ haddr_t hdr_addr; /* B-tree header address */ - H5B2_t * ret_value = NULL; /* Return value */ + H5B2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -197,9 +196,9 @@ H5B2_create(H5F_t *f, const H5B2_create_t *cparam, void *ctx_udata) H5B2_t * H5B2_open(H5F_t *f, haddr_t addr, void *ctx_udata) { - H5B2_t * bt2 = NULL; /* Pointer to the B-tree */ + H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_t * ret_value = NULL; /* Return value */ + H5B2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -302,7 +301,7 @@ H5B2_insert(H5B2_t *bt2, void *udata) herr_t H5B2_update(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) { - H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_update_status_t status = H5B2_UPDATE_UNKNOWN; /* Whether the record was inserted/modified */ herr_t ret_value = SUCCEED; /* Return value */ @@ -455,9 +454,9 @@ H5B2_iterate(H5B2_t *bt2, H5B2_operator_t op, void *op_data) htri_t H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) { - H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void * parent = NULL; /* Parent of current node */ + void *parent = NULL; /* Parent of current node */ uint16_t depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ @@ -704,9 +703,9 @@ H5B2_find(H5B2_t *bt2, void *udata, H5B2_found_t op, void *op_data) herr_t H5B2_index(H5B2_t *bt2, H5_iter_order_t order, hsize_t idx, H5B2_found_t op, void *op_data) { - H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void * parent = NULL; /* Parent of current node */ + void *parent = NULL; /* Parent of current node */ uint16_t depth; /* Current depth of the tree */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1147,9 +1146,9 @@ H5B2_neighbor(H5B2_t *bt2, H5B2_compare_t range, void *udata, H5B2_found_t op, v herr_t H5B2_modify(H5B2_t *bt2, void *udata, H5B2_modify_t op, void *op_data) { - H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void * parent = NULL; /* Parent of current node */ + void *parent = NULL; /* Parent of current node */ H5B2_nodepos_t curr_pos; /* Position of current node */ uint16_t depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ diff --git a/src/H5B2cache.c b/src/H5B2cache.c index e333d61f6fb..dd3e338bac0 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -60,7 +59,7 @@ /* Metadata cache callbacks */ static herr_t H5B2__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void * H5B2__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5B2__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_hdr_image_len(const void *thing, size_t *image_len); static herr_t H5B2__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_hdr_notify(H5AC_notify_action_t action, void *thing); @@ -68,7 +67,7 @@ static herr_t H5B2__cache_hdr_free_icr(void *thing); static herr_t H5B2__cache_int_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_int_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void * H5B2__cache_int_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5B2__cache_int_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_int_image_len(const void *thing, size_t *image_len); static herr_t H5B2__cache_int_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_int_notify(H5AC_notify_action_t action, void *thing); @@ -76,7 +75,7 @@ static herr_t H5B2__cache_int_free_icr(void *thing); static herr_t H5B2__cache_leaf_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5B2__cache_leaf_verify_chksum(const void *image_ptr, size_t len, void *udata); -static void * H5B2__cache_leaf_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5B2__cache_leaf_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B2__cache_leaf_image_len(const void *thing, size_t *image_len); static herr_t H5B2__cache_leaf_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B2__cache_leaf_notify(H5AC_notify_action_t action, void *thing); @@ -230,14 +229,14 @@ static void * H5B2__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5B2_hdr_t * hdr = NULL; /* B-tree header */ + H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_hdr_cache_ud_t *udata = (H5B2_hdr_cache_ud_t *)_udata; H5B2_create_t cparam; /* B-tree creation parameters */ H5B2_subid_t id; /* ID of B-tree class, as found in file */ uint16_t depth; /* Depth of B-tree */ uint32_t stored_chksum; /* Stored metadata checksum value */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5B2_hdr_t * ret_value = NULL; /* Return value */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -356,7 +355,7 @@ static herr_t H5B2__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { H5B2_hdr_t *hdr = (H5B2_hdr_t *)_thing; /* Pointer to the B-tree header */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ FUNC_ENTER_STATIC_NOERR @@ -575,7 +574,7 @@ H5B2__cache_int_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__cache_int_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata) { - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ size_t chk_size; /* Exact size of the node with checksum at the end */ uint32_t stored_chksum; /* Stored metadata checksum value */ @@ -619,13 +618,13 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void hbool_t H5_ATTR_UNUSED *dirty) { H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ - H5B2_internal_t * internal = NULL; /* Internal node read */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t * native; /* Pointer to native record info */ - H5B2_node_ptr_t * int_node_ptr; /* Pointer to node pointer info */ + H5B2_internal_t *internal = NULL; /* Internal node read */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *native; /* Pointer to native record info */ + H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned u; /* Local index variable */ - H5B2_internal_t * ret_value = NULL; /* Return value */ + H5B2_internal_t *ret_value = NULL; /* Return value */ int node_nrec = 0; FUNC_ENTER_STATIC @@ -771,8 +770,8 @@ static herr_t H5B2__cache_int_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { H5B2_internal_t *internal = (H5B2_internal_t *)_thing; /* Pointer to the B-tree internal node */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t * native; /* Pointer to native record info */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *native; /* Pointer to native record info */ H5B2_node_ptr_t *int_node_ptr; /* Pointer to node pointer info */ uint32_t metadata_chksum; /* Computed metadata checksum value */ unsigned u; /* Local index variable */ @@ -994,7 +993,7 @@ H5B2__cache_leaf_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5B2__cache_leaf_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata) { - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ H5B2_internal_cache_ud_t *udata = (H5B2_internal_cache_ud_t *)_udata; /* Pointer to user data */ size_t chk_size; /* Exact size of the node with checksum at the end */ uint32_t stored_chksum; /* Stored metadata checksum value */ @@ -1037,12 +1036,12 @@ H5B2__cache_leaf_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void hbool_t H5_ATTR_UNUSED *dirty) { H5B2_leaf_cache_ud_t *udata = (H5B2_leaf_cache_ud_t *)_udata; - H5B2_leaf_t * leaf = NULL; /* Pointer to lead node loaded */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t * native; /* Pointer to native keys */ + H5B2_leaf_t *leaf = NULL; /* Pointer to lead node loaded */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *native; /* Pointer to native keys */ uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned u; /* Local index variable */ - H5B2_leaf_t * ret_value = NULL; /* Return value */ + H5B2_leaf_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1164,8 +1163,8 @@ H5B2__cache_leaf_serialize(const H5F_t H5_ATTR_UNUSED *f, void *_image, size_t H void *_thing) { H5B2_leaf_t *leaf = (H5B2_leaf_t *)_thing; /* Pointer to the B-tree leaf node */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t * native; /* Pointer to native keys */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *native; /* Pointer to native keys */ uint32_t metadata_chksum; /* Computed metadata checksum value */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 711b2005ec4..8e01898803b 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -159,7 +158,7 @@ herr_t H5B2__int_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, unsigned depth, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { - H5B2_hdr_t * hdr = NULL; /* B-tree header */ + H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_internal_t *internal = NULL; /* B-tree internal node */ H5B2_node_ptr_t node_ptr; /* Fake node pointer for protect */ unsigned u; /* Local index variable */ @@ -260,8 +259,8 @@ herr_t H5B2__leaf_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B2_class_t *type, haddr_t hdr_addr, unsigned nrec, haddr_t H5_ATTR_NDEBUG_UNUSED obj_addr) { - H5B2_hdr_t * hdr = NULL; /* B-tree header */ - H5B2_leaf_t * leaf = NULL; /* B-tree leaf node */ + H5B2_hdr_t *hdr = NULL; /* B-tree header */ + H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ H5B2_node_ptr_t node_ptr; /* Fake node pointer for protect */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index bdde5ba2873..270789f82ce 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -507,8 +506,8 @@ H5B2_hdr_t * H5B2__hdr_protect(H5F_t *f, haddr_t hdr_addr, void *ctx_udata, unsigned flags) { H5B2_hdr_cache_ud_t udata; /* User data for cache callbacks */ - H5B2_hdr_t * hdr = NULL; /* v2 B-tree header */ - H5B2_hdr_t * ret_value = NULL; /* Return value */ + H5B2_hdr_t *hdr = NULL; /* v2 B-tree header */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5B2int.c b/src/H5B2int.c index 610da6c5f05..8b3815bc2c9 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -52,9 +51,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 */ @@ -140,9 +139,9 @@ H5B2__split1(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, { const H5AC_class_t *child_class; /* Pointer to child node's class info */ haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */ - void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ + void *left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */ - uint8_t * left_native, *right_native; /* Pointers to childs' native records */ + uint8_t *left_native, *right_native; /* Pointers to childs' native records */ H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ uint16_t mid_record; /* Index of "middle" record in current node */ @@ -425,9 +424,9 @@ H5B2__redistribute2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, { const H5AC_class_t *child_class; /* Pointer to child node's class info */ haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */ - void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ + void *left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */ - uint8_t * left_native, *right_native; /* Pointers to childs' native records */ + uint8_t *left_native, *right_native; /* Pointers to childs' native records */ H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ hssize_t left_moved_nrec = 0, right_moved_nrec = 0; /* Number of records moved, for internal redistrib */ @@ -697,16 +696,16 @@ H5B2__redistribute3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, { H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ - H5B2_node_ptr_t * middle_node_ptrs = NULL; /* Pointers to childs' node pointer info */ + H5B2_node_ptr_t *middle_node_ptrs = NULL; /* Pointers to childs' node pointer info */ const H5AC_class_t *child_class; /* Pointer to child node's class info */ haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */ haddr_t middle_addr = HADDR_UNDEF; /* Address of middle child node */ - void * left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ - void * middle_child = NULL; /* Pointers to middle child node */ + void *left_child = NULL, *right_child = NULL; /* Pointers to child nodes */ + void *middle_child = NULL; /* Pointers to middle child node */ uint16_t *left_nrec, *right_nrec; /* Pointers to child # of records */ uint16_t *middle_nrec; /* Pointers to middle child # of records */ - uint8_t * left_native, *right_native; /* Pointers to childs' native records */ - uint8_t * middle_native; /* Pointers to middle child's native records */ + uint8_t *left_native, *right_native; /* Pointers to childs' native records */ + uint8_t *middle_native; /* Pointers to middle child's native records */ hssize_t left_moved_nrec = 0, right_moved_nrec = 0; /* Number of records moved, for internal split */ hssize_t middle_moved_nrec = 0; /* Number of records moved, for internal split */ unsigned left_child_flags = H5AC__NO_FLAGS_SET, @@ -1124,9 +1123,9 @@ H5B2__merge2(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, { const H5AC_class_t *child_class; /* Pointer to child node's class info */ haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */ - void * left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */ + void *left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */ uint16_t *left_nrec, *right_nrec; /* Pointers to left & right child # of records */ - uint8_t * left_native, *right_native; /* Pointers to left & right children's native records */ + uint8_t *left_native, *right_native; /* Pointers to left & right children's native records */ H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ unsigned left_child_flags = H5AC__NO_FLAGS_SET, @@ -1300,12 +1299,12 @@ H5B2__merge3(H5B2_hdr_t *hdr, uint16_t depth, H5B2_node_ptr_t *curr_node_ptr, const H5AC_class_t *child_class; /* Pointer to child node's class info */ haddr_t left_addr = HADDR_UNDEF, right_addr = HADDR_UNDEF; /* Addresses of left & right child nodes */ haddr_t middle_addr = HADDR_UNDEF; /* Address of middle child node */ - void * left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */ - void * middle_child = NULL; /* Pointer to middle child node */ + void *left_child = NULL, *right_child = NULL; /* Pointers to left & right child nodes */ + void *middle_child = NULL; /* Pointer to middle child node */ uint16_t *left_nrec, *right_nrec; /* Pointers to left & right child # of records */ uint16_t *middle_nrec; /* Pointer to middle child # of records */ - uint8_t * left_native, *right_native; /* Pointers to left & right children's native records */ - uint8_t * middle_native; /* Pointer to middle child's native records */ + uint8_t *left_native, *right_native; /* Pointers to left & right children's native records */ + uint8_t *middle_native; /* Pointer to middle child's native records */ H5B2_node_ptr_t *left_node_ptrs = NULL, *right_node_ptrs = NULL; /* Pointers to childs' node pointer info */ H5B2_node_ptr_t *middle_node_ptrs = NULL; /* Pointer to child's node pointer info */ @@ -1617,14 +1616,14 @@ H5B2__insert(H5B2_hdr_t *hdr, void *udata) *------------------------------------------------------------------------- */ 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 */ - void * node = NULL; /* Pointers to current node */ - uint8_t * node_native; /* Pointers to node's native records */ - uint8_t * native = NULL; /* Pointers to copy of node's native records */ - H5B2_node_ptr_t * node_ptrs = NULL; /* Pointers to node's node pointers */ + void *node = NULL; /* Pointers to current node */ + uint8_t *node_native; /* Pointers to node's native records */ + uint8_t *native = NULL; /* Pointers to copy of node's native records */ + H5B2_node_ptr_t *node_ptrs = NULL; /* Pointers to node's node pointers */ hbool_t node_pinned = FALSE; /* Whether node is pinned */ unsigned u; /* Local index */ herr_t ret_value = H5_ITER_CONT; /* Iterator return value */ @@ -1642,8 +1641,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,12 +1737,12 @@ H5B2__iterate_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_ *------------------------------------------------------------------------- */ 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 */ - uint8_t * native; /* Pointers to node's native records */ + void *node = NULL; /* Pointers to current node */ + uint8_t *native; /* Pointers to node's native records */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1759,8 +1757,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 +1821,7 @@ H5B2__delete_node(H5B2_hdr_t *hdr, uint16_t depth, const H5B2_node_ptr_t *curr_n *------------------------------------------------------------------------- */ 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 +1836,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,11 +1907,11 @@ H5B2__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) *------------------------------------------------------------------------- */ 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 */ - void * child = NULL; /* Pointer to child node */ + void *child = NULL; /* Pointer to child node */ unsigned node_status = 0; /* Node's status in the metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1933,7 +1930,7 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t /* If the node is in the cache, check for retargeting its parent */ if (node_status & H5AC_ES__IN_CACHE) { - void ** parent_ptr = NULL; /* Pointer to child node's parent */ + void **parent_ptr = NULL; /* Pointer to child node's parent */ hbool_t update_deps = FALSE; /* Whether to update flush dependencies */ /* Get child node pointer */ @@ -1941,9 +1938,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 +2006,7 @@ H5B2__update_flush_depend(H5B2_hdr_t *hdr, unsigned depth, const H5B2_node_ptr_t *------------------------------------------------------------------------- */ 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/H5B2internal.c b/src/H5B2internal.c index c00f555dfd4..6a0258139e9 100644 --- a/src/H5B2internal.c +++ b/src/H5B2internal.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -17,7 +16,7 @@ * Dec 01 2016 * Quincey Koziol * - * Purpose: Routines for managing v2 B-tree internal ndoes. + * Purpose: Routines for managing v2 B-tree internal nodes. * *------------------------------------------------------------------------- */ @@ -185,8 +184,8 @@ H5B2__protect_internal(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, hbool_t shadow, unsigned flags) { H5B2_internal_cache_ud_t udata; /* User data to pass through to cache 'deserialize' callback */ - H5B2_internal_t * internal = NULL; /* v2 B-tree internal node */ - H5B2_internal_t * ret_value = NULL; /* Return value */ + H5B2_internal_t *internal = NULL; /* v2 B-tree internal node */ + H5B2_internal_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -806,8 +805,8 @@ H5B2__remove_internal(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, H5B2_nodepos_t curr_pos, H5B2_node_ptr_t *curr_node_ptr, void *udata, H5B2_remove_t op, void *op_data) { - H5AC_info_t * new_cache_info; /* Pointer to new cache info */ - unsigned * new_cache_info_flags_ptr = NULL; + H5AC_info_t *new_cache_info; /* Pointer to new cache info */ + unsigned *new_cache_info_flags_ptr = NULL; H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */ H5B2_internal_t *internal; /* Pointer to internal node */ H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of next node */ @@ -1050,8 +1049,8 @@ H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *sw unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, hsize_t n, H5B2_remove_t op, void *op_data) { - H5AC_info_t * new_cache_info; /* Pointer to new cache info */ - unsigned * new_cache_info_flags_ptr = NULL; + H5AC_info_t *new_cache_info; /* Pointer to new cache info */ + unsigned *new_cache_info_flags_ptr = NULL; H5B2_node_ptr_t *new_node_ptr; /* Pointer to new node pointer */ H5B2_internal_t *internal; /* Pointer to internal node */ H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of next node */ diff --git a/src/H5B2leaf.c b/src/H5B2leaf.c index 20ace84051b..e31fed4a065 100644 --- a/src/H5B2leaf.c +++ b/src/H5B2leaf.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -17,7 +16,7 @@ * Dec 01 2016 * Quincey Koziol * - * Purpose: Routines for managing v2 B-tree leaf ndoes. + * Purpose: Routines for managing v2 B-tree leaf nodes. * *------------------------------------------------------------------------- */ @@ -173,8 +172,8 @@ H5B2_leaf_t * H5B2__protect_leaf(H5B2_hdr_t *hdr, void *parent, H5B2_node_ptr_t *node_ptr, hbool_t shadow, unsigned flags) { H5B2_leaf_cache_ud_t udata; /* User-data for callback */ - H5B2_leaf_t * leaf; /* v2 B-tree leaf node */ - H5B2_leaf_t * ret_value = NULL; /* Return value */ + H5B2_leaf_t *leaf; /* v2 B-tree leaf node */ + H5B2_leaf_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -609,8 +608,8 @@ H5B2__swap_leaf(H5B2_hdr_t *hdr, uint16_t depth, H5B2_internal_t *internal, unsi { const H5AC_class_t *child_class; /* Pointer to child node's class info */ haddr_t child_addr = HADDR_UNDEF; /* Address of child node */ - void * child = NULL; /* Pointer to child node */ - uint8_t * child_native; /* Pointer to child's native records */ + void *child = NULL; /* Pointer to child node */ + uint8_t *child_native; /* Pointer to child's native records */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index 8d620cc890d..626ae2f9350 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -160,7 +159,7 @@ typedef struct H5B2_hdr_t { uint8_t max_nrec_size; /* Size to store max. # of records in any node (in bytes) */ /* Shared internal data structures (not stored) */ - H5F_t * f; /* Pointer to the file that the B-tree is in */ + H5F_t *f; /* Pointer to the file that the B-tree is in */ haddr_t addr; /* Address of B-tree header in the file */ size_t hdr_size; /* Size of the B-tree header on disk */ size_t rc; /* Reference count of nodes using this header */ @@ -169,17 +168,17 @@ typedef struct H5B2_hdr_t { uint8_t sizeof_size; /* Size of file sizes */ uint8_t sizeof_addr; /* Size of file addresses */ H5B2_remove_t remove_op; /* Callback operator for deleting B-tree */ - void * remove_op_data; /* B-tree deletion callback's context */ - uint8_t * page; /* Common disk page for I/O */ - size_t * nat_off; /* Array of offsets of native records */ + void *remove_op_data; /* B-tree deletion callback's context */ + uint8_t *page; /* Common disk page for I/O */ + size_t *nat_off; /* Array of offsets of native records */ H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */ - void * min_native_rec; /* Pointer to minimum native record */ - void * max_native_rec; /* Pointer to maximum native record */ + void *min_native_rec; /* Pointer to minimum native record */ + void *max_native_rec; /* Pointer to maximum native record */ /* SWMR / Flush dependency information (not stored) */ hbool_t swmr_write; /* Whether we are doing SWMR writes */ H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ - void * parent; /* Pointer to 'top' proxy flush dependency + void *parent; /* Pointer to 'top' proxy flush dependency * parent, if it exists, otherwise NULL. * If the v2 B-tree is being used to index a * chunked dataset and the dataset metadata is @@ -198,7 +197,7 @@ typedef struct H5B2_hdr_t { /* Client information (not stored) */ const H5B2_class_t *cls; /* Class of B-tree client */ - void * cb_ctx; /* Client callback context */ + void *cb_ctx; /* Client callback context */ } H5B2_hdr_t; /* B-tree leaf node information */ @@ -208,12 +207,12 @@ typedef struct H5B2_leaf_t { /* Internal B-tree information */ H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ - uint8_t * leaf_native; /* Pointer to native records */ + uint8_t *leaf_native; /* Pointer to native records */ uint16_t nrec; /* Number of records in node */ /* SWMR / Flush dependency information (not stored) */ H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ - void * parent; /* Flush dependency parent for leaf */ + void *parent; /* Flush dependency parent for leaf */ uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ } H5B2_leaf_t; @@ -223,22 +222,22 @@ typedef struct H5B2_internal_t { H5AC_info_t cache_info; /* Internal B-tree information */ - H5B2_hdr_t * hdr; /* Pointer to the [pinned] v2 B-tree header */ - uint8_t * int_native; /* Pointer to native records */ + H5B2_hdr_t *hdr; /* Pointer to the [pinned] v2 B-tree header */ + uint8_t *int_native; /* Pointer to native records */ H5B2_node_ptr_t *node_ptrs; /* Pointer to node pointers */ uint16_t nrec; /* Number of records in node */ uint16_t depth; /* Depth of this node in the B-tree */ /* SWMR / Flush dependency information (not stored) */ H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all B-tree entries */ - void * parent; /* Flush dependency parent for internal node */ + void *parent; /* Flush dependency parent for internal node */ uint64_t shadow_epoch; /* Epoch of node, for making shadow copies */ } H5B2_internal_t; /* v2 B-tree */ struct H5B2_t { H5B2_hdr_t *hdr; /* Pointer to internal v2 B-tree header info */ - H5F_t * f; /* Pointer to file for v2 B-tree */ + H5F_t *f; /* Pointer to file for v2 B-tree */ }; /* Node position, for min/max determination */ @@ -260,25 +259,25 @@ typedef enum H5B2_update_status_t { /* Callback info for loading a v2 B-tree header into the cache */ typedef struct H5B2_hdr_cache_ud_t { - H5F_t * f; /* File that v2 b-tree header is within */ + H5F_t *f; /* File that v2 b-tree header is within */ haddr_t addr; /* Address of B-tree header in the file */ - void * ctx_udata; /* User-data for protecting */ + void *ctx_udata; /* User-data for protecting */ } H5B2_hdr_cache_ud_t; /* Callback info for loading a v2 B-tree internal node into the cache */ typedef struct H5B2_internal_cache_ud_t { - H5F_t * f; /* File that v2 b-tree header is within */ + H5F_t *f; /* File that v2 b-tree header is within */ H5B2_hdr_t *hdr; /* v2 B-tree header */ - void * parent; /* Flush dependency parent */ + void *parent; /* Flush dependency parent */ uint16_t nrec; /* Number of records in node to load */ uint16_t depth; /* Depth of node to load */ } H5B2_internal_cache_ud_t; /* Callback info for loading a v2 B-tree leaf node into the cache */ typedef struct H5B2_leaf_cache_ud_t { - H5F_t * f; /* File that v2 b-tree header is within */ + H5F_t *f; /* File that v2 b-tree header is within */ H5B2_hdr_t *hdr; /* v2 B-tree header */ - void * parent; /* Flush dependency parent */ + void *parent; /* Flush dependency parent */ uint16_t nrec; /* Number of records in node to load */ } H5B2_leaf_cache_ud_t; @@ -321,7 +320,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 +389,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 */ @@ -415,7 +414,7 @@ H5_DLL herr_t H5B2__remove_leaf(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, void *parent, void *udata, H5B2_remove_t op, void *op_data); H5_DLL herr_t H5B2__remove_internal_by_idx(H5B2_hdr_t *hdr, hbool_t *depth_decreased, void *swap_loc, void *swap_parent, uint16_t depth, H5AC_info_t *parent_cache_info, - unsigned * parent_cache_info_flags_ptr, + unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, hsize_t n, H5B2_remove_t op, void *op_data); H5_DLL herr_t H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, H5B2_node_ptr_t *curr_node_ptr, @@ -423,8 +422,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/H5B2private.h b/src/H5B2private.h index 21ea8236fa2..dc8de8dd247 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -85,7 +84,7 @@ typedef enum H5B2_compare_t { typedef struct H5B2_class_t H5B2_class_t; struct H5B2_class_t { H5B2_subid_t id; /* ID of B-tree class, as found in file */ - const char * name; /* Name of B-tree class, for debugging */ + const char *name; /* Name of B-tree class, for debugging */ size_t nrec_size; /* Size of native (memory) record */ /* Extensible array client callback methods */ diff --git a/src/H5B2stat.c b/src/H5B2stat.c index 47352761d92..12956381607 100644 --- a/src/H5B2stat.c +++ b/src/H5B2stat.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -128,7 +127,7 @@ H5B2_size(H5B2_t *bt2, hsize_t *btree_size) else /* Iterate through nodes */ if (H5B2__node_size(hdr, hdr->depth, &hdr->root, hdr, btree_size) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "node iteration failed") } /* end if */ done: diff --git a/src/H5B2test.c b/src/H5B2test.c index 2b84332b1d2..9434c4ae13b 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -54,7 +53,7 @@ typedef struct H5B2_test_ctx_t { /********************/ /* v2 B-tree driver callbacks for 'test' B-trees */ -static void * H5B2__test_crt_context(void *udata); +static void *H5B2__test_crt_context(void *udata); static herr_t H5B2__test_dst_context(void *ctx); static herr_t H5B2__test_store(void *nrecord, const void *udata); static herr_t H5B2__test_compare(const void *rec1, const void *rec2, int *result); @@ -130,9 +129,9 @@ H5FL_DEFINE_STATIC(H5B2_test_ctx_t); static void * H5B2__test_crt_context(void *_f) { - H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ H5B2_test_ctx_t *ctx; /* Callback context structure */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -483,9 +482,9 @@ H5B2__get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr) herr_t H5B2__get_node_info_test(H5B2_t *bt2, void *udata, H5B2_node_info_test_t *ninfo) { - H5B2_hdr_t * hdr; /* Pointer to the B-tree header */ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ H5B2_node_ptr_t curr_node_ptr; /* Node pointer info for current node */ - void * parent = NULL; /* Parent of current node */ + void *parent = NULL; /* Parent of current node */ uint16_t depth; /* Current depth of the tree */ int cmp; /* Comparison value of records */ unsigned idx; /* Location of record which matches key */ diff --git a/src/H5Bcache.c b/src/H5Bcache.c index ec7457f9c2a..010cecd6061 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -50,7 +49,7 @@ /* Metadata cache callbacks */ static herr_t H5B__cache_get_initial_load_size(void *udata, size_t *image_len); -static void * H5B__cache_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5B__cache_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5B__cache_image_len(const void *thing, size_t *image_len); static herr_t H5B__cache_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5B__cache_free_icr(void *thing); @@ -97,7 +96,7 @@ static herr_t H5B__cache_get_initial_load_size(void *_udata, size_t *image_len) { H5B_cache_ud_t *udata = (H5B_cache_ud_t *)_udata; /* User data for callback */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ FUNC_ENTER_STATIC_NOERR @@ -132,13 +131,13 @@ static void * H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5B_t * bt = NULL; /* Pointer to the deserialized B-tree node */ + H5B_t *bt = NULL; /* Pointer to the deserialized B-tree node */ H5B_cache_ud_t *udata = (H5B_cache_ud_t *)_udata; /* User data for callback */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into image buffer */ - uint8_t * native; /* Pointer to native keys */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into image buffer */ + uint8_t *native; /* Pointer to native keys */ unsigned u; /* Local index variable */ - H5B_t * ret_value = NULL; /* Return value */ + H5B_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -235,7 +234,7 @@ H5B__cache_deserialize(const void *_image, size_t H5_ATTR_UNUSED len, void *_uda static herr_t H5B__cache_image_len(const void *_thing, size_t *image_len) { - const H5B_t * bt = (const H5B_t *)_thing; /* Pointer to the B-tree node */ + const H5B_t *bt = (const H5B_t *)_thing; /* Pointer to the B-tree node */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ FUNC_ENTER_STATIC_NOERR @@ -269,10 +268,10 @@ H5B__cache_image_len(const void *_thing, size_t *image_len) static herr_t H5B__cache_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { - H5B_t * bt = (H5B_t *)_thing; /* Pointer to the B-tree node */ + H5B_t *bt = (H5B_t *)_thing; /* Pointer to the B-tree node */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ - uint8_t * image = (uint8_t *)_image; /* Pointer into image buffer */ - uint8_t * native; /* Pointer to native keys */ + uint8_t *image = (uint8_t *)_image; /* Pointer into image buffer */ + uint8_t *native; /* Pointer to native keys */ unsigned u; /* Local index counter */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index 23d0a8f6920..b134772b116 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -51,9 +50,9 @@ herr_t H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5B_class_t *type, void *udata) { - H5B_t * bt = NULL; - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_t *bt = NULL; + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -110,20 +109,20 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5 */ for (u = 0; u < bt->nchildren; u++) { HDfprintf(stream, "%*sChild %d...\n", indent, "", u); - HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", MAX(0, fwidth - 3), + HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent + 3, "", MAX(3, fwidth) - 3, "Address:", bt->child[u]); /* If there is a key debugging routine, use it to display the left & right keys */ if (type->debug_key) { /* Decode the 'left' key & print it */ - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Left Key:"); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(3, fwidth) - 3, "Left Key:"); HDassert(H5B_NKEY(bt, shared, u)); - (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), H5B_NKEY(bt, shared, u), udata); + (void)(type->debug_key)(stream, indent + 6, MAX(6, fwidth) - 6, H5B_NKEY(bt, shared, u), udata); /* Decode the 'right' key & print it */ - HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Right Key:"); + HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(3, fwidth) - 3, "Right Key:"); HDassert(H5B_NKEY(bt, shared, u + 1)); - (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6), H5B_NKEY(bt, shared, u + 1), + (void)(type->debug_key)(stream, indent + 6, MAX(6, fwidth) - 6, H5B_NKEY(bt, shared, u + 1), udata); } /* end if */ } /* end for */ @@ -153,9 +152,9 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5 herr_t H5B__assert(H5F_t *f, haddr_t addr, const H5B_class_t *type, void *udata) { - H5B_t * bt = NULL; - H5UC_t * rc_shared; /* Ref-counted shared info */ - H5B_shared_t * shared; /* Pointer to shared B-tree info */ + H5B_t *bt = NULL; + H5UC_t *rc_shared; /* Ref-counted shared info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ int ncell, cmp; static int ncalls = 0; diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index 0a796283da3..3147315e244 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -49,7 +48,7 @@ typedef struct H5B_t { H5AC_info_t cache_info; /* Information for H5AC cache functions */ /* _must_ be first field in structure */ - H5UC_t * rc_shared; /*ref-counted shared info */ + H5UC_t *rc_shared; /*ref-counted shared info */ unsigned level; /*node level */ unsigned nchildren; /*number of child pointers */ haddr_t left; /*address of left sibling */ @@ -60,9 +59,9 @@ typedef struct H5B_t { /* Callback info for loading a B-tree node into the cache */ typedef struct H5B_cache_ud_t { - H5F_t * f; /* File that B-tree node is within */ + H5F_t *f; /* File that B-tree node is within */ const struct H5B_class_t *type; /* Type of tree */ - H5UC_t * rc_shared; /* Ref-counted shared info */ + H5UC_t *rc_shared; /* Ref-counted shared info */ } H5B_cache_ud_t; /*****************************/ diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index 265b6c67f5b..7c56f7cfc51 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -90,9 +89,9 @@ typedef struct H5B_shared_t { size_t sizeof_keys; /* Size of native (memory) key node */ size_t sizeof_addr; /* Size of file address (in bytes) */ size_t sizeof_len; /* Size of file lengths (in bytes) */ - uint8_t * page; /* Disk page */ - size_t * nkey; /* Offsets of each native key in native key buffer */ - void * udata; /* 'Local' info for a B-tree */ + uint8_t *page; /* Disk page */ + size_t *nkey; /* Offsets of each native key in native key buffer */ + void *udata; /* 'Local' info for a B-tree */ } H5B_shared_t; /* diff --git a/src/H5C.c b/src/H5C.c index 185b421b4d5..b57cbd15bb4 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -138,16 +137,6 @@ static herr_t H5C__generate_image(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t static herr_t H5C__verify_len_eoa(H5F_t *f, const H5C_class_t *type, haddr_t addr, size_t *len, hbool_t actual); -#if H5C_DO_SLIST_SANITY_CHECKS -static hbool_t H5C__entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr); -#endif /* H5C_DO_SLIST_SANITY_CHECKS */ - -#if H5C_DO_EXTREME_SANITY_CHECKS -static herr_t H5C__validate_lru_list(H5C_t *cache_ptr); -static herr_t H5C__validate_pinned_entry_list(H5C_t *cache_ptr); -static herr_t H5C__validate_protected_entry_list(H5C_t *cache_ptr); -#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - #ifndef NDEBUG static void H5C__assert_flush_dep_nocycle(const H5C_cache_entry_t *entry, const H5C_cache_entry_t *base_entry); @@ -193,88 +182,11 @@ H5FL_SEQ_DEFINE_STATIC(H5C_cache_entry_ptr_t); * flag to determine whether writes are permitted. * * Return: Success: Pointer to the new instance. - * * Failure: NULL * * Programmer: John Mainzer * 6/2/04 * - * Modifications: - * - * JRM -- 7/20/04 - * Updated for the addition of the hash table. - * - * JRM -- 10/5/04 - * Added call to H5C_reset_cache_hit_rate_stats(). Also - * added initialization for cache_is_full flag and for - * resize_ctl. - * - * JRM -- 11/12/04 - * Added initialization for the new size_decreased field. - * - * JRM -- 11/17/04 - * Added/updated initialization for the automatic cache - * size control data structures. - * - * JRM -- 6/24/05 - * Added support for the new write_permitted field of - * the H5C_t structure. - * - * JRM -- 7/5/05 - * Added the new log_flush parameter and supporting code. - * - * JRM -- 9/21/05 - * Added the new aux_ptr parameter and supporting code. - * - * JRM -- 1/20/06 - * Added initialization of the new prefix field in H5C_t. - * - * JRM -- 3/16/06 - * Added initialization for the pinned entry related fields. - * - * JRM -- 5/31/06 - * Added initialization for the trace_file_ptr field. - * - * JRM -- 8/19/06 - * Added initialization for the flush_in_progress field. - * - * JRM -- 8/25/06 - * Added initialization for the slist_len_increase and - * slist_size_increase fields. These fields are used - * for sanity checking in the flush process, and are not - * compiled in unless H5C_DO_SANITY_CHECKS is TRUE. - * - * JRM -- 3/28/07 - * Added initialization for the new is_read_only and - * ro_ref_count fields. - * - * JRM -- 7/27/07 - * Added initialization for the new evictions_enabled - * field of H5C_t. - * - * JRM -- 12/31/07 - * Added initialization for the new flash cache size increase - * related fields of H5C_t. - * - * JRM -- 11/5/08 - * Added initialization for the new clean_index_size and - * dirty_index_size fields of H5C_t. - * - * - * Missing entries? - * - * - * JRM -- 4/20/20 - * Added initialization for the slist_enabled field. Recall - * that the slist is used to flush metadata cache entries - * in (roughly) increasing address order. While this is - * needed at flush and close, it is not used elsewhere. - * The slist_enabled field exists to allow us to construct - * the slist when needed, and leave it empty otherwise -- thus - * avoiding the overhead of maintaining it. - * - * JRM -- 4/29/20 - * *------------------------------------------------------------------------- */ H5C_t * @@ -307,8 +219,7 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, if (NULL == (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, NULL, "can't create skip list") - if (NULL == (cache_ptr->tag_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, NULL, "can't create skip list for tagged entry addresses") + cache_ptr->tag_list = NULL; /* If we get this far, we should succeed. Go ahead and initialize all * the fields. @@ -372,7 +283,7 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, cache_ptr->slist_size = (size_t)0; /* slist_ring_len, slist_ring_size, and - * slist_ptr initializaed above. + * slist_ptr initialized above. */ #if H5C_DO_SANITY_CHECKS @@ -515,7 +426,7 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, #ifndef NDEBUG cache_ptr->get_entry_ptr_from_addr_counter = 0; -#endif /* NDEBUG */ +#endif /* Set return value */ ret_value = cache_ptr; @@ -526,16 +437,16 @@ H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, if (cache_ptr->slist_ptr != NULL) H5SL_close(cache_ptr->slist_ptr); - if (cache_ptr->tag_list != NULL) - H5SL_close(cache_ptr->tag_list); + HASH_CLEAR(hh, cache_ptr->tag_list); + cache_ptr->tag_list = NULL; if (cache_ptr->log_info != NULL) H5MM_xfree(cache_ptr->log_info); cache_ptr->magic = 0; cache_ptr = H5FL_FREE(H5C_t, cache_ptr); - } /* end if */ - } /* end if */ + } + } FUNC_LEAVE_NOAPI(ret_value) } /* H5C_create() */ @@ -674,33 +585,6 @@ H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, } } /* H5C_def_auto_resize_rpt_fcn() */ -/*------------------------------------------------------------------------- - * Function: H5C__free_tag_list_cb - * - * Purpose: Callback function to free tag nodes from the skip list. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Vailin Choi - * January 2014 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__free_tag_list_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op_data) -{ - H5C_tag_info_t *tag_info = (H5C_tag_info_t *)_item; - - FUNC_ENTER_STATIC_NOERR - - HDassert(tag_info); - - /* Release the item */ - tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); - - FUNC_LEAVE_NOAPI(0) -} /* H5C__free_tag_list_cb() */ - /*------------------------------------------------------------------------- * * Function: H5C_prep_for_file_close @@ -719,7 +603,7 @@ H5C__free_tag_list_cb(void *_item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED herr_t H5C_prep_for_file_close(H5F_t *f) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t image_generated = FALSE; /* Whether a cache image was generated */ herr_t ret_value = SUCCEED; /* Return value */ @@ -733,10 +617,7 @@ H5C_prep_for_file_close(H5F_t *f) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - /* For now at least, it is possible to receive the - * close warning more than once -- the following - * if statement handles this. - */ + /* It is possible to receive the close warning more than once */ if (cache_ptr->close_warning_received) HGOTO_DONE(SUCCEED) cache_ptr->close_warning_received = TRUE; @@ -781,7 +662,7 @@ H5C_prep_for_file_close(H5F_t *f) * * 2) Since the FSM settle routines are only invoked once during * file close, invoking them now will prevent their invocation - * during a flush, and thus avoid any resulting entrie dirties, + * during a flush, and thus avoid any resulting entry dirties, * deletions, insertion, or moves during the flush. */ if (H5C__serialize_cache(f) < 0) @@ -808,27 +689,15 @@ H5C_prep_for_file_close(H5F_t *f) * Programmer: John Mainzer * 6/2/04 * - * Modifications: - * - * JRM -- 5/15/20 - * - * Updated the function to enable the slist prior to the - * call to H5C__flush_invalidate_cache(). - * - * Arguably, it shouldn't be necessary to re-enable the - * slist after the call to H5C__flush_invalidate_cache(), as - * the metadata cache should be discarded. However, in the - * test code, we make multiple calls to H5C_dest(). Thus - * we re-enable the slist on failure if it and the cache - * still exist. - * *------------------------------------------------------------------------- */ herr_t H5C_dest(H5F_t *f) { - H5C_t *cache_ptr = f->shared->cache; - herr_t ret_value = SUCCEED; /* Return value */ + H5C_t *cache_ptr = f->shared->cache; + H5C_tag_info_t *item = NULL; + H5C_tag_info_t *tmp = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -844,57 +713,42 @@ H5C_dest(H5F_t *f) /* Enable the slist, as it is needed in the flush */ if (H5C_set_slist_enabled(f->shared->cache, TRUE, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed") /* Flush and invalidate all cache entries */ if (H5C__flush_invalidate_cache(f, H5C__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") /* Generate & write cache image if requested */ - if (cache_ptr->image_ctl.generate_image) { - + if (cache_ptr->image_ctl.generate_image) if (H5C__generate_cache_image(f, cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "Can't generate metadata cache image") - } /* Question: Is it possible for cache_ptr->slist be non-null at this * point? If no, shouldn't this if statement be an assert? */ if (cache_ptr->slist_ptr != NULL) { - HDassert(cache_ptr->slist_len == 0); HDassert(cache_ptr->slist_size == 0); H5SL_close(cache_ptr->slist_ptr); - cache_ptr->slist_ptr = NULL; + } - } /* end if */ - - if (cache_ptr->tag_list != NULL) { - - H5SL_destroy(cache_ptr->tag_list, H5C__free_tag_list_cb, NULL); - - cache_ptr->tag_list = NULL; - - } /* end if */ - - if (cache_ptr->log_info != NULL) { + HASH_ITER(hh, cache_ptr->tag_list, item, tmp) + { + HASH_DELETE(hh, cache_ptr->tag_list, item); + item = H5FL_FREE(H5C_tag_info_t, item); + } + if (cache_ptr->log_info != NULL) H5MM_xfree(cache_ptr->log_info); - } #ifndef NDEBUG #if H5C_DO_SANITY_CHECKS - - if (cache_ptr->get_entry_ptr_from_addr_counter > 0) { - + if (cache_ptr->get_entry_ptr_from_addr_counter > 0) HDfprintf(stdout, "*** %" PRId64 " calls to H5C_get_entry_ptr_from_add(). ***\n", cache_ptr->get_entry_ptr_from_addr_counter); - } #endif /* H5C_DO_SANITY_CHECKS */ cache_ptr->magic = 0; @@ -903,18 +757,12 @@ H5C_dest(H5F_t *f) cache_ptr = H5FL_FREE(H5C_t, cache_ptr); done: - - if ((ret_value < 0) && (cache_ptr) && (cache_ptr->slist_ptr)) { - + if (ret_value < 0 && cache_ptr && cache_ptr->slist_ptr) /* need this for test code -- see change note for details */ - if (H5C_set_slist_enabled(f->shared->cache, FALSE, FALSE) < 0) - HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist on flush dest failure failed") - } FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_dest() */ /*------------------------------------------------------------------------- @@ -983,7 +831,7 @@ H5C_evict(H5F_t *f) herr_t H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flags) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *entry_ptr = NULL; unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); herr_t ret_value = SUCCEED; /* Return value */ @@ -999,7 +847,7 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag HDassert(H5F_addr_defined(addr)); #if H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_lru_list(cache_ptr) < 0) + if (H5C_validate_lru_list(cache_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1034,7 +882,7 @@ H5C_expunge_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, unsigned flag done: #if H5C_DO_EXTREME_SANITY_CHECKS - if (H5C__validate_lru_list(cache_ptr) < 0) + if (H5C_validate_lru_list(cache_ptr) < 0) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "LRU extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1101,7 +949,7 @@ H5C_flush_cache(H5F_t *f, unsigned flags) uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ H5C_ring_t ring; - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t destroy; herr_t ret_value = SUCCEED; @@ -1141,8 +989,8 @@ H5C_flush_cache(H5F_t *f, unsigned flags) #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1234,7 +1082,7 @@ H5C_flush_cache(H5F_t *f, unsigned flags) herr_t H5C_flush_to_min_clean(H5F_t *f) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t write_permitted; herr_t ret_value = SUCCEED; @@ -1284,7 +1132,7 @@ H5C_flush_to_min_clean(H5F_t *f) herr_t H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5AC_ring_t ring = H5C_RING_UNDEFINED; hbool_t insert_pinned; hbool_t flush_last; @@ -1317,8 +1165,8 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u #if H5C_DO_EXTREME_SANITY_CHECKS /* no need to verify that entry is not already in the index as */ /* we already make that check below. */ - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1487,7 +1335,7 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u * Finally, we usually don't check to see if the cache is * oversized at the end of an unprotect. As a result, it is * possible to have a vastly oversized cache with no protected - * entries as long as all the protects preceed the unprotects. + * entries as long as all the protects precede the unprotects. * * Since items 1 and 2 are not changing any time soon, I see * no point in worrying about the third. @@ -1506,8 +1354,8 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, FAIL) #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed just before done") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1521,23 +1369,32 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u #ifdef H5_HAVE_PARALLEL if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) - coll_access = H5CX_get_coll_metadata_read(); + coll_access = H5F_get_coll_metadata_reads(f); entry_ptr->coll_access = coll_access; if (coll_access) { H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, FAIL) /* Make sure the size of the collective entries in the cache remain in check */ - if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) - if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") - } /* end if */ + if (H5P_USER_TRUE == H5F_COLL_MD_READ(f)) { + if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) { + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") + } /* end if */ + } /* end if */ + else { + if (cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) { + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") + } /* end if */ + } /* end else */ + } /* end if */ #endif done: #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1578,7 +1435,7 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u herr_t H5C_mark_entry_dirty(void *thing) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; herr_t ret_value = SUCCEED; /* Return value */ @@ -1676,7 +1533,7 @@ H5C_mark_entry_dirty(void *thing) herr_t H5C_mark_entry_clean(void *_thing) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_thing; herr_t ret_value = SUCCEED; /* Return value */ @@ -1861,8 +1718,8 @@ H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, hadd HDassert(H5F_addr_ne(old_addr, new_addr)); #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1967,8 +1824,8 @@ H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, hadd done: #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -1994,7 +1851,7 @@ H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t old_addr, hadd herr_t H5C_resize_entry(void *thing, size_t new_size) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; herr_t ret_value = SUCCEED; /* Return value */ @@ -2014,8 +1871,7 @@ H5C_resize_entry(void *thing, size_t new_size) HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, FAIL, "Entry isn't pinned or protected??") #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || (H5C_validate_pinned_entry_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -2111,8 +1967,7 @@ H5C_resize_entry(void *thing, size_t new_size) done: #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || (H5C_validate_pinned_entry_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -2138,7 +1993,7 @@ H5C_resize_entry(void *thing, size_t new_size) herr_t H5C_pin_protected_entry(void *thing) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)thing; /* Pointer to entry to pin */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2152,8 +2007,8 @@ H5C_pin_protected_entry(void *thing) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -2167,8 +2022,8 @@ H5C_pin_protected_entry(void *thing) done: #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -2200,7 +2055,7 @@ H5C_pin_protected_entry(void *thing) void * H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsigned flags) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5AC_ring_t ring = H5C_RING_UNDEFINED; hbool_t hit; hbool_t have_write_permitted = FALSE; @@ -2212,9 +2067,9 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign hbool_t write_permitted = FALSE; hbool_t was_loaded = FALSE; /* Whether the entry was loaded as a result of the protect */ size_t empty_space; - void * thing; + void *thing; H5C_cache_entry_t *entry_ptr; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2231,8 +2086,8 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign HDassert(H5F_addr_defined(addr)); #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -2251,7 +2106,7 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign #ifdef H5_HAVE_PARALLEL if (H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) - coll_access = H5CX_get_coll_metadata_read(); + coll_access = H5F_get_coll_metadata_reads(f); #endif /* H5_HAVE_PARALLEL */ /* first check to see if the target is in cache */ @@ -2310,9 +2165,14 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign H5MM_memcpy(((uint8_t *)entry_ptr->image_ptr) + entry_ptr->size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ - if (0 == mpi_rank) - if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't generate entry's image") + if (0 == mpi_rank) { + if (H5C__generate_image(f, cache_ptr, entry_ptr) < 0) { + /* If image generation fails, push an error but + * still participate in the following MPI_Bcast + */ + HDONE_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't generate entry's image") + } + } } /* end if */ HDassert(entry_ptr->image_ptr); @@ -2447,7 +2307,7 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign * Finally, we usually don't check to see if the cache is * oversized at the end of an unprotect. As a result, it is * possible to have a vastly oversized cache with no protected - * entries as long as all the protects preceed the unprotects. + * entries as long as all the protects precede the unprotects. * * Since items 1, 2, and 3 are not changing any time soon, I * see no point in worrying about the fourth. @@ -2562,7 +2422,7 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign * * Also, if the min_clean_size requirement is not met, we * should also call H5C__make_space_in_cache() to bring us - * into complience. + * into compliance. */ if (cache_ptr->index_size >= cache_ptr->max_cache_size) @@ -2598,16 +2458,24 @@ H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsign #ifdef H5_HAVE_PARALLEL /* Make sure the size of the collective entries in the cache remain in check */ - if (coll_access) - if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) - if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") -#endif /* H5_HAVE_PARALLEL */ + if (coll_access) { + if (H5P_USER_TRUE == H5F_COLL_MD_READ(f)) { + if (cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") + } /* end if */ + else { + if (cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) + if (H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") + } /* end else */ + } /* end if */ +#endif /* H5_HAVE_PARALLEL */ done: #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -2826,9 +2694,10 @@ H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_p break; case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_possible = TRUE; - cache_ptr->flash_size_increase_threshold = (size_t)( - ((double)(cache_ptr->max_cache_size)) * ((cache_ptr->resize_ctl).flash_threshold)); + cache_ptr->flash_size_increase_possible = TRUE; + cache_ptr->flash_size_increase_threshold = + (size_t)(((double)(cache_ptr->max_cache_size)) * + ((cache_ptr->resize_ctl).flash_threshold)); break; default: /* should be unreachable */ @@ -2971,7 +2840,7 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_sli } /* set cache_ptr->slist_enabled to TRUE so that the slist - * mainenance macros will be enabled. + * maintenance macros will be enabled. */ cache_ptr->slist_enabled = TRUE; @@ -3067,7 +2936,7 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, hbool_t slist_enabled, hbool_t clear_sli herr_t H5C_unpin_entry(void *_entry_ptr) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *entry_ptr = (H5C_cache_entry_t *)_entry_ptr; /* Pointer to entry to unpin */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3080,8 +2949,8 @@ H5C_unpin_entry(void *_entry_ptr) HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -3091,8 +2960,8 @@ H5C_unpin_entry(void *_entry_ptr) done: #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -3202,7 +3071,7 @@ H5C_unpin_entry(void *_entry_ptr) herr_t H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t deleted; hbool_t dirtied; hbool_t set_flush_marker; @@ -3259,8 +3128,8 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) was_clean = !(entry_ptr->is_dirty); #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -3526,8 +3395,8 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) done: #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HDONE_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -3565,7 +3434,7 @@ herr_t H5C_unsettle_entry_ring(void *_entry) { H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry whose ring to unsettle */ - H5C_t * cache; /* Cache for file */ + H5C_t *cache; /* Cache for file */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3849,7 +3718,7 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t *config_ptr, unsigned int tests) herr_t H5C_create_flush_dependency(void *parent_thing, void *child_thing) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent thing's entry */ H5C_cache_entry_t *child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child thing's entry */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3990,7 +3859,7 @@ H5C_create_flush_dependency(void *parent_thing, void *child_thing) herr_t H5C_destroy_flush_dependency(void *parent_thing, void *child_thing) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *parent_entry = (H5C_cache_entry_t *)parent_thing; /* Ptr to parent entry */ H5C_cache_entry_t *child_entry = (H5C_cache_entry_t *)child_thing; /* Ptr to child entry */ unsigned u; /* Local index variable */ @@ -4078,7 +3947,7 @@ H5C_destroy_flush_dependency(void *parent_thing, void *child_thing) "can't notify parent about child entry serialized flag set") } /* end if */ - /* Shrink or free the parent array if apporpriate */ + /* Shrink or free the parent array if appropriate */ if (child_entry->flush_dep_nparents == 0) { child_entry->flush_dep_parent = H5FL_SEQ_FREE(H5C_cache_entry_ptr_t, child_entry->flush_dep_parent); child_entry->flush_dep_parent_nalloc = 0; @@ -4257,7 +4126,7 @@ H5C__unpin_entry_from_client(H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr, hbo static herr_t H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) { - H5C_t * cache_ptr = f->shared->cache; + H5C_t *cache_ptr = f->shared->cache; hbool_t reentrant_call = FALSE; hbool_t inserted_epoch_marker = FALSE; size_t new_max_cache_size = 0; @@ -4490,8 +4359,9 @@ H5C__auto_adjust_cache_size(H5F_t *f, hbool_t write_permitted) break; case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_threshold = (size_t)( - ((double)(cache_ptr->max_cache_size)) * ((cache_ptr->resize_ctl).flash_threshold)); + cache_ptr->flash_size_increase_threshold = + (size_t)(((double)(cache_ptr->max_cache_size)) * + ((cache_ptr->resize_ctl).flash_threshold)); break; default: /* should be unreachable */ @@ -4659,10 +4529,11 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr) cache_ptr->epoch_marker_ringbuf_first = (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); + if (cache_ptr->epoch_marker_ringbuf_size <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + cache_ptr->epoch_marker_ringbuf_size -= 1; - if (cache_ptr->epoch_marker_ringbuf_size < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") if ((cache_ptr->epoch_marker_active)[i] != TRUE) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") @@ -4682,11 +4553,11 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr) (cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i; - cache_ptr->epoch_marker_ringbuf_size += 1; - - if (cache_ptr->epoch_marker_ringbuf_size > H5C__MAX_EPOCH_MARKERS) + if (cache_ptr->epoch_marker_ringbuf_size >= H5C__MAX_EPOCH_MARKERS) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") + cache_ptr->epoch_marker_ringbuf_size += 1; + H5C__DLL_PREPEND((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (FAIL)) done: @@ -4737,7 +4608,7 @@ H5C__autoadjust__ageout__cycle_epoch_marker(H5C_t *cache_ptr) static herr_t H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitted) { - H5C_t * cache_ptr = f->shared->cache; + H5C_t *cache_ptr = f->shared->cache; size_t eviction_size_limit; size_t bytes_evicted = 0; hbool_t prev_is_dirty = FALSE; @@ -4851,7 +4722,7 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t *f, hbool_t write_permitte /* for now at least, don't bother to maintain the minimum clean size, * as the cache should now be less than its maximum size. Due to - * the vaguries of the cache size reduction algorthim, we may not + * the vaguries of the cache size reduction algorithm, we may not * reduce the size of the cache. * * If we do, we will calculate a new minimum clean size, which will @@ -4957,13 +4828,13 @@ H5C__autoadjust__ageout__insert_new_marker(H5C_t *cache_ptr) (cache_ptr->epoch_marker_ringbuf)[cache_ptr->epoch_marker_ringbuf_last] = i; - cache_ptr->epoch_marker_ringbuf_size += 1; - - if (cache_ptr->epoch_marker_ringbuf_size > H5C__MAX_EPOCH_MARKERS) { + if (cache_ptr->epoch_marker_ringbuf_size >= H5C__MAX_EPOCH_MARKERS) { HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer overflow") } + cache_ptr->epoch_marker_ringbuf_size += 1; + H5C__DLL_PREPEND((&((cache_ptr->epoch_markers)[i])), (cache_ptr)->LRU_head_ptr, (cache_ptr)->LRU_tail_ptr, (cache_ptr)->LRU_list_len, (cache_ptr)->LRU_list_size, (FAIL)) @@ -5011,11 +4882,11 @@ H5C__autoadjust__ageout__remove_all_markers(H5C_t *cache_ptr) cache_ptr->epoch_marker_ringbuf_first = (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); - cache_ptr->epoch_marker_ringbuf_size -= 1; - - if (cache_ptr->epoch_marker_ringbuf_size < 0) + if (cache_ptr->epoch_marker_ringbuf_size <= 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + cache_ptr->epoch_marker_ringbuf_size -= 1; + if ((cache_ptr->epoch_marker_active)[i] != TRUE) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") @@ -5084,10 +4955,11 @@ H5C__autoadjust__ageout__remove_excess_markers(H5C_t *cache_ptr) cache_ptr->epoch_marker_ringbuf_first = (cache_ptr->epoch_marker_ringbuf_first + 1) % (H5C__MAX_EPOCH_MARKERS + 1); + if (cache_ptr->epoch_marker_ringbuf_size <= 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") + cache_ptr->epoch_marker_ringbuf_size -= 1; - if (cache_ptr->epoch_marker_ringbuf_size < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "ring buffer underflow") if ((cache_ptr->epoch_marker_active)[i] != TRUE) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unused marker in LRU?!?") @@ -5212,8 +5084,9 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n break; case H5C_flash_incr__add_space: - cache_ptr->flash_size_increase_threshold = (size_t)( - ((double)(cache_ptr->max_cache_size)) * ((cache_ptr->resize_ctl).flash_threshold)); + cache_ptr->flash_size_increase_threshold = + (size_t)(((double)(cache_ptr->max_cache_size)) * + ((cache_ptr->resize_ctl).flash_threshold)); break; default: /* should be unreachable */ @@ -5331,7 +5204,7 @@ H5C__flash_increase_cache_size(H5C_t *cache_ptr, size_t old_entry_size, size_t n static herr_t H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_ring_t ring; herr_t ret_value = SUCCEED; @@ -5511,15 +5384,15 @@ H5C__flush_invalidate_cache(H5F_t *f, unsigned flags) static herr_t H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t restart_slist_scan; uint32_t protected_entries = 0; int32_t i; - int32_t cur_ring_pel_len; - int32_t old_ring_pel_len; + uint32_t cur_ring_pel_len; + uint32_t old_ring_pel_len; unsigned cooked_flags; unsigned evict_flags; - H5SL_node_t * node_ptr = NULL; + H5SL_node_t *node_ptr = NULL; H5C_cache_entry_t *entry_ptr = NULL; H5C_cache_entry_t *next_entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS @@ -5863,7 +5736,7 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) * If either of these happen, and one of the target * or proxy entries happens to be the next entry in * the hash bucket, we could either find ourselves - * either scanning a non-existant entry, scanning + * either scanning a non-existent entry, scanning * through a different bucket, or skipping an entry. * * Neither of these are good, so restart the @@ -6033,14 +5906,14 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) static herr_t H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) { - H5C_t * cache_ptr = f->shared->cache; + H5C_t *cache_ptr = f->shared->cache; hbool_t flushed_entries_last_pass; hbool_t flush_marked_entries; hbool_t ignore_protected; hbool_t tried_to_flush_protected_entry = FALSE; hbool_t restart_slist_scan; uint32_t protected_entries = 0; - H5SL_node_t * node_ptr = NULL; + H5SL_node_t *node_ptr = NULL; H5C_cache_entry_t *entry_ptr = NULL; H5C_cache_entry_t *next_entry_ptr = NULL; #if H5C_DO_SANITY_CHECKS @@ -6061,8 +5934,8 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HDassert(ring < H5C_RING_NTYPES); #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -6398,7 +6271,7 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) herr_t H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) { - H5C_t * cache_ptr; /* Cache for file */ + H5C_t *cache_ptr; /* Cache for file */ hbool_t destroy; /* external flag */ hbool_t clear_only; /* external flag */ hbool_t free_file_space; /* external flag */ @@ -7095,8 +6968,8 @@ H5C__load_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata) { hbool_t dirty = FALSE; /* Flag indicating whether thing was dirtied during deserialize */ - uint8_t * image = NULL; /* Buffer for disk image */ - void * thing = NULL; /* Pointer to thing loaded */ + uint8_t *image = NULL; /* Buffer for disk image */ + void *thing = NULL; /* Pointer to thing loaded */ H5C_cache_entry_t *entry = NULL; /* Alias for thing loaded, as cache entry */ size_t len; /* Size of image in file */ #ifdef H5_HAVE_PARALLEL @@ -7159,7 +7032,7 @@ H5C__load_entry(H5F_t *f, htri_t chk_ret; /* return from verify_chksum callback */ size_t actual_len = len; /* The actual length, after speculative reads have been resolved */ uint64_t nanosec = 1; /* # of nanoseconds to sleep between retries */ - void * new_image; /* Pointer to image */ + void *new_image; /* Pointer to image */ hbool_t len_changed = TRUE; /* Whether to re-check speculative entries */ /* Get the # of read attempts */ @@ -7185,8 +7058,20 @@ H5C__load_entry(H5F_t *f, #ifdef H5_HAVE_PARALLEL if (!coll_access || 0 == mpi_rank) { #endif /* H5_HAVE_PARALLEL */ - if (H5F_block_read(f, type->mem_type, addr, len, image) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") + + if (H5F_block_read(f, type->mem_type, addr, len, image) < 0) { + +#ifdef H5_HAVE_PARALLEL + if (coll_access) { + /* Push an error, but still participate in following MPI_Bcast */ + HDmemset(image, 0, len); + HDONE_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") + } + else +#endif + HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") + } + #ifdef H5_HAVE_PARALLEL } /* end if */ /* if the collective metadata read optimization is turned on, @@ -7233,8 +7118,19 @@ H5C__load_entry(H5F_t *f, * loaded thing, go get the on-disk image again (the extra portion). */ if (H5F_block_read(f, type->mem_type, addr + len, actual_len - len, image + len) < - 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") + 0) { + +#ifdef H5_HAVE_PARALLEL + if (coll_access) { + /* Push an error, but still participate in following MPI_Bcast */ + HDmemset(image + len, 0, actual_len - len); + HDONE_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") + } + else +#endif + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "can't read image") + } + #ifdef H5_HAVE_PARALLEL } /* If the collective metadata read optimization is turned on, @@ -7714,7 +7610,7 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) /*------------------------------------------------------------------------- * - * Function: H5C__validate_lru_list + * Function: H5C_validate_lru_list * * Purpose: Debugging function that scans the LRU list for errors. * @@ -7729,15 +7625,15 @@ H5C__make_space_in_cache(H5F_t *f, size_t space_needed, hbool_t write_permitted) *------------------------------------------------------------------------- */ #if H5C_DO_EXTREME_SANITY_CHECKS -static herr_t -H5C__validate_lru_list(H5C_t *cache_ptr) +herr_t +H5C_validate_lru_list(H5C_t *cache_ptr) { int32_t len = 0; size_t size = 0; H5C_cache_entry_t *entry_ptr = NULL; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_NOAPI(FAIL) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); @@ -7746,51 +7642,48 @@ H5C__validate_lru_list(H5C_t *cache_ptr) (cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - if (cache_ptr->LRU_list_len < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - if ((cache_ptr->LRU_list_len == 1) && ((cache_ptr->LRU_head_ptr != cache_ptr->LRU_tail_ptr) || (cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_head_ptr->size != cache_ptr->LRU_list_size))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") if ((cache_ptr->LRU_list_len >= 1) && ((cache_ptr->LRU_head_ptr == NULL) || (cache_ptr->LRU_head_ptr->prev != NULL) || (cache_ptr->LRU_tail_ptr == NULL) || (cache_ptr->LRU_tail_ptr->next != NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") entry_ptr = cache_ptr->LRU_head_ptr; while (entry_ptr != NULL) { if ((entry_ptr != cache_ptr->LRU_head_ptr) && ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") if ((entry_ptr != cache_ptr->LRU_tail_ptr) && ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") if ((entry_ptr->is_pinned) || (entry_ptr->pinned_from_client) || (entry_ptr->pinned_from_cache)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") len++; size += entry_ptr->size; entry_ptr = entry_ptr->next; } - if ((cache_ptr->LRU_list_len != len) || (cache_ptr->LRU_list_size != size)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") + if ((cache_ptr->LRU_list_len != (uint32_t)len) || (cache_ptr->LRU_list_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") done: if (ret_value != SUCCEED) HDassert(0); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__validate_lru_list() */ +} /* H5C_validate_lru_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /*------------------------------------------------------------------------- * - * Function: H5C__validate_pinned_entry_list + * Function: H5C_validate_pinned_entry_list * * Purpose: Debugging function that scans the pinned entry list for * errors. @@ -7806,15 +7699,15 @@ H5C__validate_lru_list(H5C_t *cache_ptr) *------------------------------------------------------------------------- */ #if H5C_DO_EXTREME_SANITY_CHECKS -static herr_t -H5C__validate_pinned_entry_list(H5C_t *cache_ptr) +herr_t +H5C_validate_pinned_entry_list(H5C_t *cache_ptr) { int32_t len = 0; size_t size = 0; H5C_cache_entry_t *entry_ptr = NULL; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_NOAPI(FAIL) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); @@ -7823,54 +7716,51 @@ H5C__validate_pinned_entry_list(H5C_t *cache_ptr) (cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - if (cache_ptr->pel_len < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - if ((cache_ptr->pel_len == 1) && ((cache_ptr->pel_head_ptr != cache_ptr->pel_tail_ptr) || (cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_head_ptr->size != cache_ptr->pel_size))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") if ((cache_ptr->pel_len >= 1) && ((cache_ptr->pel_head_ptr == NULL) || (cache_ptr->pel_head_ptr->prev != NULL) || (cache_ptr->pel_tail_ptr == NULL) || (cache_ptr->pel_tail_ptr->next != NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") entry_ptr = cache_ptr->pel_head_ptr; while (entry_ptr != NULL) { if ((entry_ptr != cache_ptr->pel_head_ptr) && ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") if ((entry_ptr != cache_ptr->pel_tail_ptr) && ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") if (!entry_ptr->is_pinned) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") if (!(entry_ptr->pinned_from_client || entry_ptr->pinned_from_cache)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") len++; size += entry_ptr->size; entry_ptr = entry_ptr->next; } - if ((cache_ptr->pel_len != len) || (cache_ptr->pel_size != size)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 9 failed") + if ((cache_ptr->pel_len != (uint32_t)len) || (cache_ptr->pel_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") done: if (ret_value != SUCCEED) HDassert(0); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__validate_pinned_entry_list() */ +} /* H5C_validate_pinned_entry_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /*------------------------------------------------------------------------- * - * Function: H5C__validate_protected_entry_list + * Function: H5C_validate_protected_entry_list * * Purpose: Debugging function that scans the protected entry list for * errors. @@ -7886,15 +7776,15 @@ H5C__validate_pinned_entry_list(H5C_t *cache_ptr) *------------------------------------------------------------------------- */ #if H5C_DO_EXTREME_SANITY_CHECKS -static herr_t -H5C__validate_protected_entry_list(H5C_t *cache_ptr) +herr_t +H5C_validate_protected_entry_list(H5C_t *cache_ptr) { int32_t len = 0; size_t size = 0; H5C_cache_entry_t *entry_ptr = NULL; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_NOAPI(FAIL) HDassert(cache_ptr); HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); @@ -7903,54 +7793,51 @@ H5C__validate_protected_entry_list(H5C_t *cache_ptr) (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - if (cache_ptr->pl_len < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - if ((cache_ptr->pl_len == 1) && ((cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr) || (cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_head_ptr->size != cache_ptr->pl_size))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") if ((cache_ptr->pl_len >= 1) && ((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_head_ptr->prev != NULL) || (cache_ptr->pl_tail_ptr == NULL) || (cache_ptr->pl_tail_ptr->next != NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 3 failed") entry_ptr = cache_ptr->pl_head_ptr; while (entry_ptr != NULL) { if ((entry_ptr != cache_ptr->pl_head_ptr) && ((entry_ptr->prev == NULL) || (entry_ptr->prev->next != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 4 failed") if ((entry_ptr != cache_ptr->pl_tail_ptr) && ((entry_ptr->next == NULL) || (entry_ptr->next->prev != entry_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 5 failed") if (!entry_ptr->is_protected) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 6 failed") if (entry_ptr->is_read_only && (entry_ptr->ro_ref_count <= 0)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 7 failed") len++; size += entry_ptr->size; entry_ptr = entry_ptr->next; } - if ((cache_ptr->pl_len != len) || (cache_ptr->pl_size != size)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 9 failed") + if ((cache_ptr->pl_len != (uint32_t)len) || (cache_ptr->pl_size != size)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 8 failed") done: if (ret_value != SUCCEED) HDassert(0); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__validate_protected_entry_list() */ +} /* H5C_validate_protected_entry_list() */ #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /*------------------------------------------------------------------------- * - * Function: H5C__entry_in_skip_list + * Function: H5C_entry_in_skip_list * * Purpose: Debugging function that scans skip list to see if it * is in present. We need this, as it is possible for @@ -7964,8 +7851,8 @@ H5C__validate_protected_entry_list(H5C_t *cache_ptr) *------------------------------------------------------------------------- */ #if H5C_DO_SLIST_SANITY_CHECKS -static hbool_t -H5C__entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) +hbool_t +H5C_entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) { H5SL_node_t *node_ptr; hbool_t in_slist; @@ -7993,7 +7880,7 @@ H5C__entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr) } return (in_slist); -} /* H5C__entry_in_skip_list() */ +} /* H5C_entry_in_skip_list() */ #endif /* H5C_DO_SLIST_SANITY_CHECKS */ /*------------------------------------------------------------------------- @@ -8062,7 +7949,7 @@ H5C__flush_marked_entries(H5F_t *f) * To cork the object * Return error if the object is already corked * H5C__UNCORK: - * To uncork the obejct + * To uncork the object * Return error if the object is not corked * H5C__GET_CORKED: * To retrieve the cork status of an object in @@ -8079,7 +7966,7 @@ H5C__flush_marked_entries(H5F_t *f) herr_t H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) { - H5C_tag_info_t *tag_info; /* Points to a tag info struct */ + H5C_tag_info_t *tag_info = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -8090,7 +7977,7 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) HDassert(action == H5C__SET_CORK || action == H5C__UNCORK || action == H5C__GET_CORKED); /* Search the list of corked object addresses in the cache */ - tag_info = (H5C_tag_info_t *)H5SL_search(cache_ptr->tag_list, &obj_addr); + HASH_FIND(hh, cache_ptr->tag_list, &obj_addr, sizeof(haddr_t), tag_info); if (H5C__GET_CORKED == action) { HDassert(corked); @@ -8098,7 +7985,7 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) *corked = TRUE; else *corked = FALSE; - } /* end if */ + } else { /* Sanity check */ HDassert(H5C__SET_CORK == action || H5C__UNCORK == action); @@ -8114,25 +8001,24 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) /* Set the tag for all entries */ tag_info->tag = obj_addr; - /* Insert tag info into skip list */ - if (H5SL_insert(cache_ptr->tag_list, tag_info, &(tag_info->tag)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert tag info in skip list") - } /* end if */ + /* Insert tag info into hash table */ + HASH_ADD(hh, cache_ptr->tag_list, tag, sizeof(haddr_t), tag_info); + } else { /* Check for object already corked */ if (tag_info->corked) HGOTO_ERROR(H5E_CACHE, H5E_CANTCORK, FAIL, "object already corked") HDassert(tag_info->entry_cnt > 0 && tag_info->head); - } /* end else */ + } /* Set the corked status for the entire object */ tag_info->corked = TRUE; cache_ptr->num_objs_corked++; - - } /* end if */ + } else { /* Sanity check */ - HDassert(tag_info); + if (NULL == tag_info) + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNCORK, FAIL, "tag info pointer is NULL") /* Check for already uncorked */ if (!tag_info->corked) @@ -8147,16 +8033,15 @@ H5C_cork(H5C_t *cache_ptr, haddr_t obj_addr, unsigned action, hbool_t *corked) /* Sanity check */ HDassert(NULL == tag_info->head); - if (H5SL_remove(cache_ptr->tag_list, &(tag_info->tag)) != tag_info) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove tag info from list") + HASH_DELETE(hh, cache_ptr->tag_list, tag_info); /* Release the tag info */ tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); - } /* end if */ + } else HDassert(NULL != tag_info->head); - } /* end else */ - } /* end else */ + } + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -8443,7 +8328,7 @@ H5C__serialize_cache(H5F_t *f) uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ H5C_ring_t ring; - H5C_t * cache_ptr; + H5C_t *cache_ptr; herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -8483,8 +8368,8 @@ H5C__serialize_cache(H5F_t *f) #endif /* H5C_DO_SANITY_CHECKS */ #if H5C_DO_EXTREME_SANITY_CHECKS - if ((H5C__validate_protected_entry_list(cache_ptr) < 0) || - (H5C__validate_pinned_entry_list(cache_ptr) < 0) || (H5C__validate_lru_list(cache_ptr) < 0)) + if ((H5C_validate_protected_entry_list(cache_ptr) < 0) || + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -8493,7 +8378,7 @@ H5C__serialize_cache(H5F_t *f) * each entry in the cache to zero before we start the serialization. * This allows us to detect the case in which any entry is serialized * more than once (a performance issues), and more importantly, the - * case is which any flush depencency parent is serializes more than + * case is which any flush dependency parent is serializes more than * once (a correctness issue). */ { @@ -8612,7 +8497,7 @@ static herr_t H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) { hbool_t done = FALSE; - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5C_cache_entry_t *entry_ptr; herr_t ret_value = SUCCEED; @@ -8650,8 +8535,8 @@ H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) * are serialized correctly, it doesn't matter if we have to go back * and serialize an entry a second time. * - * These possible actions result in the following modfications to - * tha basic algorithm: + * These possible actions result in the following modifications to + * the basic algorithm: * * 1) In the event of an entry expunge, eviction or removal, we must * restart the scan as it is possible that the next entry in our @@ -8701,7 +8586,7 @@ H5C__serialize_ring(H5F_t *f, H5C_ring_t ring) * condition appears. * * Observe that either eviction or removal of entries as a result of - * a serialization is not a problem as long as the flush depencency + * a serialization is not a problem as long as the flush dependency * tree does not change beyond the removal of a leaf. */ while (!done) { @@ -9124,7 +9009,7 @@ herr_t H5C_remove_entry(void *_entry) { H5C_cache_entry_t *entry = (H5C_cache_entry_t *)_entry; /* Entry to remove */ - H5C_t * cache; /* Cache for file */ + H5C_t *cache; /* Cache for file */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5CS.c b/src/H5CS.c index 6510c252503..6ceff843df8 100644 --- a/src/H5CS.c +++ b/src/H5CS.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -47,7 +46,7 @@ typedef struct H5CS_t { * each thread individually. The association of stacks to threads will * be handled by the pthread library. * - * In order for this macro to work, H5CS_get_my_stack() must be preceeded + * In order for this macro to work, H5CS_get_my_stack() must be preceded * by "H5CS_t *fstack =". */ static H5CS_t *H5CS__get_stack(void); @@ -127,7 +126,7 @@ H5CS__get_stack(void) herr_t H5CS_print_stack(const H5CS_t *fstack, FILE *stream) { - const int indent = 2; /* Indention level */ + const int indent = 2; /* Indentation level */ int i; /* Local index ariable */ /* Don't push this function on the function stack... :-) */ @@ -244,10 +243,10 @@ H5CS_pop(void) H5CS_t * H5CS_copy_stack(void) { - H5CS_t * old_stack = H5CS_get_my_stack(); /* Existing function stack for library */ - H5CS_t * new_stack; /* New function stack, for copy */ + H5CS_t *old_stack = H5CS_get_my_stack(); /* Existing function stack for library */ + H5CS_t *new_stack; /* New function stack, for copy */ unsigned u; /* Local index variable */ - H5CS_t * ret_value = NULL; /* Return value */ + H5CS_t *ret_value = NULL; /* Return value */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOFS diff --git a/src/H5CSprivate.h b/src/H5CSprivate.h index a238ec7ad1f..5cdf2d5fdd3 100644 --- a/src/H5CSprivate.h +++ b/src/H5CSprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -17,10 +16,6 @@ #ifndef H5CSprivate_H #define H5CSprivate_H -#ifdef NOT_YET -#include "H5CSpublic.h" -#endif /* NOT_YET */ - /* Private headers needed by this file */ #include "H5private.h" diff --git a/src/H5CX.c b/src/H5CX.c index ff3620e28fa..54e1a2da61d 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -50,7 +50,7 @@ * each thread individually. The association of contexts to threads will * be handled by the pthread library. * - * In order for this macro to work, H5CX_get_my_context() must be preceeded + * In order for this macro to work, H5CX_get_my_context() must be preceded * by "H5CX_node_t *ctx =". */ #define H5CX_get_my_context() H5CX__get_context() @@ -218,9 +218,9 @@ typedef struct H5CX_t { /* Cached DXPL properties */ size_t max_temp_buf; /* Maximum temporary buffer size */ hbool_t max_temp_buf_valid; /* Whether maximum temporary buffer size is valid */ - void * tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ + void *tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ hbool_t tconv_buf_valid; /* Whether temporary conversion buffer is valid */ - void * bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ + void *bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ hbool_t bkgr_buf_valid; /* Whether background conversion buffer is valid */ H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_NAME) */ hbool_t bkgr_buf_type_valid; /* Whether background buffer type is valid */ @@ -237,7 +237,7 @@ typedef struct H5CX_t { H5FD_mpio_chunk_opt_t mpio_chunk_opt_mode; /* Collective chunk option (H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME) */ hbool_t mpio_chunk_opt_mode_valid; /* Whether collective chunk option is valid */ - unsigned mpio_chunk_opt_num; /* Collective chunk thrreshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ + unsigned mpio_chunk_opt_num; /* Collective chunk threshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ hbool_t mpio_chunk_opt_num_valid; /* Whether collective chunk threshold is valid */ unsigned mpio_chunk_opt_ratio; /* Collective chunk ratio (H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME) */ hbool_t mpio_chunk_opt_ratio_valid; /* Whether collective chunk ratio is valid */ @@ -246,7 +246,7 @@ typedef struct H5CX_t { hbool_t err_detect_valid; /* Whether error detection info is valid */ H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ hbool_t filter_cb_valid; /* Whether filter callback function is valid */ - H5Z_data_xform_t * data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ + H5Z_data_xform_t *data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ hbool_t data_transform_valid; /* Whether data transform info is valid */ H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ hbool_t vl_alloc_info_valid; /* Whether VL datatype alloc info is valid */ @@ -332,7 +332,7 @@ typedef struct H5CX_t { /* Cached VOL settings */ H5VL_connector_prop_t vol_connector_prop; /* Property for VOL connector ID & info */ hbool_t vol_connector_prop_valid; /* Whether property for VOL connector ID & info is valid */ - void * vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ + void *vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ hbool_t vol_wrap_ctx_valid; /* Whether VOL connector's "wrap context" for creating IDs is valid */ } H5CX_t; @@ -356,8 +356,8 @@ typedef struct H5CX_node_t { */ typedef struct H5CX_dxpl_cache_t { size_t max_temp_buf; /* Maximum temporary buffer size (H5D_XFER_MAX_TEMP_BUF_NAME) */ - void * tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ - void * bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ + void *tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ + void *bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_NAME) */ double btree_split_ratio[3]; /* B-tree split ratios (H5D_XFER_BTREE_SPLIT_RATIO_NAME) */ size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ @@ -371,12 +371,12 @@ typedef struct H5CX_dxpl_cache_t { (H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME) */ H5FD_mpio_chunk_opt_t mpio_chunk_opt_mode; /* Collective chunk option (H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME) */ - unsigned mpio_chunk_opt_num; /* Collective chunk thrreshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ + unsigned mpio_chunk_opt_num; /* Collective chunk threshold (H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME) */ unsigned mpio_chunk_opt_ratio; /* Collective chunk ratio (H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME) */ #endif /* H5_HAVE_PARALLEL */ H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ - H5Z_data_xform_t * data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ + H5Z_data_xform_t *data_transform; /* Data transform info (H5D_XFER_XFORM_NAME) */ H5T_vlen_alloc_info_t vl_alloc_info; /* VL datatype alloc info (H5D_XFER_VLEN_*_NAME) */ H5T_conv_cb_t dt_conv_cb; /* Datatype conversion struct (H5D_XFER_CONV_CB_NAME) */ } H5CX_dxpl_cache_t; @@ -949,7 +949,7 @@ H5CX_retrieve_state(H5CX_state_t **api_state) /* Copy connector info, if it exists */ if ((*api_state)->vol_connector_prop.connector_info) { H5VL_class_t *connector; /* Pointer to connector */ - void * new_connector_info = NULL; /* Copy of connector info */ + void *new_connector_info = NULL; /* Copy of connector info */ /* Retrieve the connector for the ID */ if (NULL == @@ -1366,7 +1366,7 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, * specified a collective metadata read for just this operation. */ if (!is_collective) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5P_coll_md_read_flag_t md_coll_read; /* Collective metadata read flag */ /* Get the plist structure for the access property list */ @@ -1392,9 +1392,7 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, /* If parallel is enabled and the file driver used is the MPI-IO * VFD, issue an MPI barrier for easier debugging if the API function - * calling this is supposed to be called collectively. Note that this - * happens only when the environment variable H5_COLL_BARRIER is set - * to non 0. + * calling this is supposed to be called collectively. */ if (H5_coll_api_sanity_check_g) { MPI_Comm mpi_comm; /* File communicator */ @@ -1420,7 +1418,7 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, * Purpose: Sanity checks and sets up collective operations. * * Note: Should be called for all API routines that modify file - * file metadata but don't pass in an access property list. + * metadata but don't pass in an access property list. * * Return: Non-negative on success / Negative on failure * @@ -1451,9 +1449,7 @@ H5CX_set_loc(hid_t /* If parallel is enabled and the file driver used is the MPI-IO * VFD, issue an MPI barrier for easier debugging if the API function - * calling this is supposed to be called collectively. Note that this - * happens only when the environment variable H5_COLL_BARRIER is set - * to non 0. + * calling this is supposed to be called collectively. */ if (H5_coll_api_sanity_check_g) { MPI_Comm mpi_comm; /* File communicator */ diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index f9289cb0e6f..fdbbbf6e825 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -16,11 +16,6 @@ #ifndef H5CXprivate_H #define H5CXprivate_H -/* Include package's public header */ -#ifdef NOT_YET -#include "H5CXpublic.h" -#endif /* NOT_YET */ - /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ @@ -43,7 +38,7 @@ typedef struct H5CX_state_t { hid_t dxpl_id; /* DXPL for operation */ hid_t lapl_id; /* LAPL for operation */ hid_t lcpl_id; /* LCPL for operation */ - void * vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ + void *vol_wrap_ctx; /* VOL connector's "wrap context" for creating IDs */ H5VL_connector_prop_t vol_connector_prop; /* VOL connector property */ #ifdef H5_HAVE_PARALLEL diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 104f1aff055..4d74a0ac1bd 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -79,7 +78,7 @@ herr_t H5C_dump_cache(H5C_t *cache_ptr, const char *cache_name) { H5C_cache_entry_t *entry_ptr; - H5SL_t * slist_ptr = NULL; + H5SL_t *slist_ptr = NULL; int i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -275,7 +274,7 @@ H5C_dump_cache_skip_list(H5C_t *cache_ptr, char *calling_fcn) herr_t ret_value = SUCCEED; /* Return value */ int i; H5C_cache_entry_t *entry_ptr = NULL; - H5SL_node_t * node_ptr = NULL; + H5SL_node_t *node_ptr = NULL; FUNC_ENTER_NOAPI_NOERR @@ -844,9 +843,9 @@ H5C_stats__reset(H5C_t H5_ATTR_UNUSED *cache_ptr) * If either the parent or the child is not in the metadata * cache, the function sets *fd_exists_ptr to FALSE. * - * If both are in the cache, the childs list of parents is + * If both are in the cache, the child's list of parents is * searched for the proposed parent. If the proposed parent - * is found in the childs parent list, the function sets + * is found in the child's parent list, the function sets * *fd_exists_ptr to TRUE. In all other non-error cases, * the function sets *fd_exists_ptr FALSE. * diff --git a/src/H5Cepoch.c b/src/H5Cepoch.c index 3434feddcc7..6daf979c8dc 100644 --- a/src/H5Cepoch.c +++ b/src/H5Cepoch.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -54,7 +53,7 @@ static herr_t H5C__epoch_marker_get_initial_load_size(void *udata_ptr, size_t *i static herr_t H5C__epoch_marker_get_final_load_size(const void *image_ptr, size_t image_len_ptr, void *udata_ptr, size_t *actual_len); static htri_t H5C__epoch_marker_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5C__epoch_marker_deserialize(const void *image_ptr, size_t len, void *udata, +static void *H5C__epoch_marker_deserialize(const void *image_ptr, size_t len, void *udata, hbool_t *dirty_ptr); static herr_t H5C__epoch_marker_image_len(const void *thing, size_t *image_len_ptr); static herr_t H5C__epoch_marker_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, @@ -64,7 +63,7 @@ static herr_t H5C__epoch_marker_serialize(const H5F_t *f, void *image_ptr, size_ static herr_t H5C__epoch_marker_notify(H5C_notify_action_t action, void *thing); static herr_t H5C__epoch_marker_free_icr(void *thing); static herr_t H5C__epoch_marker_fsf_size(const void H5_ATTR_UNUSED *thing, - hsize_t H5_ATTR_UNUSED *fsf_size_ptr); + hsize_t H5_ATTR_UNUSED *fsf_size_ptr); /*********************/ /* Package Variables */ diff --git a/src/H5Cimage.c b/src/H5Cimage.c index f17ff485b26..ae18a24fbdc 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -277,7 +276,7 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) { uint32_t old_chksum; const uint8_t *q; - H5C_t * fake_cache_ptr = NULL; + H5C_t *fake_cache_ptr = NULL; unsigned v; herr_t status; /* Status from decoding */ @@ -356,7 +355,7 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) /* compute the checksum */ old_chksum = chksum; chksum = H5_checksum_metadata(cache_ptr->image_buffer, - (size_t)(cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM), 0); + (size_t)(cache_ptr->image_data_len - H5F_SIZEOF_CHKSUM), 0); HDassert(chksum == old_chksum); fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(fake_cache_ptr->image_entries); @@ -444,7 +443,7 @@ H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr) * deserialized entry after it is inserted in the cache. * * Since deserializing a prefetched entry is semantically - * equivalent to a load, issue an entry loaded nofification + * equivalent to a load, issue an entry loaded notification * if the notify callback is defined. * * Return: SUCCEED on success, and FAIL on failure. @@ -467,7 +466,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t * dirtied during deserialize */ size_t len; /* Size of image in file */ - void * thing = NULL; /* Pointer to thing loaded */ + void *thing = NULL; /* Pointer to thing loaded */ H5C_cache_entry_t *pf_entry_ptr; /* pointer to the prefetched entry */ /* supplied in *entry_ptr_ptr. */ H5C_cache_entry_t *ds_entry_ptr; /* Alias for thing loaded, as cache @@ -591,7 +590,7 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t * * Note that at present, dirty can't be set to true with prefetched * entries. However this may change, so include this functionality - * against that posibility. + * against that possibility. * * Also, note that it is possible for a prefetched entry to be dirty -- * hence the value assigned to ds_entry_ptr->is_dirty below. @@ -997,6 +996,9 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) #endif /* H5_HAVE_PARALLEL */ /* Read the buffer (if serial access, or rank 0 of parallel access) */ + /* NOTE: if this block read is being performed on rank 0 only, throwing + * an error here will cause other ranks to hang in the following MPI_Bcast. + */ if (H5F_block_read(f, H5FD_MEM_SUPER, cache_ptr->image_addr, cache_ptr->image_len, cache_ptr->image_buffer) < 0) HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read metadata cache image block") @@ -1111,6 +1113,11 @@ H5C__load_cache_image(H5F_t *f) } /* end if */ done: + if (ret_value < 0) { + if (H5F_addr_defined(cache_ptr->image_addr)) + cache_ptr->image_buffer = H5MM_xfree(cache_ptr->image_buffer); + } + FUNC_LEAVE_NOAPI(ret_value) } /* H5C__load_cache_image() */ @@ -1129,7 +1136,7 @@ H5C__load_cache_image(H5F_t *f) * image superblock extension message must be deleted from * the superblock extension and the image block freed * - * Contrawise, if the file is openened R/O, the metadata + * Contrawise, if the file is opened R/O, the metadata * cache image superblock extension message and image block * must be left as is. Further, any dirty entries in the * cache image block must be marked as clean to avoid @@ -1270,7 +1277,7 @@ H5C__image_entry_cmp(const void *_entry1, const void *_entry2) herr_t H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) { - H5C_t * cache_ptr = NULL; + H5C_t *cache_ptr = NULL; haddr_t eoa_frag_addr = HADDR_UNDEF; hsize_t eoa_frag_size = 0; herr_t ret_value = SUCCEED; /* Return value */ @@ -1414,7 +1421,8 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated) if (HADDR_UNDEF == (cache_ptr->image_addr = H5FD_alloc(f->shared->lf, H5FD_MEM_SUPER, f, (hsize_t)(cache_ptr->image_data_len), &eoa_frag_addr, &eoa_frag_size))) - HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, "can't allocate file space for metadata cache image") + HGOTO_ERROR(H5E_CACHE, H5E_NOSPACE, FAIL, + "can't allocate file space for metadata cache image") /* Make note of the eoa after allocation of the cache image * block. This value is used for sanity checking when we @@ -1821,7 +1829,7 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t * * Purpose: Decode the metadata cache image entry from the supplied * buffer into the supplied instance of H5C_image_entry_t. * This includes allocating a buffer for the entry image, - * loading it, and seting ie_ptr->image_ptr to point to + * loading it, and setting ie_ptr->image_ptr to point to * the buffer. * * Advances the buffer pointer to the first byte @@ -1843,7 +1851,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint hbool_t is_fd_child = FALSE; /* Only used in assertions */ haddr_t addr; hsize_t size = 0; - void * image_ptr; + void *image_ptr; uint8_t flags = 0; uint8_t type_id; uint8_t ring; @@ -1851,10 +1859,10 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint uint16_t fd_child_count; uint16_t fd_dirty_child_count; uint16_t fd_parent_count; - haddr_t * fd_parent_addrs = NULL; + haddr_t *fd_parent_addrs = NULL; int32_t lru_rank; H5C_image_entry_t *ie_ptr = NULL; - const uint8_t * p; + const uint8_t *p; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2201,7 +2209,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne { H5C_image_entry_t *ie_ptr; /* Pointer to entry to encode */ uint8_t flags = 0; /* Flags for entry */ - uint8_t * p; /* Pointer into cache image buffer */ + uint8_t *p; /* Pointer into cache image buffer */ unsigned u; /* Local index value */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2338,7 +2346,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne * also be a flush dependency child. * * Finally, note that for purposes of the cache image, flush - * dependency height ends when a flush dependecy relation + * dependency height ends when a flush dependency relation * passes off the cache image. * * On exit, the flush dependency height of each entry in the @@ -2500,7 +2508,7 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr) entry_ptr = entry_ptr->il_next; } /* while (entry_ptr != NULL) */ - /* At present, no extenal parent or child flush dependency links + /* At present, no external parent or child flush dependency links * should exist -- hence the following assertions. This will change * if we support ageout of entries in the cache image. */ @@ -2687,10 +2695,11 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr) */ if (entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID) { image_entries[u].type_id = entry_ptr->prefetch_type_id; - image_entries[u].age = entry_ptr->age + 1; - if (image_entries[u].age > H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX) + if (entry_ptr->age >= H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX) image_entries[u].age = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__MAX; + else + image_entries[u].age = entry_ptr->age + 1; } /* end if */ else { image_entries[u].type_id = entry_ptr->type->id; @@ -3015,7 +3024,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) { H5C_cache_entry_t *pf_entry_ptr; /* Pointer to prefetched entry */ H5C_cache_entry_t *parent_ptr; /* Pointer to parent of prefetched entry */ - const uint8_t * p; /* Pointer into image buffer */ + const uint8_t *p; /* Pointer into image buffer */ unsigned u, v; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3227,7 +3236,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b hbool_t is_fd_parent = FALSE; hbool_t is_fd_child = FALSE; #endif /* NDEBUG */ /* only used in assertions */ - const uint8_t * p; + const uint8_t *p; hbool_t file_is_rw; H5C_cache_entry_t *ret_value = NULL; /* Return value */ @@ -3381,7 +3390,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b * creating if specified. * * In general, the size and location of the cache image block - * will be unknow at the time that the cache image superblock + * will be unknown at the time that the cache image superblock * message is created. A subsequent call to this routine will * be used to write the correct data. * @@ -3394,7 +3403,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b static herr_t H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5O_mdci_t mdci_msg; /* metadata cache image message */ /* to insert in the superblock */ /* extension. */ diff --git a/src/H5Clog.c b/src/H5Clog.c index 14b37d45a8e..25b3cf01c1a 100644 --- a/src/H5Clog.c +++ b/src/H5Clog.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Clog.h b/src/H5Clog.h index 790a0736be3..b3636c6c176 100644 --- a/src/H5Clog.h +++ b/src/H5Clog.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -82,7 +81,7 @@ struct H5C_log_info_t { hbool_t enabled; /* Was the logging set up? */ hbool_t logging; /* Are we currently logging? */ const H5C_log_class_t *cls; /* Callbacks for writing log messages */ - void * udata; /* Log-specific data */ + void *udata; /* Log-specific data */ }; /*****************************/ diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c index 18323ca74e9..fafb68c92e2 100644 --- a/src/H5Clog_json.c +++ b/src/H5Clog_json.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -209,7 +208,7 @@ herr_t H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) { H5C_log_json_udata_t *json_udata = NULL; - char * file_name = NULL; + char *file_name = NULL; size_t n_chars; herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Clog_trace.c b/src/H5Clog_trace.c index d33d1b05a65..31a589511bb 100644 --- a/src/H5Clog_trace.c +++ b/src/H5Clog_trace.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -204,7 +203,7 @@ herr_t H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) { H5C_log_trace_udata_t *trace_udata = NULL; - char * file_name = NULL; + char *file_name = NULL; size_t n_chars; herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c index 66c6601bf91..9fcb80fe6a4 100644 --- a/src/H5Cmpio.c +++ b/src/H5Cmpio.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -164,7 +163,7 @@ H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, ha unsigned last_entry_to_flush; unsigned total_entries_to_clear = 0; unsigned total_entries_to_flush = 0; - unsigned * candidate_assignment_table = NULL; + unsigned *candidate_assignment_table = NULL; unsigned entries_to_flush[H5C_RING_NTYPES]; unsigned entries_to_clear[H5C_RING_NTYPES]; haddr_t addr; @@ -673,7 +672,7 @@ H5C_construct_candidate_list__min_clean(H5C_t *cache_ptr) herr_t H5C_mark_entries_as_clean(H5F_t *f, unsigned ce_array_len, haddr_t *ce_array_ptr) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; unsigned entries_cleared; unsigned pinned_entries_cleared; hbool_t progress; @@ -939,13 +938,13 @@ H5C_clear_coll_entries(H5C_t *cache_ptr, hbool_t partial) static herr_t H5C__collective_write(H5F_t *f) { - H5AC_t * cache_ptr; + H5AC_t *cache_ptr; H5FD_mpio_xfer_t orig_xfer_mode = H5FD_MPIO_COLLECTIVE; - void * base_buf; + void *base_buf; int count; - int * length_array = NULL; - MPI_Aint * buf_array = NULL; - MPI_Aint * offset_array = NULL; + int *length_array = NULL; + MPI_Aint *buf_array = NULL; + MPI_Aint *offset_array = NULL; MPI_Datatype btype = MPI_BYTE; MPI_Datatype ftype = MPI_BYTE; int mpi_code; @@ -972,7 +971,7 @@ H5C__collective_write(H5F_t *f) /* Get number of entries in collective write list */ count = (int)H5SL_count(cache_ptr->coll_write_list); if (count > 0) { - H5SL_node_t * node; + H5SL_node_t *node; H5C_cache_entry_t *entry_ptr; int i; @@ -1095,7 +1094,7 @@ H5C__collective_write(H5F_t *f) * * Note that this function is a modified version of * H5C_flush_cache() -- any changes there may need to be - * reflected here and vise versa. + * reflected here and vice versa. * * Return: Non-negative on success/Negative on failure. * @@ -1120,7 +1119,7 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES uint32_t slist_len = 0; #endif /* H5C_DO_SANITY_CHECKS */ H5C_ring_t ring; - H5C_t * cache_ptr; + H5C_t *cache_ptr; herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1227,7 +1226,7 @@ H5C__flush_candidate_entries(H5F_t *f, unsigned entries_to_flush[H5C_RING_NTYPES static herr_t H5C__flush_candidates_in_ring(H5F_t *f, H5C_ring_t ring, unsigned entries_to_flush, unsigned entries_to_clear) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; hbool_t progress; hbool_t restart_scan = FALSE; unsigned entries_flushed = 0; diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 99ed4f8dad2..64b0c5df9c6 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -1011,7 +1010,7 @@ if ( ( (cache_ptr) == NULL ) || \ ( H5C__HASH_FCN((entry_ptr)->addr) >= H5C__HASH_TABLE_LEN ) || \ ( (cache_ptr)->index_size != \ ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ + (cache_ptr)->dirty_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ @@ -1034,7 +1033,7 @@ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) || \ ( (cache_ptr)->index_size != \ ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ + (cache_ptr)->dirty_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] == 0 ) || \ @@ -1071,7 +1070,7 @@ if ( ( (cache_ptr) == NULL ) || \ ( (entry_ptr)->ht_prev != NULL ) ) || \ ( (cache_ptr)->index_size != \ ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ + (cache_ptr)->dirty_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ @@ -1102,7 +1101,7 @@ if ( ( (cache_ptr) == NULL ) || \ ( (entry_ptr)->ht_prev != NULL ) || \ ( (cache_ptr)->index_size != \ ((cache_ptr)->clean_index_size + \ - (cache_ptr)->dirty_index_size) ) || \ + (cache_ptr)->dirty_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ @@ -1161,7 +1160,7 @@ if ( ( (cache_ptr) == NULL ) || \ } #define H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ + entry_ptr, was_clean) \ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->index_len <= 0 ) || \ ( (cache_ptr)->index_size <= 0 ) || \ @@ -1175,9 +1174,9 @@ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ ( ( !( was_clean ) || \ - ( (cache_ptr)->clean_index_size < (old_size) ) ) && \ - ( ( (was_clean) ) || \ - ( (cache_ptr)->dirty_index_size < (old_size) ) ) ) || \ + ( (cache_ptr)->clean_index_size < (old_size) ) ) && \ + ( ( (was_clean) ) || \ + ( (cache_ptr)->dirty_index_size < (old_size) ) ) ) || \ ( (entry_ptr) == NULL ) || \ ( (entry_ptr)->ring <= H5C_RING_UNDEFINED ) || \ ( (entry_ptr)->ring >= H5C_RING_NTYPES ) || \ @@ -1196,20 +1195,20 @@ if ( ( (cache_ptr) == NULL ) || \ } #define H5C__POST_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr) \ + entry_ptr) \ if ( ( (cache_ptr) == NULL ) || \ ( (cache_ptr)->index_len <= 0 ) || \ ( (cache_ptr)->index_size <= 0 ) || \ ( (new_size) > (cache_ptr)->index_size ) || \ ( (cache_ptr)->index_size != \ - ((cache_ptr)->clean_index_size + \ + ((cache_ptr)->clean_index_size + \ (cache_ptr)->dirty_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->clean_index_size) ) || \ ( (cache_ptr)->index_size < ((cache_ptr)->dirty_index_size) ) || \ ( ( !((entry_ptr)->is_dirty ) || \ - ( (cache_ptr)->dirty_index_size < (new_size) ) ) && \ - ( ( ((entry_ptr)->is_dirty) ) || \ - ( (cache_ptr)->clean_index_size < (new_size) ) ) ) || \ + ( (cache_ptr)->dirty_index_size < (new_size) ) ) && \ + ( ( ((entry_ptr)->is_dirty) ) || \ + ( (cache_ptr)->clean_index_size < (new_size) ) ) ) || \ ( ( (cache_ptr)->index_len == 1 ) && \ ( (cache_ptr)->index_size != (new_size) ) ) || \ ( (cache_ptr)->index_ring_len[(entry_ptr)->ring] > \ @@ -1465,10 +1464,10 @@ if ( ( (cache_ptr)->index_size != \ H5C__PRE_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ (cache_ptr)->dirty_index_size -= (entry_ptr)->size; \ ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ + -= (entry_ptr)->size; \ (cache_ptr)->clean_index_size += (entry_ptr)->size; \ ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ + += (entry_ptr)->size; \ H5C__POST_HT_UPDATE_FOR_ENTRY_CLEAN_SC(cache_ptr, entry_ptr); \ } @@ -1477,18 +1476,18 @@ if ( ( (cache_ptr)->index_size != \ H5C__PRE_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ (cache_ptr)->clean_index_size -= (entry_ptr)->size; \ ((cache_ptr)->clean_index_ring_size[entry_ptr->ring]) \ - -= (entry_ptr)->size; \ + -= (entry_ptr)->size; \ (cache_ptr)->dirty_index_size += (entry_ptr)->size; \ ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring]) \ - += (entry_ptr)->size; \ + += (entry_ptr)->size; \ H5C__POST_HT_UPDATE_FOR_ENTRY_DIRTY_SC(cache_ptr, entry_ptr); \ } #define H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ + entry_ptr, was_clean) \ { \ H5C__PRE_HT_ENTRY_SIZE_CHANGE_SC(cache_ptr, old_size, new_size, \ - entry_ptr, was_clean) \ + entry_ptr, was_clean) \ (cache_ptr)->index_size -= (old_size); \ (cache_ptr)->index_size += (new_size); \ ((cache_ptr)->index_ring_size[entry_ptr->ring]) -= (old_size); \ @@ -1497,14 +1496,14 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->clean_index_size -= (old_size); \ ((cache_ptr)->clean_index_ring_size[entry_ptr->ring])-= (old_size); \ } else { \ - (cache_ptr)->dirty_index_size -= (old_size); \ + (cache_ptr)->dirty_index_size -= (old_size); \ ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring])-= (old_size); \ } \ if((entry_ptr)->is_dirty) { \ (cache_ptr)->dirty_index_size += (new_size); \ ((cache_ptr)->dirty_index_ring_size[entry_ptr->ring])+= (new_size); \ } else { \ - (cache_ptr)->clean_index_size += (new_size); \ + (cache_ptr)->clean_index_size += (new_size); \ ((cache_ptr)->clean_index_ring_size[entry_ptr->ring])+= (new_size); \ } \ H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->il_len, \ @@ -1597,7 +1596,7 @@ if ( ( (cache_ptr)->index_size != \ * * H5C_DO_SLIST_SANITY_CHECKS * - * can be selected independantly. This is easy to miss as the + * can be selected independently. This is easy to miss as the * two #defines are easy to confuse. */ @@ -1791,7 +1790,7 @@ if ( ( (cache_ptr)->index_size != \ } else { /* slist disabled */ \ \ HDassert( (cache_ptr)->slist_len == 0 ); \ - HDassert( (cache_ptr)->slist_size == 0 ); \ + HDassert( (cache_ptr)->slist_size == 0 ); \ } \ } /* H5C__REMOVE_ENTRY_FROM_SLIST */ @@ -2033,16 +2032,16 @@ if ( ( (cache_ptr)->index_size != \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head.\ - */ \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* Use the dirty flag to infer whether the entry is on the clean or \ @@ -2096,16 +2095,16 @@ if ( ( (cache_ptr)->index_size != \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head \ - */ \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2288,28 +2287,28 @@ if ( ( (cache_ptr)->index_size != \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ - */ \ + * head. \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* since the entry is being flushed or cleared, one would think \ - * that it must be dirty -- but that need not be the case. Use the \ - * dirty flag to infer whether the entry is on the clean or dirty \ - * LRU list, and remove it. Then insert it at the head of the \ - * clean LRU list. \ + * that it must be dirty -- but that need not be the case. Use the \ + * dirty flag to infer whether the entry is on the clean or dirty \ + * LRU list, and remove it. Then insert it at the head of the \ + * clean LRU list. \ * \ * The function presumes that a dirty entry will be either cleared \ - * or flushed shortly, so it is OK if we put a dirty entry on the \ - * clean LRU list. \ + * or flushed shortly, so it is OK if we put a dirty entry on the \ + * clean LRU list. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ @@ -2350,17 +2349,17 @@ if ( ( (cache_ptr)->index_size != \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the \ - * head. \ - */ \ + * head. \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2424,7 +2423,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* insert the entry at the tail of the clean or dirty LRU list as \ @@ -2465,7 +2464,7 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->pel_tail_ptr, \ (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ - \ + \ } else { \ \ /* modified LRU specific code */ \ @@ -2474,7 +2473,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_APPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2558,7 +2557,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* insert the entry at the head of the clean or dirty LRU list as \ @@ -2599,7 +2598,7 @@ if ( ( (cache_ptr)->index_size != \ (cache_ptr)->pel_tail_ptr, \ (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ - \ + \ } else { \ \ /* modified LRU specific code */ \ @@ -2608,7 +2607,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2677,12 +2676,12 @@ if ( ( (cache_ptr)->index_size != \ HDassert( !((entry_ptr)->is_read_only) ); \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ - \ + \ if ( (entry_ptr)->is_pinned ) { \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ \ } else { \ @@ -2693,7 +2692,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* Similarly, remove the entry from the clean or dirty LRU list \ @@ -2739,12 +2738,12 @@ if ( ( (cache_ptr)->index_size != \ HDassert( !((entry_ptr)->is_read_only) ); \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ - \ + \ if ( (entry_ptr)->is_pinned ) { \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->pel_head_ptr, \ - (cache_ptr)->pel_tail_ptr, \ - (cache_ptr)->pel_len, \ + (cache_ptr)->pel_tail_ptr, \ + (cache_ptr)->pel_len, \ (cache_ptr)->pel_size, (fail_val)) \ \ } else { \ @@ -2755,7 +2754,7 @@ if ( ( (cache_ptr)->index_size != \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2804,21 +2803,21 @@ if ( ( (cache_ptr)->index_size != \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) { \ - \ + if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) {\ + \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* remove the entry from either the clean or dirty LUR list as \ @@ -2827,7 +2826,7 @@ if ( ( (cache_ptr)->index_size != \ if ( was_dirty ) { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, \ @@ -2836,34 +2835,34 @@ if ( ( (cache_ptr)->index_size != \ } else { \ \ H5C__AUX_DLL_REMOVE((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ + (fail_val)) \ } \ \ /* insert the entry at the head of either the clean or dirty \ - * LRU list as appropriate. \ + * LRU list as appropriate. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ \ H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->dLRU_head_ptr, \ + (cache_ptr)->dLRU_head_ptr, \ (cache_ptr)->dLRU_tail_ptr, \ (cache_ptr)->dLRU_list_len, \ (cache_ptr)->dLRU_list_size, \ - (fail_val)) \ + (fail_val)) \ \ } else { \ \ H5C__AUX_DLL_PREPEND((entry_ptr), \ - (cache_ptr)->cLRU_head_ptr, \ + (cache_ptr)->cLRU_head_ptr, \ (cache_ptr)->cLRU_tail_ptr, \ (cache_ptr)->cLRU_list_len, \ (cache_ptr)->cLRU_list_size, \ - (fail_val)) \ + (fail_val)) \ } \ \ /* End modified LRU specific code. */ \ @@ -2872,7 +2871,7 @@ if ( ( (cache_ptr)->index_size != \ #else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ -#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ +#define H5C__UPDATE_RP_FOR_MOVE(cache_ptr, entry_ptr, was_dirty, fail_val) \ { \ HDassert( (cache_ptr) ); \ HDassert( (cache_ptr)->magic == H5C__H5C_T_MAGIC ); \ @@ -2881,21 +2880,21 @@ if ( ( (cache_ptr)->index_size != \ HDassert( ((entry_ptr)->ro_ref_count) == 0 ); \ HDassert( (entry_ptr)->size > 0 ); \ \ - if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) { \ - \ + if ( ! ( (entry_ptr)->is_pinned ) && ! ( (entry_ptr->is_protected ) ) ) {\ + \ /* modified LRU specific code */ \ \ /* remove the entry from the LRU list, and re-insert it at the head. \ - */ \ + */ \ \ H5C__DLL_REMOVE((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ H5C__DLL_PREPEND((entry_ptr), (cache_ptr)->LRU_head_ptr, \ (cache_ptr)->LRU_tail_ptr, \ - (cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_len, \ (cache_ptr)->LRU_list_size, (fail_val)) \ \ /* End modified LRU specific code. */ \ @@ -2952,49 +2951,49 @@ if ( ( (cache_ptr)->index_size != \ \ if ( (entry_ptr)->coll_access ) { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, \ - (cache_ptr)->coll_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->coll_list_len, \ + (cache_ptr)->coll_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ } \ \ if ( (entry_ptr)->is_pinned ) { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, \ - (entry_ptr)->size, \ - (new_size)); \ - \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, \ + (entry_ptr)->size, \ + (new_size)); \ + \ } else { \ \ /* modified LRU specific code */ \ \ - /* Update the size of the LRU list */ \ + /* Update the size of the LRU list */ \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ \ /* Similarly, update the size of the clean or dirty LRU list as \ - * appropriate. At present, the entry must be clean, but that \ - * could change. \ + * appropriate. At present, the entry must be clean, but that \ + * could change. \ */ \ \ if ( (entry_ptr)->is_dirty ) { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, \ - (cache_ptr)->dLRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->dLRU_list_len, \ + (cache_ptr)->dLRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ \ } else { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, \ - (cache_ptr)->cLRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->cLRU_list_len, \ + (cache_ptr)->cLRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ } \ \ /* End modified LRU specific code. */ \ @@ -3017,21 +3016,21 @@ if ( ( (cache_ptr)->index_size != \ \ if ( (entry_ptr)->is_pinned ) { \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ - (cache_ptr)->pel_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->pel_len, \ + (cache_ptr)->pel_size, \ + (entry_ptr)->size, \ + (new_size)); \ \ } else { \ \ /* modified LRU specific code */ \ \ - /* Update the size of the LRU list */ \ + /* Update the size of the LRU list */ \ \ - H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ - (cache_ptr)->LRU_list_size, \ - (entry_ptr)->size, \ - (new_size)); \ + H5C__DLL_UPDATE_FOR_SIZE_CHANGE((cache_ptr)->LRU_list_len, \ + (cache_ptr)->LRU_list_size, \ + (entry_ptr)->size, \ + (new_size)); \ \ /* End modified LRU specific code. */ \ } \ @@ -3318,7 +3317,7 @@ if ( ( (hd_ptr) == NULL ) || \ ( (Size) < (entry_ptr)->size ) || \ ( ( (Size) == (entry_ptr)->size ) && ( ! ( (len) == 1 ) ) ) || \ ( ( (entry_ptr)->coll_prev == NULL ) && ( (hd_ptr) != (entry_ptr) ) ) || \ - ( ( (entry_ptr)->coll_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) || \ + ( ( (entry_ptr)->coll_next == NULL ) && ( (tail_ptr) != (entry_ptr) ) ) ||\ ( ( (len) == 1 ) && \ ( ! ( ( (hd_ptr) == (entry_ptr) ) && ( (tail_ptr) == (entry_ptr) ) && \ ( (entry_ptr)->coll_next == NULL ) && \ @@ -3350,10 +3349,10 @@ if ( ( ( ( (head_ptr) == NULL ) || ( (tail_ptr) == NULL ) ) && \ ) \ ) { \ HDassert(0 && "COLL DLL sanity check failed"); \ - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed") \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, (fv), "COLL DLL sanity check failed")\ } -#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv) \ +#define H5C__COLL_DLL_PRE_INSERT_SC(entry_ptr, hd_ptr, tail_ptr, len, Size, fv)\ if ( ( (entry_ptr) == NULL ) || \ ( (entry_ptr)->coll_next != NULL ) || \ ( (entry_ptr)->coll_prev != NULL ) || \ @@ -3566,15 +3565,17 @@ if ( ( (entry_ptr) == NULL ) || \ * * The fields of this structure are discussed individually below: * - * tag: Address (i.e. "tag") of the object header for all the entries + * tag: Address (i.e. "tag") of the object header for all the entries * corresponding to parts of that object. * - * head: Head of doubly-linked list of all entries belonging to the tag. + * head: Head of doubly-linked list of all entries belonging to the tag. * - * entry_cnt: Number of entries on linked list of entries for this tag. + * entry_cnt: Number of entries on linked list of entries for this tag. * - * corked: Boolean flag indicating whether entries for this object can be - * evicted. + * corked: Boolean flag indicating whether entries for this object can be + * evicted. + * + * hh: uthash hash table handle (must be last) * ****************************************************************************/ typedef struct H5C_tag_info_t { @@ -3582,6 +3583,9 @@ typedef struct H5C_tag_info_t { H5C_cache_entry_t *head; /* Head of the list of entries for this tag */ size_t entry_cnt; /* Number of entries on list */ hbool_t corked; /* Whether this object is corked */ + + /* Hash table fields */ + UT_hash_handle hh; /* Hash table handle (must be LAST) */ } H5C_tag_info_t; @@ -3974,15 +3978,15 @@ typedef struct H5C_tag_info_t { * * The following fields are maintained to facilitate this. * - * tag_list: A skip list to track entries that belong to an object. - * Each H5C_tag_info_t struct on the tag list corresponds to - * a particular object in the file. Tagged entries can be - * flushed or evicted as a group, or corked to prevent entries - * from being evicted from the cache. + * tag_list: A collection to track entries that belong to an object. + * Each H5C_tag_info_t struct on the tag list corresponds to a + * particular object in the file. Tagged entries can be flushed + * or evicted as a group, or corked to prevent entries from being + * evicted from the cache. * - * "Global" entries, like the superblock and the file's - * freelist, as well as shared entries like global - * heaps and shared object header messages, are not tagged. + * "Global" entries, like the superblock and the file's freelist, + * as well as shared entries like global heaps and shared object + * header messages, are not tagged. * * ignore_tags: Boolean flag to disable tag validation during entry insertion. * @@ -4726,7 +4730,7 @@ typedef struct H5C_tag_info_t { * * Fields for tracking prefetched entries. Note that flushes and evictions * of prefetched entries are tracked in the flushes and evictions arrays - * discused above. + * discussed above. * * prefetches: Number of prefetched entries that are loaded to the * cache. @@ -4863,7 +4867,7 @@ struct H5C_t { #endif /* H5C_DO_SANITY_CHECKS */ /* Fields for maintaining list of tagged entries */ - H5SL_t * tag_list; + H5C_tag_info_t * tag_list; hbool_t ignore_tags; uint32_t num_objs_corked; @@ -5074,7 +5078,7 @@ H5_DLL herr_t H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr); H5_DLL herr_t H5C__load_cache_image(H5F_t *f); H5_DLL herr_t H5C__mark_flush_dep_serialized(H5C_cache_entry_t * entry_ptr); H5_DLL herr_t H5C__mark_flush_dep_unserialized(H5C_cache_entry_t * entry_ptr); -H5_DLL herr_t H5C__make_space_in_cache(H5F_t * f, size_t space_needed, +H5_DLL herr_t H5C__make_space_in_cache(H5F_t * f, size_t space_needed, hbool_t write_permitted); H5_DLL herr_t H5C__flush_marked_entries(H5F_t * f); H5_DLL herr_t H5C__serialize_cache(H5F_t *f); diff --git a/src/H5Cprefetched.c b/src/H5Cprefetched.c index 07fca2bd193..6ec013d5535 100644 --- a/src/H5Cprefetched.c +++ b/src/H5Cprefetched.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -51,7 +50,7 @@ static herr_t H5C__prefetched_entry_get_initial_load_size(void *udata_ptr, size_ static herr_t H5C__prefetched_entry_get_final_load_size(const void *image_ptr, size_t image_len, void *udata_ptr, size_t *actual_len_ptr); static htri_t H5C__prefetched_entry_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5C__prefetched_entry_deserialize(const void *image_ptr, size_t len, void *udata, +static void *H5C__prefetched_entry_deserialize(const void *image_ptr, size_t len, void *udata, hbool_t *dirty_ptr); static herr_t H5C__prefetched_entry_image_len(const void *thing, size_t *image_len_ptr); static herr_t H5C__prefetched_entry_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, @@ -106,7 +105,7 @@ const H5AC_class_t H5AC_PREFETCHED_ENTRY[1] = {{ ***************************************************************************/ static herr_t -H5C__prefetched_entry_get_initial_load_size(void H5_ATTR_UNUSED *udata_ptr, +H5C__prefetched_entry_get_initial_load_size(void H5_ATTR_UNUSED *udata_ptr, size_t H5_ATTR_UNUSED *image_len_ptr) { FUNC_ENTER_STATIC_NOERR /* Yes, even though this pushes an error on the stack */ @@ -302,7 +301,7 @@ H5C__prefetched_entry_free_icr(void *_thing) HDassert(entry_ptr->fd_parent_count == 0); if (entry_ptr->image_ptr != NULL) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "prefetched entry image buffer still attatched?") + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "prefetched entry image buffer still attached?") entry_ptr = H5FL_FREE(H5C_cache_entry_t, entry_ptr); diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 27a24c41bca..e424964393f 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -213,7 +212,7 @@ #define H5C_DO_TAGGING_SANITY_CHECKS 1 #define H5C_DO_EXTREME_SANITY_CHECKS 0 #else /* NDEBUG */ -/* With rare execptions, the following defines should be set +/* With rare exceptions, the following defines should be set * to 0 if NDEBUG is defined */ #define H5C_DO_SANITY_CHECKS 0 @@ -542,7 +541,7 @@ typedef struct H5C_t H5C_t; * ensure that the entry is ready to be flushed -- in particular, * if the entry contains references to other entries that are in * temporary file space, the pre-serialize callback must move those - * entries into real file space so that the serialzed entry will + * entries into real file space so that the serialized entry will * contain no invalid data. * * One would think that the base address and length of @@ -884,7 +883,7 @@ typedef herr_t (*H5C_get_fsf_size_t)(const void *thing, hsize_t *fsf_size_ptr); /* Metadata cache client class definition */ typedef struct H5C_class_t { int id; - const char * name; + const char *name; H5FD_mem_t mem_type; unsigned flags; H5C_get_initial_load_size_func_t get_initial_load_size; @@ -924,7 +923,7 @@ typedef herr_t (*H5C_log_flush_func_t)(H5C_t *cache_ptr, haddr_t addr, hbool_t w * instead would apply unnecessary constraints on flushes under normal * operating circumstances. * - * As of this writing, all metadata entries pretaining to data sets and + * As of this writing, all metadata entries pertaining to data sets and * groups must be flushed first, and are thus assigned to the outermost * ring. * @@ -1428,7 +1427,7 @@ typedef int H5C_ring_t; * with no flush dependency children. * * Since the image_fd_height is used to order entries in the - * cache image so that fd parents preceed fd children, for + * cache image so that fd parents precede fd children, for * purposes of this field, and entry is at flush dependency * level 0 if it either has no children, or if all of its * children are not in the cache image. @@ -1543,7 +1542,7 @@ typedef int H5C_ring_t; * number of times each entry is serialized during cache * serialization. While no entry should be serialized more than * once in any serialization call, throw an assertion if any - * flush depencency parent is serialized more than once during + * flush dependency parent is serialized more than once during * a single cache serialization. * * This is a debugging field, and thus is maintained only if @@ -1591,10 +1590,10 @@ typedef int H5C_ring_t; ****************************************************************************/ typedef struct H5C_cache_entry_t { uint32_t magic; - H5C_t * cache_ptr; + H5C_t *cache_ptr; haddr_t addr; size_t size; - void * image_ptr; + void *image_ptr; hbool_t image_up_to_date; const H5C_class_t *type; hbool_t is_dirty; @@ -1666,7 +1665,7 @@ typedef struct H5C_cache_entry_t { /* fields supporting tag lists */ struct H5C_cache_entry_t *tl_next; struct H5C_cache_entry_t *tl_prev; - struct H5C_tag_info_t * tag_info; + struct H5C_tag_info_t *tag_info; #if H5C_COLLECT_CACHE_ENTRY_STATS /* cache entry stats fields */ @@ -1734,7 +1733,7 @@ typedef struct H5C_cache_entry_t { * with no flush dependency children. * * Since the image_fd_height is used to order entries in the - * cache image so that fd parents preceed fd children, for + * cache image so that fd parents precede fd children, for * purposes of this field, an entry is at flush dependency * level 0 if it either has no children, or if all of its * children are not in the cache image. @@ -1832,10 +1831,10 @@ typedef struct H5C_image_entry_t { hbool_t is_dirty; unsigned image_fd_height; uint64_t fd_parent_count; - haddr_t * fd_parent_addrs; + haddr_t *fd_parent_addrs; uint64_t fd_child_count; uint64_t fd_dirty_child_count; - void * image_ptr; + void *image_ptr; } H5C_image_entry_t; /**************************************************************************** @@ -2177,7 +2176,7 @@ typedef struct H5C_auto_size_ctl_t { * equivalent of H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE. * * flags: Unsigned integer containing flags controlling which aspects of the - * cache image functinality is actually executed. The primary impetus + * cache image functionality is actually executed. The primary impetus * behind this field is to allow development of tests for partial * implementations that will require little if any modification to run * with the full implementation. In normal operation, all flags should @@ -2221,7 +2220,7 @@ typedef enum H5C_log_style_t { H5C_LOG_STYLE_JSON, H5C_LOG_STYLE_TRACE } H5C_log /***************************************/ H5_DLL H5C_t *H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, - const H5C_class_t *const * class_table_ptr, + const H5C_class_t *const *class_table_ptr, H5C_write_permitted_func_t check_write_permitted, hbool_t write_permitted, H5C_log_flush_func_t log_flush, void *aux_ptr); H5_DLL void H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, int32_t version, double hit_rate, @@ -2251,7 +2250,7 @@ H5_DLL herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, size_t *size_pt hbool_t *is_corked_ptr, hbool_t *is_flush_dep_parent_ptr, hbool_t *is_flush_dep_child_ptr, hbool_t *image_up_to_date_ptr); H5_DLL herr_t H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t *evictions_enabled_ptr); -H5_DLL void * H5C_get_aux_ptr(const H5C_t *cache_ptr); +H5_DLL void *H5C_get_aux_ptr(const H5C_t *cache_ptr); H5_DLL herr_t H5C_image_stats(H5C_t *cache_ptr, hbool_t print_header); H5_DLL herr_t H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags); @@ -2264,7 +2263,7 @@ H5_DLL herr_t H5C_move_entry(H5C_t *cache_ptr, const H5C_class_t *type, haddr_t H5_DLL herr_t H5C_pin_protected_entry(void *thing); H5_DLL herr_t H5C_prep_for_file_close(H5F_t *f); H5_DLL herr_t H5C_create_flush_dependency(void *parent_thing, void *child_thing); -H5_DLL void * H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsigned flags); +H5_DLL void *H5C_protect(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *udata, unsigned flags); H5_DLL herr_t H5C_reset_cache_hit_rate_stats(H5C_t *cache_ptr); H5_DLL herr_t H5C_resize_entry(void *thing, size_t new_size); H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr); @@ -2292,6 +2291,16 @@ H5_DLL herr_t H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t * H5_DLL hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr); H5_DLL herr_t H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); +#if H5C_DO_SLIST_SANITY_CHECKS +H5_DLL hbool_t H5C_entry_in_skip_list(H5C_t *cache_ptr, H5C_cache_entry_t *target_ptr); +#endif + +#if H5C_DO_EXTREME_SANITY_CHECKS +H5_DLL herr_t H5C_validate_lru_list(H5C_t *cache_ptr); +H5_DLL herr_t H5C_validate_pinned_entry_list(H5C_t *cache_ptr); +H5_DLL herr_t H5C_validate_protected_entry_list(H5C_t *cache_ptr); +#endif /* H5C_DO_EXTREME_SANITY_CHECKS */ + /* Logging functions */ H5_DLL herr_t H5C_start_logging(H5C_t *cache); H5_DLL herr_t H5C_stop_logging(H5C_t *cache); diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h index 79ece102944..501a99b8a2f 100644 --- a/src/H5Cpublic.h +++ b/src/H5Cpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -27,10 +26,6 @@ /* Public headers needed by this file */ #include "H5public.h" -#ifdef __cplusplus -extern "C" { -#endif - enum H5C_cache_incr_mode { H5C_incr__off, /**tag_list, &tag); + HASH_FIND(hh, cache->tag_list, &tag, sizeof(haddr_t), tag_info); /* Check if this is the first entry for this tagged object */ if (NULL == tag_info) { @@ -251,10 +250,9 @@ H5C__tag_entry(H5C_t *cache, H5C_cache_entry_t *entry) /* Set the tag for all entries */ tag_info->tag = tag; - /* Insert tag info into skip list */ - if (H5SL_insert(cache->tag_list, tag_info, &(tag_info->tag)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert tag info in skip list") - } /* end if */ + /* Insert tag info into the hash table */ + HASH_ADD(hh, cache->tag_list, tag, sizeof(haddr_t), tag_info); + } else HDassert(tag_info->corked || (tag_info->entry_cnt > 0 && tag_info->head)); @@ -295,7 +293,7 @@ H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) H5C_tag_info_t *tag_info; /* Points to a tag info struct */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR /* Assertions */ HDassert(cache != NULL); @@ -323,17 +321,14 @@ H5C__untag_entry(H5C_t *cache, H5C_cache_entry_t *entry) /* Sanity check */ HDassert(NULL == tag_info->head); - if (H5SL_remove(cache->tag_list, &(tag_info->tag)) != tag_info) - HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove tag info from list") - /* Release the tag info */ + HASH_DELETE(hh, cache->tag_list, tag_info); tag_info = H5FL_FREE(H5C_tag_info_t, tag_info); - } /* end if */ + } else HDassert(tag_info->corked || NULL != tag_info->head); - } /* end if */ + } -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C__untag_entry */ @@ -364,7 +359,7 @@ H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, v HDassert(cache->magic == H5C__H5C_T_MAGIC); /* Search the list of tagged object addresses in the cache */ - tag_info = (H5C_tag_info_t *)H5SL_search(cache->tag_list, &tag); + HASH_FIND(hh, cache->tag_list, &tag, sizeof(haddr_t), tag_info); /* If there's any entries for this tag, iterate over them */ if (tag_info) { @@ -505,7 +500,7 @@ H5C__evict_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) herr_t H5C_evict_tagged_entries(H5F_t *f, haddr_t tag, hbool_t match_global) { - H5C_t * cache; /* Pointer to cache structure */ + H5C_t *cache; /* Pointer to cache structure */ H5C_tag_iter_evict_ctx_t ctx; /* Context for iterator callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -756,7 +751,7 @@ H5C_flush_tagged_entries(H5F_t *f, haddr_t tag) * value specified by src_tag and changes it to the value * specified by dest_tag. * - * Return: SUCCEED or FAIL. + * Return: SUCCEED/FAIL * * Programmer: Mike McGreevy * March 17, 2010 @@ -766,27 +761,28 @@ H5C_flush_tagged_entries(H5F_t *f, haddr_t tag) herr_t H5C_retag_entries(H5C_t *cache, haddr_t src_tag, haddr_t dest_tag) { - H5C_tag_info_t *tag_info; /* Points to a tag info struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5C_tag_info_t *tag_info = NULL; /* Function enter macro */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* Sanity check */ HDassert(cache); /* Remove tag info from tag list */ - if (NULL != (tag_info = (H5C_tag_info_t *)H5SL_remove(cache->tag_list, &src_tag))) { + HASH_FIND(hh, cache->tag_list, &src_tag, sizeof(haddr_t), tag_info); + if (NULL != tag_info) { + /* Remove info with old tag */ + HASH_DELETE(hh, cache->tag_list, tag_info); + /* Change to new tag */ tag_info->tag = dest_tag; - /* Re-insert tag info into skip list */ - if (H5SL_insert(cache->tag_list, tag_info, &(tag_info->tag)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "can't insert tag info in skip list") - } /* end if */ + /* Re-insert tag info into tag list */ + HASH_ADD(hh, cache->tag_list, tag, sizeof(haddr_t), tag_info); + } -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_retag_entries() */ /*------------------------------------------------------------------------- @@ -842,7 +838,7 @@ H5C__expunge_tag_type_metadata_cb(H5C_cache_entry_t *entry, void *_ctx) herr_t H5C_expunge_tag_type_metadata(H5F_t *f, haddr_t tag, int type_id, unsigned flags) { - H5C_t * cache; /* Pointer to cache structure */ + H5C_t *cache; /* Pointer to cache structure */ H5C_tag_iter_ettm_ctx_t ctx; /* Context for iterator callback */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Ctest.c b/src/H5Ctest.c index aa0641672c8..33f5fd52490 100644 --- a/src/H5Ctest.c +++ b/src/H5Ctest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -124,8 +123,8 @@ H5C__verify_cork_tag_test_cb(H5C_cache_entry_t *entry, void *_ctx) herr_t H5C__verify_cork_tag_test(hid_t fid, H5O_token_t tag_token, hbool_t status) { - H5F_t * f; /* File Pointer */ - H5C_t * cache; /* Cache Pointer */ + H5F_t *f; /* File Pointer */ + H5C_t *cache; /* Cache Pointer */ H5C_tag_iter_vct_ctx_t ctx; /* Context for iterator callback */ haddr_t tag; /* Tagged address */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5D.c b/src/H5D.c index b69391fad8f..c9c10543bd9 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -90,8 +89,8 @@ hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) { - void * dset = NULL; /* New dataset's info */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *dset = NULL; /* New dataset's info */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -187,8 +186,8 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - void * dset = NULL; /* dset object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + void *dset = NULL; /* dset object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ H5VL_loc_params_t loc_params; /* Location parameters for object access */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -253,8 +252,8 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) { - void * dset = NULL; /* dset object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *dset = NULL; /* dset object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -655,8 +654,8 @@ H5Dget_offset(hid_t dset_id) herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, void *operator_data) { - H5T_t * type; /* Datatype */ - H5S_t * space; /* Dataspace for iteration */ + H5T_t *type; /* Datatype */ + H5S_t *space; /* Dataspace for iteration */ H5S_sel_iter_op_t dset_op; /* Operator for iteration */ herr_t ret_value; /* Return value */ @@ -1126,3 +1125,51 @@ H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filte done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_chunk_info_by_coord() */ + +/*------------------------------------------------------------------------- + * Function: H5Dchunk_iter + * + * Purpose: Iterates over all chunks in dataset with given callback and user data. + * + * Parameters: + * hid_t dset_id; IN: Chunked dataset ID + * hid_t dxpl_id; IN: Dataset transfer property list ID + * H5D_chunk_iter_op_t cb IN: User callback function, called for every chunk. + * void *op_data IN/OUT: Optional user data passed on to user callback. + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Gaute Hope + * August 2020 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t op, void *op_data) +{ + H5VL_object_t *vol_obj = NULL; /* Dataset for this operation */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "iix*x", dset_id, dxpl_id, op, op_data); + + /* Check arguments */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") + if (NULL == op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback to chunk iteration") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") + + /* Iterate over the chunks */ + if ((ret_value = H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_ITER, dxpl_id, H5_REQUEST_NULL, + op, op_data)) < 0) + HGOTO_ERROR(H5E_BADITER, H5E_BADITER, FAIL, "error iterating over dataset chunks") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Dchunk_iter() */ diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index 861b4281bd4..12d151f5f86 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -75,7 +74,7 @@ typedef struct H5D_btree_key_t { typedef struct H5D_btree_it_ud_t { H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ H5D_chunk_cb_func_t cb; /* Chunk callback routine */ - void * udata; /* User data for chunk callback routine */ + void *udata; /* User data for chunk callback routine */ } H5D_btree_it_ud_t; /* B-tree callback info for debugging */ @@ -97,7 +96,7 @@ static int H5D__btree_idx_iterate_cb(H5F_t *f, const void *left_key, haddr_t add void *_udata); /* B-tree callbacks */ -static H5UC_t * H5D__btree_get_shared(const H5F_t *f, const void *_udata); +static H5UC_t *H5D__btree_get_shared(const H5F_t *f, const void *_udata); static herr_t H5D__btree_new_node(H5F_t *f, H5B_ins_t, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p /*out*/); static int H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key); @@ -241,7 +240,7 @@ H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, { H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; H5D_btree_key_t *rt_key = (H5D_btree_key_t *)_rt_key; - H5D_chunk_ud_t * udata = (H5D_chunk_ud_t *)_udata; + H5D_chunk_ud_t *udata = (H5D_chunk_ud_t *)_udata; unsigned u; herr_t ret_value = SUCCEED; /* Return value */ @@ -307,8 +306,8 @@ H5D__btree_new_node(H5F_t H5_ATTR_NDEBUG_UNUSED *f, H5B_ins_t op, void *_lt_key, static int H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key) { - H5D_btree_key_t * lt_key = (H5D_btree_key_t *)_lt_key; - H5D_btree_key_t * rt_key = (H5D_btree_key_t *)_rt_key; + H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; + H5D_btree_key_t *rt_key = (H5D_btree_key_t *)_rt_key; H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *)_udata; int ret_value = -1; /* Return value */ @@ -355,8 +354,8 @@ H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key) static int H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key) { - H5D_btree_key_t * lt_key = (H5D_btree_key_t *)_lt_key; - H5D_btree_key_t * rt_key = (H5D_btree_key_t *)_rt_key; + H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; + H5D_btree_key_t *rt_key = (H5D_btree_key_t *)_rt_key; H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *)_udata; int ret_value = 0; @@ -418,7 +417,7 @@ H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key) static htri_t H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, haddr_t addr, const void *_lt_key, void *_udata) { - H5D_chunk_ud_t * udata = (H5D_chunk_ud_t *)_udata; + H5D_chunk_ud_t *udata = (H5D_chunk_ud_t *)_udata; const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *)_lt_key; unsigned u; htri_t ret_value = TRUE; /* Return value */ @@ -519,7 +518,7 @@ H5D__btree_insert(H5F_t H5_ATTR_NDEBUG_UNUSED *f, haddr_t H5_ATTR_NDEBUG_UNUSED H5D_btree_key_t *lt_key = (H5D_btree_key_t *)_lt_key; H5D_btree_key_t *md_key = (H5D_btree_key_t *)_md_key; H5D_btree_key_t *rt_key = (H5D_btree_key_t *)_rt_key; - H5D_chunk_ud_t * udata = (H5D_chunk_ud_t *)_udata; + H5D_chunk_ud_t *udata = (H5D_chunk_ud_t *)_udata; int cmp; unsigned u; H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ @@ -638,7 +637,7 @@ static herr_t H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key) { const H5O_layout_chunk_t *layout; /* Chunk layout description */ - H5D_btree_key_t * key = (H5D_btree_key_t *)_key; /* Pointer to decoded key */ + H5D_btree_key_t *key = (H5D_btree_key_t *)_key; /* Pointer to decoded key */ hsize_t tmp_offset; /* Temporary coordinate offset, from file */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -662,7 +661,8 @@ H5D__btree_decode_key(const H5B_shared_t *shared, const uint8_t *raw, void *_key /* Retrieve coordinate offset */ UINT64DECODE(raw, tmp_offset); - HDassert(0 == (tmp_offset % layout->dim[u])); + if (0 != (tmp_offset % layout->dim[u])) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "bad coordinate offset"); /* Convert to a scaled offset */ key->scaled[u] = tmp_offset / layout->dim[u]; @@ -688,7 +688,7 @@ static herr_t H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) { const H5O_layout_chunk_t *layout; /* Chunk layout description */ - const H5D_btree_key_t * key = (const H5D_btree_key_t *)_key; + const H5D_btree_key_t *key = (const H5D_btree_key_t *)_key; hsize_t tmp_offset; /* Temporary coordinate offset, from file */ unsigned u; /* Local index variable */ @@ -793,7 +793,7 @@ H5D__btree_shared_free(void *_shared) static herr_t H5D__btree_shared_create(const H5F_t *f, H5O_storage_chunk_t *store, const H5O_layout_chunk_t *layout) { - H5B_shared_t * shared; /* Shared B-tree node info */ + H5B_shared_t *shared; /* Shared B-tree node info */ H5O_layout_chunk_t *my_layout = NULL; /* Pointer to copy of layout info */ size_t sizeof_rkey; /* Size of raw (disk) key */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1030,7 +1030,7 @@ static int H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, const void *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - H5D_btree_it_ud_t * udata = (H5D_btree_it_ud_t *)_udata; /* User data */ + H5D_btree_it_ud_t *udata = (H5D_btree_it_ud_t *)_udata; /* User data */ const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *)_lt_key; /* B-tree key for chunk */ H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ int ret_value = -1; /* Return value */ diff --git a/src/H5Dbtree2.c b/src/H5Dbtree2.c index f9a4a07a039..4cd911cab64 100644 --- a/src/H5Dbtree2.c +++ b/src/H5Dbtree2.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -46,7 +45,7 @@ typedef struct H5D_bt2_ctx_ud_t { const H5F_t *f; /* Pointer to file info */ uint32_t chunk_size; /* Size of chunk (bytes; for filtered object) */ unsigned ndims; /* Number of dimensions */ - uint32_t * dim; /* Size of chunk in elements */ + uint32_t *dim; /* Size of chunk in elements */ } H5D_bt2_ctx_ud_t; /* The callback context */ @@ -61,7 +60,7 @@ typedef struct H5D_bt2_ctx_t { /* Callback info for iteration over chunks in v2 B-tree */ typedef struct H5D_bt2_it_ud_t { H5D_chunk_cb_func_t cb; /* Callback routine for the chunk */ - void * udata; /* User data for the chunk's callback routine */ + void *udata; /* User data for the chunk's callback routine */ } H5D_bt2_it_ud_t; /* User data for compare callback */ @@ -75,7 +74,7 @@ typedef struct H5D_bt2_ud_t { /********************/ /* Shared v2 B-tree methods for indexing filtered and non-filtered chunked datasets */ -static void * H5D__bt2_crt_context(void *udata); +static void *H5D__bt2_crt_context(void *udata); static herr_t H5D__bt2_dst_context(void *ctx); static herr_t H5D__bt2_store(void *native, const void *udata); static herr_t H5D__bt2_compare(const void *rec1, const void *rec2, int *result); @@ -215,9 +214,9 @@ static void * H5D__bt2_crt_context(void *_udata) { H5D_bt2_ctx_ud_t *udata = (H5D_bt2_ctx_ud_t *)_udata; /* User data for building callback context */ - H5D_bt2_ctx_t * ctx; /* Callback context structure */ - uint32_t * my_dim = NULL; /* Pointer to copy of chunk dimension size */ - void * ret_value = NULL; /* Return value */ + H5D_bt2_ctx_t *ctx; /* Callback context structure */ + uint32_t *my_dim = NULL; /* Pointer to copy of chunk dimension size */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -329,7 +328,7 @@ H5D__bt2_store(void *record, const void *_udata) static herr_t H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) { - const H5D_bt2_ud_t * udata = (const H5D_bt2_ud_t *)_udata; /* User data */ + const H5D_bt2_ud_t *udata = (const H5D_bt2_ud_t *)_udata; /* User data */ const H5D_chunk_rec_t *rec1 = &(udata->rec); /* The search record */ const H5D_chunk_rec_t *rec2 = (const H5D_chunk_rec_t *)_rec2; /* The native record */ herr_t ret_value = SUCCEED; /* Return value */ @@ -362,7 +361,7 @@ H5D__bt2_compare(const void *_udata, const void *_rec2, int *result) static herr_t H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) { - H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ unsigned u; /* Local index variable */ @@ -396,7 +395,7 @@ H5D__bt2_unfilt_encode(uint8_t *raw, const void *_record, void *_ctx) static herr_t H5D__bt2_unfilt_decode(const uint8_t *raw, void *_record, void *_ctx) { - H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ unsigned u; /* Local index variable */ @@ -431,7 +430,7 @@ static herr_t H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *_record, const void *_ctx) { const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ + const H5D_bt2_ctx_t *ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -467,7 +466,7 @@ H5D__bt2_unfilt_debug(FILE *stream, int indent, int fwidth, const void *_record, static herr_t H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) { - H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ unsigned u; /* Local index variable */ @@ -505,7 +504,7 @@ H5D__bt2_filt_encode(uint8_t *raw, const void *_record, void *_ctx) static herr_t H5D__bt2_filt_decode(const uint8_t *raw, void *_record, void *_ctx) { - H5D_bt2_ctx_t * ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5D_bt2_ctx_t *ctx = (H5D_bt2_ctx_t *)_ctx; /* Callback context structure */ H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* The native record */ unsigned u; /* Local index variable */ @@ -545,7 +544,7 @@ static herr_t H5D__bt2_filt_debug(FILE *stream, int indent, int fwidth, const void *_record, const void *_ctx) { const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - const H5D_bt2_ctx_t * ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ + const H5D_bt2_ctx_t *ctx = (const H5D_bt2_ctx_t *)_ctx; /* Callback context */ unsigned u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -610,7 +609,7 @@ H5D__bt2_idx_init(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, const H5S_t static herr_t H5D__btree2_idx_depend(const H5D_chk_idx_info_t *idx_info) { - H5O_t * oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ H5O_loc_t oloc; /* Temporary object header location for dataset */ H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ @@ -827,7 +826,7 @@ H5D__bt2_idx_is_space_alloc(const H5O_storage_chunk_t *storage) static herr_t H5D__bt2_mod_cb(void *_record, void *_op_data, hbool_t *changed) { - H5D_bt2_ud_t * op_data = (H5D_bt2_ud_t *)_op_data; /* User data for v2 B-tree calls */ + H5D_bt2_ud_t *op_data = (H5D_bt2_ud_t *)_op_data; /* User data for v2 B-tree calls */ H5D_chunk_rec_t *record = (H5D_chunk_rec_t *)_record; /* Chunk record */ FUNC_ENTER_STATIC_NOERR @@ -873,7 +872,7 @@ static herr_t H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, const H5D_t H5_ATTR_UNUSED *dset) { - H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -898,7 +897,7 @@ H5D__bt2_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata, } /* end if */ else /* Patch the top level file pointer contained in bt2 if needed */ if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; @@ -965,7 +964,7 @@ H5D__bt2_found_cb(const void *nrecord, void *op_data) static herr_t H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) { - H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree calls */ H5D_chunk_rec_t found_rec; /* Record found from searching for object */ unsigned u; /* Local index variable */ @@ -991,7 +990,7 @@ H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) } /* end if */ else /* Patch the top level file pointer contained in bt2 if needed */ if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; @@ -1059,7 +1058,7 @@ H5D__bt2_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata) static int H5D__bt2_idx_iterate_cb(const void *_record, void *_udata) { - H5D_bt2_it_ud_t * udata = (H5D_bt2_it_ud_t *)_udata; /* User data */ + H5D_bt2_it_ud_t *udata = (H5D_bt2_it_ud_t *)_udata; /* User data */ const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* Native record */ int ret_value = -1; /* Return value */ @@ -1087,7 +1086,7 @@ H5D__bt2_idx_iterate_cb(const void *_record, void *_udata) static int H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ H5D_bt2_it_ud_t udata; /* User data for B-tree iterator callback */ int ret_value = FAIL; /* Return value */ @@ -1111,7 +1110,7 @@ H5D__bt2_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chu } /* end if */ else /* Patch the top level file pointer contained in bt2 if needed */ if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; @@ -1147,7 +1146,7 @@ static herr_t H5D__bt2_remove_cb(const void *_record, void *_udata) { const H5D_chunk_rec_t *record = (const H5D_chunk_rec_t *)_record; /* The native record */ - H5F_t * f = (H5F_t *)_udata; /* User data for removal callback */ + H5F_t *f = (H5F_t *)_udata; /* User data for removal callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1178,7 +1177,7 @@ H5D__bt2_remove_cb(const void *_record, void *_udata) static herr_t H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *udata) { - H5B2_t * bt2; /* v2 B-tree handle for indexing chunks */ + H5B2_t *bt2; /* v2 B-tree handle for indexing chunks */ H5D_bt2_ud_t bt2_udata; /* User data for v2 B-tree find call */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1202,7 +1201,7 @@ H5D__bt2_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t *u } /* end if */ else /* Patch the top level file pointer contained in bt2 if needed */ if (H5B2_patch_file(idx_info->storage->u.btree2.bt2, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch v2 B-tree file pointer") /* Set convenience pointer to v2 B-tree structure */ bt2 = idx_info->storage->u.btree2.bt2; diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index f335a25886d..466423426f1 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -107,9 +106,9 @@ /*#define H5D_CHUNK_DEBUG */ /* Flags for the "edge_chunk_state" field below */ -#define H5D_RDCC_DISABLE_FILTERS 0x01u /* Disable filters on this chunk */ +#define H5D_RDCC_DISABLE_FILTERS 0x01U /* Disable filters on this chunk */ #define H5D_RDCC_NEWLY_DISABLED_FILTERS \ - 0x02u /* Filters have been disabled since \ + 0x02U /* Filters have been disabled since \ * the last flush */ /******************/ @@ -127,7 +126,7 @@ typedef struct H5D_rdcc_ent_t { uint32_t wr_count; /*bytes remaining to be written */ H5F_block_t chunk_block; /*offset/length of chunk in file */ hsize_t chunk_idx; /*index of chunk in dataset */ - uint8_t * chunk; /*the unfiltered chunk data */ + uint8_t *chunk; /*the unfiltered chunk data */ unsigned idx; /*index in hash table */ struct H5D_rdcc_ent_t *next; /*next item in doubly-linked list */ struct H5D_rdcc_ent_t *prev; /*previous item in doubly-linked list */ @@ -140,12 +139,12 @@ typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ typedef struct H5D_chunk_it_ud1_t { H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ const H5D_chk_idx_info_t *idx_info; /* Chunked index info */ - const H5D_io_info_t * io_info; /* I/O info for dataset operation */ - const hsize_t * space_dim; /* New dataset dimensions */ - const hbool_t * shrunk_dim; /* Dimensions which have been shrunk */ - H5S_t * chunk_space; /* Dataspace for a chunk */ + const H5D_io_info_t *io_info; /* I/O info for dataset operation */ + const hsize_t *space_dim; /* New dataset dimensions */ + const hbool_t *shrunk_dim; /* Dimensions which have been shrunk */ + H5S_t *chunk_space; /* Dataspace for a chunk */ uint32_t elmts_per_chunk; /* Elements in chunk */ - hsize_t * hyper_start; /* Starting location of hyperslab */ + hsize_t *hyper_start; /* Starting location of hyperslab */ H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ hbool_t fb_info_init; /* Whether the fill value buffer has been initialized */ } H5D_chunk_it_ud1_t; @@ -163,10 +162,10 @@ typedef struct H5D_chunk_it_ud2_t { /* Callback info for iteration to copy data */ typedef struct H5D_chunk_it_ud3_t { H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ - H5F_t * file_src; /* Source file for copy */ - H5D_chk_idx_info_t * idx_info_dst; /* Dest. chunk index info object */ - void * buf; /* Buffer to hold chunk data for read/write */ - void * bkg; /* Buffer for background information during type conversion */ + H5F_t *file_src; /* Source file for copy */ + H5D_chk_idx_info_t *idx_info_dst; /* Dest. chunk index info object */ + void *buf; /* Buffer to hold chunk data for read/write */ + void *bkg; /* Buffer for background information during type conversion */ size_t buf_size; /* Buffer size */ hbool_t do_convert; /* Whether to perform type conversions */ @@ -175,17 +174,17 @@ typedef struct H5D_chunk_it_ud3_t { hid_t tid_dst; /* Datatype ID for destination datatype */ hid_t tid_mem; /* Datatype ID for memory datatype */ const H5T_t *dt_src; /* Source datatype */ - H5T_path_t * tpath_src_mem; /* Datatype conversion path from source file to memory */ - H5T_path_t * tpath_mem_dst; /* Datatype conversion path from memory to dest. file */ - void * reclaim_buf; /* Buffer for reclaiming data */ + H5T_path_t *tpath_src_mem; /* Datatype conversion path from source file to memory */ + H5T_path_t *tpath_mem_dst; /* Datatype conversion path from memory to dest. file */ + void *reclaim_buf; /* Buffer for reclaiming data */ size_t reclaim_buf_size; /* Reclaim buffer size */ uint32_t nelmts; /* Number of elements in buffer */ - H5S_t * buf_space; /* Dataspace describing buffer */ + H5S_t *buf_space; /* Dataspace describing buffer */ /* needed for compressed variable-length data */ const H5O_pline_t *pline; /* Filter pipeline */ unsigned dset_ndims; /* Number of dimensions in dataset */ - const hsize_t * dset_dims; /* Dataset dimensions */ + const hsize_t *dset_dims; /* Dataset dimensions */ /* needed for copy object pointed by refs */ H5O_copy_t *cpy_info; /* Copy options */ @@ -197,7 +196,7 @@ typedef struct H5D_chunk_it_ud3_t { /* Callback info for iteration to dump index */ typedef struct H5D_chunk_it_ud4_t { - FILE * stream; /* Output stream */ + FILE *stream; /* Output stream */ hbool_t header_displayed; /* Node's header is displayed? */ unsigned ndims; /* Number of dimensions for chunk/dataset */ uint32_t *chunk_dim; /* Chunk dimensions */ @@ -207,13 +206,13 @@ typedef struct H5D_chunk_it_ud4_t { typedef struct H5D_chunk_it_ud5_t { H5D_chk_idx_info_t *new_idx_info; /* Dest. chunk index info object */ unsigned dset_ndims; /* Number of dimensions in dataset */ - hsize_t * dset_dims; /* Dataset dimensions */ + hsize_t *dset_dims; /* Dataset dimensions */ } H5D_chunk_it_ud5_t; /* Callback info for nonexistent readvv operation */ typedef struct H5D_chunk_readvv_ud_t { unsigned char *rbuf; /* Read buffer to initialize */ - const H5D_t * dset; /* Dataset to operate on */ + const H5D_t *dset; /* Dataset to operate on */ } H5D_chunk_readvv_ud_t; /* Typedef for chunk info iterator callback */ @@ -239,12 +238,22 @@ typedef struct H5D_chunk_file_iter_ud_t { #ifdef H5_HAVE_PARALLEL /* information to construct a collective I/O operation for filling chunks */ -typedef struct H5D_chunk_coll_info_t { - size_t num_io; /* Number of write operations */ - haddr_t *addr; /* array of the file addresses of the write operation */ -} H5D_chunk_coll_info_t; +typedef struct H5D_chunk_coll_fill_info_t { + size_t num_chunks; /* Number of chunks in the write operation */ + struct chunk_coll_fill_info { + haddr_t addr; /* File address of the chunk */ + size_t chunk_size; /* Size of the chunk in the file */ + hbool_t unfiltered_partial_chunk; + } * chunk_info; +} H5D_chunk_coll_fill_info_t; #endif /* H5_HAVE_PARALLEL */ +typedef struct H5D_chunk_iter_ud_t { + H5D_chunk_iter_op_t op; /* User defined callback */ + void *op_data; /* User data for user defined callback */ + H5O_layout_chunk_t *chunk; /* Chunk layout */ +} H5D_chunk_iter_ud_t; + /********************/ /* Local Prototypes */ /********************/ @@ -253,14 +262,13 @@ typedef struct H5D_chunk_coll_info_t { static herr_t H5D__chunk_construct(H5F_t *f, H5D_t *dset); static herr_t H5D__chunk_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); static herr_t H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, - H5D_chunk_map_t *fm); + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); 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); @@ -269,6 +277,7 @@ static herr_t H5D__chunk_dest(H5D_t *dset); static int H5D__get_num_chunks_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); static int H5D__get_chunk_info_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); static int H5D__get_chunk_info_by_coord_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); +static int H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata); /* "Nonexistent" layout operation callback */ static ssize_t H5D__nonexistent_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, @@ -282,9 +291,6 @@ static int H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void * /* Helper routines */ static herr_t H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims, const hsize_t *max_dims); -static void * H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline); -static void * H5D__chunk_mem_xfree(void *chk, const void *pline); -static void * H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline); static herr_t H5D__chunk_cinfo_cache_reset(H5D_chunk_cached_t *last); static herr_t H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *udata); static hbool_t H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *udata); @@ -301,18 +307,16 @@ static herr_t H5D__chunk_mem_cb(void *elem, const H5T_t *type, unsigned ndims, static unsigned H5D__chunk_hash_val(const H5D_shared_t *shared, const hsize_t *scaled); static herr_t H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset); static herr_t H5D__chunk_cache_evict(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t flush); -static hbool_t H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims, - const hsize_t *chunk_scaled, const hsize_t *dset_dims); -static void * H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax, +static void *H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax, hbool_t prev_unfilt_chunk); static herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, uint32_t naccessed); static herr_t H5D__chunk_cache_prune(const H5D_t *dset, size_t size); static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk); #ifdef H5_HAVE_PARALLEL -static herr_t H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, - size_t chunk_size, const void *fill_buf); -static int H5D__chunk_cmp_addr(const void *addr1, const void *addr2); +static herr_t H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_fill_info_t *chunk_fill_info, + const void *fill_buf, const void *partial_chunk_fill_buf); +static int H5D__chunk_cmp_coll_fill_info(const void *_entry1, const void *_entry2); #endif /* H5_HAVE_PARALLEL */ /* Debugging helper routine callback */ @@ -323,13 +327,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 */ @@ -489,7 +504,7 @@ herr_t H5D__chunk_direct_read(const H5D_t *dset, hsize_t *offset, uint32_t *filters, void *buf) { const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - const H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ H5D_chunk_ud_t udata; /* User data for querying chunk info */ hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ herr_t ret_value = SUCCEED; /* Return value */ @@ -584,7 +599,7 @@ herr_t H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage_size) { const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - const H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ H5D_chunk_ud_t udata; /* User data for querying chunk info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -596,8 +611,6 @@ H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage HDassert(offset); HDassert(storage_size); - *storage_size = 0; - /* Allocate dataspace and initialize it if it hasn't been. */ if (!(*layout->ops->is_space_alloc)(&layout->storage)) HGOTO_DONE(SUCCEED) @@ -688,9 +701,12 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize /* Sanity checks */ HDassert(layout); - HDassert(ndims > 0); HDassert(curr_dims); + /* Can happen when corrupt files are parsed */ + if (ndims == 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "number of dimensions cannot be zero") + /* Compute the # of chunks in dataset dimensions */ for (u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { /* Round up to the next integer # of chunks, to accommodate partial chunks */ @@ -899,9 +915,10 @@ static herr_t H5D__chunk_init(H5F_t *f, const H5D_t *const dset, hid_t dapl_id) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ - H5P_genplist_t * dapl; /* Data access property list object pointer */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ + H5P_genplist_t *dapl; /* Data access property list object pointer */ H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); + hbool_t idx_init = FALSE; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -960,7 +977,7 @@ H5D__chunk_init(H5F_t *f, const H5D_t *const dset, hid_t dapl_id) if (!(scaled_power2up = H5VM_power2up(rdcc->scaled_dims[u]))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get the next power of 2") - /* Inital 'power2up' values for scaled dimensions */ + /* Initial 'power2up' values for scaled dimensions */ rdcc->scaled_power2up[u] = scaled_power2up; /* Number of bits required to encode scaled dimension size */ @@ -977,12 +994,21 @@ H5D__chunk_init(H5F_t *f, const H5D_t *const dset, hid_t dapl_id) /* Allocate any indexing structures */ if (sc->ops->init && (sc->ops->init)(&idx_info, dset->shared->space, dset->oloc.addr) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize indexing information") + idx_init = TRUE; /* Set the number of chunks in dataset, etc. */ if (H5D__chunk_set_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set # of chunks for dataset") done: + if (FAIL == ret_value) { + if (rdcc->slot) + rdcc->slot = H5FL_SEQ_FREE(H5D_rdcc_ent_ptr_t, rdcc->slot); + + if (idx_init && sc->ops->dest && (sc->ops->dest)(&idx_info) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info"); + } + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_init() */ @@ -1024,7 +1050,7 @@ H5D__chunk_is_space_alloc(const H5O_storage_t *storage) * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner - * Wednessday, March 6, 2016 + * Wednesday, March 6, 2016 * *------------------------------------------------------------------------- */ @@ -1053,7 +1079,7 @@ H5D__chunk_is_data_cached(const H5D_shared_t *shared_dset) */ static herr_t H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, - const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *fm) + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm) { const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset */ @@ -1084,7 +1110,7 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf * 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 */ @@ -1121,8 +1147,7 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf fm->mem_space = NULL; if (file_space_normalized == TRUE) - if (H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset) < - 0) /* (Casting away const OK -QAK) */ + if (H5S_hyper_denormalize_offset(file_space, old_offset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't denormalize selection") FUNC_LEAVE_NOAPI(ret_value) @@ -1146,8 +1171,8 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ { const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ const H5T_t *mem_type = type_info->mem_type; /* Local pointer to memory datatype */ - H5S_t * tmp_mspace = NULL; /* Temporary memory dataspace */ - H5T_t * file_type = NULL; /* Temporary copy of file datatype for iteration */ + H5S_t *tmp_mspace = NULL; /* Temporary memory dataspace */ + H5T_t *file_type = NULL; /* Temporary copy of file datatype for iteration */ hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ char bogus; /* "bogus" buffer to pass to selection iterator */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1348,16 +1373,17 @@ H5D__chunk_io_init_selections(const H5D_io_info_t *io_info, const H5D_type_info_ * *------------------------------------------------------------------------- */ -static void * -H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) +void * +H5D__chunk_mem_alloc(size_t size, void *pline) { - void *ret_value = NULL; /* Return value */ + H5O_pline_t *_pline = (H5O_pline_t *)pline; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR HDassert(size); - if (pline && pline->nused) + if (_pline && _pline->nused) ret_value = H5MM_malloc(size); else ret_value = H5FL_BLK_MALLOC(chunk, size); @@ -1379,15 +1405,15 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) * *------------------------------------------------------------------------- */ -static void * -H5D__chunk_mem_xfree(void *chk, const void *_pline) +void * +H5D__chunk_mem_xfree(void *chk, const void *pline) { - const H5O_pline_t *pline = (const H5O_pline_t *)_pline; + const H5O_pline_t *_pline = (const H5O_pline_t *)pline; FUNC_ENTER_STATIC_NOERR if (chk) { - if (pline && pline->nused) + if (_pline && _pline->nused) H5MM_xfree(chk); else chk = H5FL_BLK_FREE(chunk, chk); @@ -1396,6 +1422,19 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline) FUNC_LEAVE_NOAPI(NULL) } /* 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. + *------------------------------------------------------------------------- + */ +void +H5D__chunk_mem_free(void *chk, void *pline) +{ + (void)H5D__chunk_mem_xfree(chk, pline); +} + /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_realloc * @@ -1410,7 +1449,7 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline) * *------------------------------------------------------------------------- */ -static void * +void * H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline) { void *ret_value = NULL; /* Return value */ @@ -1545,8 +1584,7 @@ H5D__create_chunk_map_single(H5D_chunk_map_t *fm, const H5D_io_info_t chunk_info->fspace_shared = TRUE; /* Just point at the memory dataspace & selection */ - /* (Casting away const OK -QAK) */ - chunk_info->mspace = (H5S_t *)fm->mem_space; + chunk_info->mspace = fm->mem_space; /* Indicate that the chunk's memory dataspace is shared */ chunk_info->mspace_shared = TRUE; @@ -1574,7 +1612,7 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t #endif /* H5_HAVE_PARALLEL */ *io_info) { - H5S_t * tmp_fchunk = NULL; /* Temporary file dataspace */ + H5S_t *tmp_fchunk = NULL; /* Temporary file dataspace */ hsize_t file_dims[H5S_MAX_RANK]; /* File dataspace dims */ hsize_t sel_points; /* Number of elements in file selection */ hsize_t zeros[H5S_MAX_RANK]; /* All zero vector (for start parameter to setting hyperslab on partial @@ -1615,7 +1653,7 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t coords[u] = 0; end[u] = fm->chunk_dim[u] - 1; - /* Iniitialize partial chunk dimension information */ + /* Initialize partial chunk dimension information */ partial_dim_size[u] = file_dims[u] % fm->chunk_dim[u]; if (file_dims[u] < fm->chunk_dim[u]) { curr_partial_clip[u] = partial_dim_size[u]; @@ -1779,7 +1817,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t #endif /* H5_HAVE_PARALLEL */ *io_info) { - H5S_t * tmp_fchunk = NULL; /* Temporary file dataspace */ + H5S_t *tmp_fchunk = NULL; /* Temporary file dataspace */ hsize_t sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ hsize_t sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ hsize_t sel_points; /* Number of elements in file selection */ @@ -1821,7 +1859,6 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t /* Iterate through each chunk in the dataset */ while (sel_points) { /* Check for intersection of current chunk and file selection */ - /* (Casting away const OK - QAK) */ if (TRUE == H5S_SELECT_INTERSECT_BLOCK(fm->file_space, coords, end)) { H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */ hsize_t chunk_points; /* Number of elements in chunk selection */ @@ -1956,7 +1993,7 @@ static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) { H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ - H5SL_node_t * curr_node; /* Current node in skip list */ + H5SL_node_t *curr_node; /* Current node in skip list */ hsize_t file_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ hsize_t file_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ @@ -1980,8 +2017,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) HDassert(chunk_info); /* Just point at the memory dataspace & selection */ - /* (Casting away const OK -QAK) */ - chunk_info->mspace = (H5S_t *)fm->mem_space; + chunk_info->mspace = fm->mem_space; /* Indicate that the chunk's memory space is shared */ chunk_info->mspace_shared = TRUE; @@ -2085,7 +2121,7 @@ static herr_t H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) { H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ - H5SL_node_t * curr_node; /* Current node in skip list */ + H5SL_node_t *curr_node; /* Current node in skip list */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2103,8 +2139,7 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) HDassert(chunk_info); /* Just point at the memory dataspace & selection */ - /* (Casting away const OK -QAK) */ - chunk_info->mspace = (H5S_t *)fm->mem_space; + chunk_info->mspace = fm->mem_space; /* Indicate that the chunk's memory space is shared */ chunk_info->mspace_shared = TRUE; @@ -2167,8 +2202,8 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, const hsize_t *coords, void *_udata) { H5D_chunk_file_iter_ud_t *udata = (H5D_chunk_file_iter_ud_t *)_udata; /* User data for operation */ - H5D_chunk_map_t * fm = udata->fm; /* File<->memory chunk mapping info */ - H5D_chunk_info_t * chunk_info; /* Chunk information for current chunk */ + H5D_chunk_map_t *fm = udata->fm; /* File<->memory chunk mapping info */ + H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ hsize_t coords_in_chunk[H5O_LAYOUT_NDIMS]; /* Coordinates of element in chunk */ hsize_t chunk_index; /* Chunk index */ hsize_t scaled[H5S_MAX_RANK]; /* Scaled coordinates for this chunk */ @@ -2232,7 +2267,6 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, /* Set the chunk's scaled coordinates */ H5MM_memcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); chunk_info->scaled[fm->f_ndims] = 0; - H5MM_memcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); /* Insert the new chunk into the skip list */ if (H5SL_insert(fm->sel_chunks, chunk_info, &chunk_info->index) < 0) { @@ -2284,7 +2318,7 @@ static herr_t H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, const hsize_t *coords, void *_fm) { - H5D_chunk_map_t * fm = (H5D_chunk_map_t *)_fm; /* File<->memory chunk mapping info */ + H5D_chunk_map_t *fm = (H5D_chunk_map_t *)_fm; /* File<->memory chunk mapping info */ H5D_chunk_info_t *chunk_info; /* Chunk information for current chunk */ hsize_t coords_in_mem[H5S_MAX_RANK]; /* Coordinates of element in memory */ hsize_t chunk_index; /* Chunk index */ @@ -2447,10 +2481,9 @@ H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_ */ 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 */ + H5SL_node_t *chunk_node; /* Current node in chunk skip list */ H5D_io_info_t nonexistent_io_info; /* "nonexistent" I/O info object */ H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ @@ -2524,11 +2557,11 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_ HDassert((H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length > 0) || (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); - /* Check for non-existant chunk & skip it if appropriate */ + /* Check for non-existent chunk & skip it if appropriate */ if (H5F_addr_defined(udata.chunk_block.offset) || UINT_MAX != udata.idx_hint || !skip_missing_chunks) { H5D_io_info_t *chk_io_info; /* Pointer to I/O info object for this chunk */ - void * chunk = NULL; /* Pointer to locked chunk buffer */ + void *chunk = NULL; /* Pointer to locked chunk buffer */ htri_t cacheable; /* Whether the chunk is cacheable */ /* Set chunk's [scaled] coordinates */ @@ -2598,10 +2631,9 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_ */ 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 */ + H5SL_node_t *chunk_node; /* Current node in chunk skip list */ H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ H5D_io_info_t cpt_io_info; /* Compact I/O info object */ @@ -2638,10 +2670,10 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize /* Iterate through nodes in chunk skip list */ chunk_node = H5D_CHUNK_GET_FIRST_NODE(fm); while (chunk_node) { - H5D_chunk_info_t * chunk_info; /* Chunk information */ + H5D_chunk_info_t *chunk_info; /* Chunk information */ H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_io_info_t * chk_io_info; /* Pointer to I/O info object for this chunk */ - void * chunk; /* Pointer to locked chunk buffer */ + H5D_io_info_t *chk_io_info; /* Pointer to I/O info object for this chunk */ + void *chunk; /* Pointer to locked chunk buffer */ H5D_chunk_ud_t udata; /* Index pass-through */ htri_t cacheable; /* Whether the chunk is cacheable */ hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ @@ -2764,7 +2796,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize static herr_t H5D__chunk_flush(H5D_t *dset) { - H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); H5D_rdcc_ent_t *ent, *next; unsigned nerrors = 0; /* Count of any errors encountered when flushing chunks */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2854,8 +2886,8 @@ static herr_t H5D__chunk_dest(H5D_t *dset) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* Dataset's chunk cache */ - H5D_rdcc_ent_t * ent = NULL, *next = NULL; /* Pointer to current & next cache entries */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Dataset's chunk cache */ + H5D_rdcc_ent_t *ent = NULL, *next = NULL; /* Pointer to current & next cache entries */ int nerrors = 0; /* Accumulated count of errors */ H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ @@ -3149,11 +3181,16 @@ 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 + H5P_coll_md_read_flag_t md_reads_file_flag; + hbool_t md_reads_context_flag; + hbool_t restore_md_reads_state = FALSE; +#endif + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3224,8 +3261,12 @@ 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)) { + md_reads_file_flag = H5P_FORCE_FALSE; + md_reads_context_flag = FALSE; + H5F_set_coll_metadata_reads(idx_info.f, &md_reads_file_flag, &md_reads_context_flag); + restore_md_reads_state = TRUE; + } #endif /* H5_HAVE_PARALLEL */ /* Go get the chunk information */ @@ -3268,6 +3309,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 (restore_md_reads_state) + H5F_set_coll_metadata_reads(dset->oloc.file, &md_reads_file_flag, &md_reads_context_flag); +#endif /* H5_HAVE_PARALLEL */ + FUNC_LEAVE_NOAPI(ret_value) } /* H5D__chunk_lookup() */ @@ -3289,7 +3336,7 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, H5D_chunk_ud_t *udat static herr_t H5D__chunk_flush_entry(const H5D_t *dset, H5D_rdcc_ent_t *ent, hbool_t reset) { - void * buf = NULL; /* Temporary buffer */ + void *buf = NULL; /* Temporary buffer */ hbool_t point_of_no_return = FALSE; H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ @@ -3564,8 +3611,8 @@ H5D__chunk_cache_prune(const H5D_t *dset, size_t size) size_t total = rdcc->nbytes_max; const int nmeth = 2; /* Number of methods */ int w[1]; /* Weighting as an interval */ - H5D_rdcc_ent_t * p[2], *cur; /* List pointers */ - H5D_rdcc_ent_t * n[2]; /* List next pointers */ + H5D_rdcc_ent_t *p[2], *cur; /* List pointers */ + H5D_rdcc_ent_t *n[2]; /* List next pointers */ int nerrors = 0; /* Accumulated error count during preemptions */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3577,7 +3624,7 @@ H5D__chunk_cache_prune(const H5D_t *dset, size_t size) * traversing the list when pointer pN reaches wN percent of the original * list. In other words, preemption method N gets to consider entries in * approximate least recently used order w0 percent before method N+1 - * where 100% means tha method N will run to completion before method N+1 + * where 100% means the method N will run to completion before method N+1 * begins. The pointers participating in the list traversal are each * given a chance at preemption before any of the pointers are advanced. */ @@ -3681,21 +3728,21 @@ H5D__chunk_cache_prune(const H5D_t *dset, size_t size) static void * H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax, hbool_t prev_unfilt_chunk) { - const H5D_t * dset = io_info->dset; /* Local pointer to the dataset info */ - const H5O_pline_t *pline = + const H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ + H5O_pline_t *pline = &(dset->shared->dcpl_cache .pline); /* I/O pipeline info - always equal to the pline passed to H5D__chunk_mem_alloc */ - const H5O_pline_t * old_pline = pline; /* Old pipeline, i.e. pipeline used to read the chunk */ + H5O_pline_t *old_pline = pline; /* Old pipeline, i.e. pipeline used to read the chunk */ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - const H5O_fill_t * fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ + const H5O_fill_t *fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ - H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache*/ - H5D_rdcc_ent_t * ent; /*cache entry */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache*/ + H5D_rdcc_ent_t *ent; /*cache entry */ size_t chunk_size; /*size of a chunk */ hbool_t disable_filters = FALSE; /* Whether to disable filters (when adding to cache) */ - void * chunk = NULL; /*the file chunk */ - void * ret_value = NULL; /* Return value */ + void *chunk = NULL; /*the file chunk */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -4082,7 +4129,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbo uint32_t naccessed) { const H5O_layout_t *layout = &(io_info->dset->shared->layout); /* Dataset layout */ - const H5D_rdcc_t * rdcc = &(io_info->dset->shared->cache.chunk); + const H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4205,8 +4252,8 @@ herr_t H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ - const H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /* Raw data chunk cache */ - H5D_rdcc_ent_t * ent; /* Cache entry */ + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Raw data chunk cache */ + H5D_rdcc_ent_t *ent; /* Cache entry */ hsize_t chunk_bytes = 0; /* Number of bytes allocated for chunks */ H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ @@ -4258,35 +4305,35 @@ H5D__chunk_allocated(const H5D_t *dset, hsize_t *nbytes) herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const hsize_t old_dim[]) { - const H5D_t * dset = io_info->dset; /* the dataset pointer */ + const H5D_t *dset = io_info->dset; /* the dataset pointer */ H5D_chk_idx_info_t idx_info; /* Chunked index info */ const H5D_chunk_ops_t *ops = dset->shared->layout.storage.u.chunk.ops; /* Chunk operations */ hsize_t min_unalloc[H5O_LAYOUT_NDIMS]; /* First chunk in each dimension that is unallocated (in scaled coordinates) */ hsize_t max_unalloc[H5O_LAYOUT_NDIMS]; /* Last chunk in each dimension that is unallocated (in scaled coordinates) */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Offset of current chunk (in scaled coordinates) */ - size_t orig_chunk_size; /* Original size of chunk in bytes */ - size_t chunk_size; /* Actual size of chunk in bytes, possibly filtered */ - unsigned filter_mask = 0; /* Filter mask for chunks that have them */ - const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ - const H5O_pline_t * pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info */ - const H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default pipeline */ - const H5O_fill_t * fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ - H5D_fill_value_t fill_status; /* The fill value status */ - hbool_t should_fill = FALSE; /* Whether fill values should be written */ - void * unfilt_fill_buf = NULL; /* Unfiltered fill value buffer */ - void ** fill_buf = NULL; /* Pointer to the fill buffer to use for a chunk */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Offset of current chunk (in scaled coordinates) */ + size_t orig_chunk_size; /* Original size of chunk in bytes */ + size_t chunk_size; /* Actual size of chunk in bytes, possibly filtered */ + unsigned filter_mask = 0; /* Filter mask for chunks that have them */ + H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ + H5O_pline_t *pline = &(dset->shared->dcpl_cache.pline); /* I/O pipeline info */ + H5O_pline_t def_pline = H5O_CRT_PIPELINE_DEF; /* Default pipeline */ + const H5O_fill_t *fill = &(dset->shared->dcpl_cache.fill); /* Fill value info */ + H5D_fill_value_t fill_status; /* The fill value status */ + hbool_t should_fill = FALSE; /* Whether fill values should be written */ + void *unfilt_fill_buf = NULL; /* Unfiltered fill value buffer */ + void **fill_buf = NULL; /* Pointer to the fill buffer to use for a chunk */ #ifdef H5_HAVE_PARALLEL hbool_t blocks_written = FALSE; /* Flag to indicate that chunk was actually written */ hbool_t using_mpi = FALSE; /* Flag to indicate that the file is being accessed with an MPI-capable file driver */ - H5D_chunk_coll_info_t chunk_info; /* chunk address information for doing I/O */ -#endif /* H5_HAVE_PARALLEL */ + H5D_chunk_coll_fill_info_t chunk_fill_info; /* chunk address information for doing I/O */ +#endif /* H5_HAVE_PARALLEL */ hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ unsigned space_ndims; /* Dataset's space rank */ - const hsize_t * space_dim; /* Dataset's dataspace dimensions */ - const uint32_t * chunk_dim = layout->u.chunk.dim; /* Convenience pointer to chunk dimensions */ + const hsize_t *space_dim; /* Dataset's dataspace dimensions */ + const uint32_t *chunk_dim = layout->u.chunk.dim; /* Convenience pointer to chunk dimensions */ unsigned op_dim; /* Current operating dimension */ H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ @@ -4329,8 +4376,8 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const using_mpi = TRUE; /* init chunk info stuff for collective I/O */ - chunk_info.num_io = 0; - chunk_info.addr = NULL; + chunk_fill_info.num_chunks = 0; + chunk_fill_info.chunk_info = NULL; } /* end if */ #endif /* H5_HAVE_PARALLEL */ @@ -4381,10 +4428,9 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const if (should_fill) { /* Initialize the fill value buffer */ /* (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, - dset->shared->type, dset->shared->type_id, (size_t)0, orig_chunk_size) < 0) + if (H5D__fill_init(&fb_info, NULL, H5D__chunk_mem_alloc, pline, H5D__chunk_mem_free, 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; @@ -4602,19 +4648,26 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const if (using_mpi) { /* collect all chunk addresses to be written to write collectively at the end */ - /* allocate/resize address array if no more space left */ - /* Note that if we add support for parallel filters we must - * also store an array of chunk sizes and pass it to the - * apporpriate collective write function */ - if (0 == chunk_info.num_io % 1024) - if (NULL == (chunk_info.addr = (haddr_t *)H5MM_realloc( - chunk_info.addr, (chunk_info.num_io + 1024) * sizeof(haddr_t)))) + + /* allocate/resize chunk info array if no more space left */ + if (0 == chunk_fill_info.num_chunks % 1024) { + void *tmp_realloc; + + if (NULL == (tmp_realloc = H5MM_realloc(chunk_fill_info.chunk_info, + (chunk_fill_info.num_chunks + 1024) * + sizeof(struct chunk_coll_fill_info)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, - "memory allocation failed for chunk addresses") + "memory allocation failed for chunk fill info") + + chunk_fill_info.chunk_info = tmp_realloc; + } - /* Store the chunk's address for later */ - chunk_info.addr[chunk_info.num_io] = udata.chunk_block.offset; - chunk_info.num_io++; + /* Store info about the chunk for later */ + chunk_fill_info.chunk_info[chunk_fill_info.num_chunks].addr = udata.chunk_block.offset; + chunk_fill_info.chunk_info[chunk_fill_info.num_chunks].chunk_size = chunk_size; + chunk_fill_info.chunk_info[chunk_fill_info.num_chunks].unfiltered_partial_chunk = + (*fill_buf == unfilt_fill_buf); + chunk_fill_info.num_chunks++; /* Indicate that blocks will be written */ blocks_written = TRUE; @@ -4687,7 +4740,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const #ifdef H5_HAVE_PARALLEL /* do final collective I/O */ if (using_mpi && blocks_written) - if (H5D__chunk_collective_fill(dset, &chunk_info, chunk_size, fb_info.fill_buf) < 0) + if (H5D__chunk_collective_fill(dset, &chunk_fill_info, fb_info.fill_buf, unfilt_fill_buf) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write raw data to file") #endif /* H5_HAVE_PARALLEL */ @@ -4703,8 +4756,8 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, const unfilt_fill_buf = H5D__chunk_mem_xfree(unfilt_fill_buf, &def_pline); #ifdef H5_HAVE_PARALLEL - if (using_mpi && chunk_info.addr) - H5MM_free(chunk_info.addr); + if (using_mpi && chunk_fill_info.chunk_info) + H5MM_free(chunk_fill_info.chunk_info); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -4737,14 +4790,14 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) modified */ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset layout */ hsize_t chunk_sc[H5O_LAYOUT_NDIMS]; /* Offset of current chunk */ - const uint32_t * chunk_dim = layout->u.chunk.dim; /* Convenience pointer to chunk dimensions */ + const uint32_t *chunk_dim = layout->u.chunk.dim; /* Convenience pointer to chunk dimensions */ unsigned space_ndims; /* Dataset's space rank */ - const hsize_t * space_dim; /* Dataset's dataspace dimensions */ + const hsize_t *space_dim; /* Dataset's dataspace dimensions */ unsigned op_dim; /* Current operationg dimension */ H5D_io_info_t chk_io_info; /* Chunked I/O info object */ H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ H5D_storage_t chk_store; /* Chunk storage information */ - void * chunk; /* The file chunk */ + void *chunk; /* The file chunk */ hbool_t carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */ herr_t ret_value = SUCCEED; /* Return value */ @@ -4898,27 +4951,35 @@ H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]) *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, size_t chunk_size, - const void *fill_buf) +H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_fill_info_t *chunk_fill_info, + const void *fill_buf, const void *partial_chunk_fill_buf) { - MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */ - int mpi_rank = (-1); /* This process's rank */ - int mpi_size = (-1); /* MPI Comm size */ - int mpi_code; /* MPI return code */ - size_t num_blocks; /* Number of blocks between processes. */ - size_t leftover_blocks; /* Number of leftover blocks to handle */ - int blocks, leftover, block_len; /* converted to int for MPI */ - MPI_Aint * chunk_disp_array = NULL; - int * block_lens = NULL; + MPI_Comm mpi_comm = MPI_COMM_NULL; /* MPI communicator for file */ + int mpi_rank = (-1); /* This process's rank */ + int mpi_size = (-1); /* MPI Comm size */ + int mpi_code; /* MPI return code */ + size_t num_blocks; /* Number of blocks between processes. */ + size_t leftover_blocks; /* Number of leftover blocks to handle */ + int blocks, leftover; /* converted to int for MPI */ + MPI_Aint *chunk_disp_array = NULL; + MPI_Aint *block_disps = NULL; + int *block_lens = NULL; MPI_Datatype mem_type = MPI_BYTE, file_type = MPI_BYTE; H5FD_mpio_xfer_t prev_xfer_mode; /* Previous data xfer mode */ hbool_t have_xfer_mode = FALSE; /* Whether the previous xffer mode has been retrieved */ - hbool_t need_addr_sort = FALSE; - int i; /* Local index variable */ + hbool_t need_sort = FALSE; + size_t i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC + /* + * If a separate fill buffer is provided for partial chunks, ensure + * that the "don't filter partial edge chunks" flag is set. + */ + if (partial_chunk_fill_buf) + HDassert(dset->shared->layout.u.chunk.flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + /* Get the MPI communicator */ if (MPI_COMM_NULL == (mpi_comm = H5F_mpi_get_comm(dset->oloc.file))) HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "Can't retrieve MPI communicator") @@ -4934,39 +4995,92 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, /* Distribute evenly the number of blocks between processes. */ if (mpi_size == 0) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Resulted in division by zero") - num_blocks = (size_t)(chunk_info->num_io / (size_t)mpi_size); /* value should be the same on all procs */ + num_blocks = + (size_t)(chunk_fill_info->num_chunks / (size_t)mpi_size); /* value should be the same on all procs */ /* After evenly distributing the blocks between processes, are there any * leftover blocks for each individual process (round-robin)? */ - leftover_blocks = (size_t)(chunk_info->num_io % (size_t)mpi_size); + leftover_blocks = (size_t)(chunk_fill_info->num_chunks % (size_t)mpi_size); /* Cast values to types needed by MPI */ H5_CHECKED_ASSIGN(blocks, int, num_blocks, size_t); H5_CHECKED_ASSIGN(leftover, int, leftover_blocks, size_t); - H5_CHECKED_ASSIGN(block_len, int, chunk_size, size_t); /* Check if we have any chunks to write on this rank */ if (num_blocks > 0 || (leftover && leftover > mpi_rank)) { + MPI_Aint partial_fill_buf_disp = 0; + hbool_t all_same_block_len = TRUE; + /* Allocate buffers */ - /* (MSC - should not need block_lens if MPI_type_create_hindexed_block is working) */ - if (NULL == (block_lens = (int *)H5MM_malloc((size_t)(blocks + 1) * sizeof(int)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk lengths buffer") if (NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc((size_t)(blocks + 1) * sizeof(MPI_Aint)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file displacement buffer") - for (i = 0; i < blocks; i++) { - /* store the chunk address as an MPI_Aint */ - chunk_disp_array[i] = (MPI_Aint)(chunk_info->addr[i + (mpi_rank * blocks)]); + if (partial_chunk_fill_buf) { + MPI_Aint fill_buf_addr; + MPI_Aint partial_fill_buf_addr; - /* MSC - should not need this if MPI_type_create_hindexed_block is working */ - block_lens[i] = block_len; + /* Calculate the displacement between the fill buffer and partial chunk fill buffer */ + if (MPI_SUCCESS != (mpi_code = MPI_Get_address(fill_buf, &fill_buf_addr))) + HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code) + if (MPI_SUCCESS != (mpi_code = MPI_Get_address(partial_chunk_fill_buf, &partial_fill_buf_addr))) + HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code) - /* Make sure that the addresses in the datatype are - * monotonically non-decreasing +#if MPI_VERSION >= 3 && MPI_SUBVERSION >= 1 + partial_fill_buf_disp = MPI_Aint_diff(partial_fill_buf_addr, fill_buf_addr); +#else + partial_fill_buf_disp = partial_fill_buf_addr - fill_buf_addr; +#endif + + /* + * Allocate all-zero block displacements array. If a block's displacement + * is left as zero, that block will be written to from the regular fill + * buffer. If a block represents an unfiltered partial edge chunk, its + * displacement will be set so that the block is written to from the + * unfiltered fill buffer. */ - if (i && (chunk_disp_array[i] < chunk_disp_array[i - 1])) - need_addr_sort = TRUE; + if (NULL == (block_disps = (MPI_Aint *)H5MM_calloc((size_t)(blocks + 1) * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate block displacements buffer") + } + + /* + * Perform initial scan of chunk info list to: + * - make sure that chunk addresses are monotonically non-decreasing + * - check if all blocks have the same length + */ + for (i = 1; i < chunk_fill_info->num_chunks; i++) { + if (chunk_fill_info->chunk_info[i].addr < chunk_fill_info->chunk_info[i - 1].addr) + need_sort = TRUE; + + if (chunk_fill_info->chunk_info[i].chunk_size != chunk_fill_info->chunk_info[i - 1].chunk_size) + all_same_block_len = FALSE; + } + + if (need_sort) + HDqsort(chunk_fill_info->chunk_info, chunk_fill_info->num_chunks, + sizeof(struct chunk_coll_fill_info), H5D__chunk_cmp_coll_fill_info); + + /* Allocate buffer for block lengths if necessary */ +#if MPI_VERSION >= 3 + if (!all_same_block_len) +#endif + if (NULL == (block_lens = (int *)H5MM_malloc((size_t)(blocks + 1) * sizeof(int)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk lengths buffer") + + for (i = 0; i < (size_t)blocks; i++) { + size_t idx = i + (size_t)(mpi_rank * blocks); + + /* store the chunk address as an MPI_Aint */ + chunk_disp_array[i] = (MPI_Aint)(chunk_fill_info->chunk_info[idx].addr); +#if MPI_VERSION >= 3 + if (!all_same_block_len) +#endif + H5_CHECKED_ASSIGN(block_lens[i], int, chunk_fill_info->chunk_info[idx].chunk_size, size_t); + + if (chunk_fill_info->chunk_info[idx].unfiltered_partial_chunk) { + HDassert(partial_chunk_fill_buf); + block_disps[i] = partial_fill_buf_disp; + } } /* end for */ /* Calculate if there are any leftover blocks after evenly @@ -4974,32 +5088,83 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, * to processes 0 -> leftover. */ if (leftover && leftover > mpi_rank) { - chunk_disp_array[blocks] = (MPI_Aint)chunk_info->addr[(blocks * mpi_size) + mpi_rank]; - if (blocks && (chunk_disp_array[blocks] < chunk_disp_array[blocks - 1])) - need_addr_sort = TRUE; - block_lens[blocks] = block_len; + chunk_disp_array[blocks] = + (MPI_Aint)chunk_fill_info->chunk_info[(blocks * mpi_size) + mpi_rank].addr; +#if MPI_VERSION >= 3 + if (!all_same_block_len) +#endif + H5_CHECKED_ASSIGN(block_lens[blocks], int, + chunk_fill_info->chunk_info[(blocks * mpi_size) + mpi_rank].chunk_size, + size_t); + + if (chunk_fill_info->chunk_info[(blocks * mpi_size) + mpi_rank].unfiltered_partial_chunk) { + HDassert(partial_chunk_fill_buf); + block_disps[blocks] = partial_fill_buf_disp; + } + blocks++; } - /* Ensure that the blocks are sorted in monotonically non-decreasing - * order of offset in the file. - */ - if (need_addr_sort) - HDqsort(chunk_disp_array, blocks, sizeof(MPI_Aint), H5D__chunk_cmp_addr); + /* Create file and memory types for the write operation */ + if (all_same_block_len) { + int block_len; + + H5_CHECKED_ASSIGN(block_len, int, chunk_fill_info->chunk_info[0].chunk_size, size_t); +#if MPI_VERSION >= 3 + mpi_code = + MPI_Type_create_hindexed_block(blocks, block_len, chunk_disp_array, MPI_BYTE, &file_type); + if (mpi_code != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code) +#else + mpi_code = MPI_Type_create_hindexed(blocks, block_lens, chunk_disp_array, MPI_BYTE, &file_type); + if (mpi_code != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) +#endif + + if (partial_chunk_fill_buf) { + /* + * If filters are disabled for partial edge chunks, those chunks could + * potentially have the same block length as the other chunks, but still + * need to be written to using the unfiltered fill buffer. Use an hindexed + * block type rather than an hvector. + */ +#if MPI_VERSION >= 3 + mpi_code = + MPI_Type_create_hindexed_block(blocks, block_len, block_disps, MPI_BYTE, &mem_type); + if (mpi_code != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code) +#else + mpi_code = MPI_Type_create_hindexed(blocks, block_lens, block_disps, MPI_BYTE, &mem_type); + if (mpi_code != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) +#endif + } + else { + mpi_code = MPI_Type_create_hvector(blocks, block_len, 0, MPI_BYTE, &mem_type); + if (mpi_code != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) + } + } + else { + /* + * Currently, different block lengths implies that there are partial + * edge chunks and the "don't filter partial edge chunks" flag is set. + */ + HDassert(partial_chunk_fill_buf); + HDassert(block_lens); + HDassert(block_disps); + + mpi_code = MPI_Type_create_hindexed(blocks, block_lens, chunk_disp_array, MPI_BYTE, &file_type); + if (mpi_code != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) + + mpi_code = MPI_Type_create_hindexed(blocks, block_lens, block_disps, MPI_BYTE, &mem_type); + if (mpi_code != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) + } - /* MSC - should use this if MPI_type_create_hindexed block is working: - * mpi_code = MPI_Type_create_hindexed_block(blocks, block_len, chunk_disp_array, MPI_BYTE, - * &file_type); - */ - mpi_code = MPI_Type_create_hindexed(blocks, block_lens, chunk_disp_array, MPI_BYTE, &file_type); - if (mpi_code != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&file_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - - mpi_code = MPI_Type_create_hvector(blocks, block_len, 0, MPI_BYTE, &mem_type); - if (mpi_code != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code) if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&mem_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) } /* end if */ @@ -5042,39 +5207,22 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info, if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) H5MM_xfree(chunk_disp_array); + H5MM_xfree(block_disps); H5MM_xfree(block_lens); FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_fill() */ static int -H5D__chunk_cmp_addr(const void *addr1, const void *addr2) +H5D__chunk_cmp_coll_fill_info(const void *_entry1, const void *_entry2) { - MPI_Aint _addr1 = (MPI_Aint)0, _addr2 = (MPI_Aint)0; - int ret_value = 0; + const struct chunk_coll_fill_info *entry1 = (const struct chunk_coll_fill_info *)_entry1; + const struct chunk_coll_fill_info *entry2 = (const struct chunk_coll_fill_info *)_entry2; FUNC_ENTER_STATIC_NOERR - _addr1 = *((const MPI_Aint *)addr1); - _addr2 = *((const MPI_Aint *)addr2); - -#if MPI_VERSION >= 3 && MPI_SUBVERSION >= 1 - { - MPI_Aint diff = MPI_Aint_diff(_addr1, _addr2); - - if (diff < (MPI_Aint)0) - ret_value = -1; - else if (diff > (MPI_Aint)0) - ret_value = 1; - else - ret_value = 0; - } -#else - ret_value = (_addr1 > _addr2) - (_addr1 < _addr2); -#endif - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__chunk_cmp_addr() */ + FUNC_LEAVE_NOAPI(H5F_addr_cmp(entry1->addr, entry2->addr)) +} /* end H5D__chunk_cmp_coll_fill_info() */ #endif /* H5_HAVE_PARALLEL */ /*------------------------------------------------------------------------- @@ -5094,16 +5242,16 @@ static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) { const H5D_io_info_t *io_info = udata->io_info; /* Local pointer to I/O info */ - const H5D_t * dset = io_info->dset; /* Local pointer to the dataset info */ - const H5O_layout_t * layout = &(dset->shared->layout); /* Dataset's layout */ + const H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ + const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset's layout */ unsigned rank = udata->common.layout->ndims - 1; /* Dataset rank */ - const hsize_t * scaled = udata->common.scaled; /* Scaled chunk offset */ - H5S_sel_iter_t * chunk_iter = NULL; /* Memory selection iteration info */ + const hsize_t *scaled = udata->common.scaled; /* Scaled chunk offset */ + H5S_sel_iter_t *chunk_iter = NULL; /* Memory selection iteration info */ hbool_t chunk_iter_init = FALSE; /* Whether the chunk iterator has been initialized */ hsize_t sel_nelmts; /* Number of elements in selection */ hsize_t count[H5O_LAYOUT_NDIMS]; /* Element count of hyperslab */ size_t chunk_size; /*size of a chunk */ - void * chunk; /* The file chunk */ + void *chunk; /* The file chunk */ H5D_chunk_ud_t chk_udata; /* User data for locking chunk */ uint32_t bytes_accessed; /* Bytes accessed in chunk */ unsigned u; /* Local index variable */ @@ -5182,7 +5330,7 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk) /* The number of bytes accessed in the chunk */ /* (i.e. the bytes replaced with fill values) */ - H5_CHECK_OVERFLOW(sel_nelmts, hssize_t, uint32_t); + H5_CHECK_OVERFLOW(sel_nelmts, hsize_t, uint32_t); bytes_accessed = (uint32_t)sel_nelmts * layout->u.chunk.dim[rank]; /* Release lock on chunk */ @@ -5315,15 +5463,15 @@ H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim) H5D_io_info_t chk_io_info; /* Chunked I/O info object */ H5D_storage_t chk_store; /* Chunk storage information */ const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset's layout */ - const H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ + const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ unsigned space_ndims; /* Dataset's space rank */ - const hsize_t * space_dim; /* Current dataspace dimensions */ + const hsize_t *space_dim; /* Current dataspace dimensions */ unsigned op_dim; /* Current operating dimension */ hbool_t shrunk_dim[H5O_LAYOUT_NDIMS]; /* Dimensions which have shrunk */ H5D_chunk_it_ud1_t udata; /* Chunk index iterator user data */ hbool_t udata_init = FALSE; /* Whether the chunk index iterator user data has been initialized */ H5D_chunk_common_ud_t idx_udata; /* User data for index removal routine */ - H5S_t * chunk_space = NULL; /* Dataspace for a chunk */ + H5S_t *chunk_space = NULL; /* Dataspace for a chunk */ hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Chunk dimensions */ hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Scaled offset of current chunk */ hsize_t hyper_start[H5O_LAYOUT_NDIMS]; /* Starting location of hyperslab */ @@ -5677,7 +5825,7 @@ herr_t H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ - const H5D_t * dset = io_info->dset; /* Local pointer to dataset info */ + const H5D_t *dset = io_info->dset; /* Local pointer to dataset info */ H5D_chunk_it_ud2_t udata; /* User data for iteration callback */ H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ @@ -5803,7 +5951,7 @@ H5D__chunk_delete(H5F_t *f, H5O_t *oh, H5O_storage_t *storage) herr_t H5D__chunk_update_cache(H5D_t *dset) { - H5D_rdcc_t * rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent, *next; /*cache entry */ H5D_rdcc_ent_t tmp_head; /* Sentinel entry for temporary entry list */ H5D_rdcc_ent_t *tmp_tail; /* Tail pointer for temporary entry list */ @@ -5922,12 +6070,12 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ /* General information about chunk copy */ - void * bkg = udata->bkg; /* Background buffer for datatype conversion */ - void * buf = udata->buf; /* Chunk buffer for I/O & datatype conversions */ + void *bkg = udata->bkg; /* Background buffer for datatype conversion */ + void *buf = udata->buf; /* Chunk buffer for I/O & datatype conversions */ size_t buf_size = udata->buf_size; /* Size of chunk buffer */ const H5O_pline_t *pline = udata->pline; /* I/O pipeline for applying filters */ - /* needed for commpressed variable length data */ + /* needed for compressed variable length data */ hbool_t must_filter = FALSE; /* Whether chunk must be filtered during copy */ size_t nbytes; /* Size of chunk in file (in bytes) */ H5Z_cb_t filter_cb; /* Filter failure callback struct */ @@ -5996,7 +6144,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ unsigned idx; /* Index of chunk in cache, if present */ unsigned u; /* Counter */ - H5D_shared_t * shared_fo = (H5D_shared_t *)udata->cpy_info->shared_fo; + H5D_shared_t *shared_fo = (H5D_shared_t *)udata->cpy_info->shared_fo; /* See if the written chunk is in the chunk cache */ if (shared_fo && shared_fo->cache.chunk.nslots > 0) { @@ -6020,6 +6168,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) if (udata->chunk_in_cache) { HDassert(H5F_addr_defined(chunk_rec->chunk_addr)); + HDassert(ent); HDassert(H5F_addr_defined(ent->chunk_block.offset)); H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t); @@ -6046,11 +6195,11 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) if (is_vlen) { H5T_path_t *tpath_src_mem = udata->tpath_src_mem; H5T_path_t *tpath_mem_dst = udata->tpath_mem_dst; - H5S_t * buf_space = udata->buf_space; + H5S_t *buf_space = udata->buf_space; hid_t tid_src = udata->tid_src; hid_t tid_dst = udata->tid_dst; hid_t tid_mem = udata->tid_mem; - void * reclaim_buf = udata->reclaim_buf; + void *reclaim_buf = udata->reclaim_buf; size_t reclaim_buf_size = udata->reclaim_buf_size; /* Convert from source file to memory */ @@ -6169,16 +6318,16 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ H5O_pline_t _pline; /* Temporary pipeline info */ const H5O_pline_t *pline; /* Pointer to pipeline info to use */ - H5T_path_t * tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ + H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ hid_t tid_src = -1; /* Datatype ID for source datatype */ hid_t tid_dst = -1; /* Datatype ID for destination datatype */ hid_t tid_mem = -1; /* Datatype ID for memory datatype */ size_t buf_size; /* Size of copy buffer */ size_t reclaim_buf_size; /* Size of reclaim buffer */ - void * buf = NULL; /* Buffer for copying data */ - void * bkg = NULL; /* Buffer for background during type conversion */ - void * reclaim_buf = NULL; /* Buffer for reclaiming data */ - H5S_t * buf_space = NULL; /* Dataspace describing buffer */ + void *buf = NULL; /* Buffer for copying data */ + void *bkg = NULL; /* Buffer for background during type conversion */ + void *reclaim_buf = NULL; /* Buffer for reclaiming data */ + H5S_t *buf_space = NULL; /* Dataspace describing buffer */ hid_t sid_buf = -1; /* ID for buffer dataspace */ uint32_t nelmts = 0; /* Number of elements in buffer */ hbool_t do_convert = FALSE; /* Indicate that type conversions should be performed */ @@ -6247,8 +6396,8 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk /* If there's a VLEN source datatype, set up type conversion information */ if (H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { - H5T_t * dt_dst; /* Destination datatype */ - H5T_t * dt_mem; /* Memory datatype */ + H5T_t *dt_dst; /* Destination datatype */ + H5T_t *dt_mem; /* Memory datatype */ size_t mem_dt_size; /* Memory datatype size */ size_t tmp_dt_size; /* Temp. datatype size */ size_t max_dt_size; /* Max atatype size */ @@ -6263,7 +6412,7 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ - /* create variable-length datatype at the destinaton file */ + /* create variable-length datatype at the destination file */ if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { @@ -6301,7 +6450,7 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk if (NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") - /* Atomize */ + /* Register */ if ((sid_buf = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { (void)H5S_close(buf_space); HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") @@ -6379,7 +6528,7 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5O_layout_chunk if (udata.cpy_info->shared_fo) { H5D_rdcc_ent_t *ent, *next; H5D_chunk_rec_t chunk_rec; - H5D_shared_t * shared_fo = (H5D_shared_t *)udata.cpy_info->shared_fo; + H5D_shared_t *shared_fo = (H5D_shared_t *)udata.cpy_info->shared_fo; chunk_rec.nbytes = layout_src->size; chunk_rec.filter_mask = 0; @@ -6443,7 +6592,7 @@ herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5O_layout_t *layout, hsize_t *index_size) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5S_t * space = NULL; /* Dataset's dataspace */ + H5S_t *space = NULL; /* Dataset's dataspace */ H5O_pline_t pline; /* I/O pipeline message */ H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); htri_t exists; /* Flag if header message of interest exists */ @@ -6657,10 +6806,10 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) miss_rate = 0.0; } if (miss_rate > 100) { - HDsprintf(ascii, "%7d%%", (int)(miss_rate + 0.5)); + HDsnprintf(ascii, sizeof(ascii), "%7d%%", (int)(miss_rate + 0.5)); } else { - HDsprintf(ascii, "%7.2f%%", miss_rate); + HDsnprintf(ascii, sizeof(ascii), "%7.2f%%", miss_rate); } HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", "raw data chunks", rdcc->stats.nhits, @@ -6787,7 +6936,7 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, siz * *------------------------------------------------------------------------- */ -static hbool_t +hbool_t H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims, const hsize_t scaled[], const hsize_t *dset_dims) { @@ -6966,7 +7115,7 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) H5D_chunk_ud_t insert_udata; /* Chunk information to be inserted */ haddr_t chunk_addr; /* Chunk address */ size_t nbytes; /* Chunk size */ - void * buf = NULL; /* Pointer to buffer of chunk data */ + void *buf = NULL; /* Pointer to buffer of chunk data */ int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -7081,6 +7230,89 @@ H5D__chunk_format_convert(H5D_t *dset, H5D_chk_idx_info_t *idx_info, H5D_chk_idx FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_format_convert() */ +/*------------------------------------------------------------------------- + * Function: H5D__chunk_index_empty_cb + * + * Purpose: Callback function that simply stops iteration and sets the + * `empty` parameter to FALSE if called. If this callback is + * entered, it means that the chunk index contains at least + * one chunk, so is not empty. + * + * Return: H5_ITER_STOP + * + *------------------------------------------------------------------------- + */ +static int +H5D__chunk_index_empty_cb(const H5D_chunk_rec_t H5_ATTR_UNUSED *chunk_rec, void *_udata) +{ + hbool_t *empty = (hbool_t *)_udata; + int ret_value = H5_ITER_STOP; + + FUNC_ENTER_STATIC_NOERR + + *empty = FALSE; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__chunk_index_empty_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5D__chunk_index_empty + * + * Purpose: Determines whether a chunk index is empty (has no chunks + * inserted into it yet). + * + * Note: This routine is meant to be a little more performant than + * just counting the number of chunks in the index. In the + * future, this is probably a callback that the chunk index + * ops structure should provide. + * + * Return: Non-negative on Success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5D__chunk_index_empty(const H5D_t *dset, hbool_t *empty) +{ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_rdcc_ent_t *ent; /* Cache entry */ + const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) + + HDassert(dset); + HDassert(dset->shared); + HDassert(empty); + + rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ + HDassert(rdcc); + + /* Search for cached chunks that haven't been written out */ + for (ent = rdcc->head; ent; ent = ent->next) + /* Flush the chunk out to disk, to make certain the size is correct later */ + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") + + /* Compose chunked index info struct */ + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; + + *empty = TRUE; + + if (H5F_addr_defined(idx_info.storage->idx_addr)) { + /* Iterate over the allocated chunks */ + if ((dset->shared->layout.storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_index_empty_cb, empty) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve allocated chunk information from index") + } + +done: + FUNC_LEAVE_NOAPI_TAG(ret_value) +} /* end H5D__chunk_index_empty() */ + /*------------------------------------------------------------------------- * Function: H5D__get_num_chunks_cb * @@ -7133,8 +7365,8 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ { H5D_chk_idx_info_t idx_info; /* Chunked index info */ hsize_t num_chunks = 0; /* Number of written chunks */ - H5D_rdcc_ent_t * ent; /* Cache entry */ - const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */ + H5D_rdcc_ent_t *ent; /* Cache entry */ + const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7246,8 +7478,8 @@ H5D__get_chunk_info(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ { H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5D_chunk_info_iter_ud_t udata; /* User data for callback */ - const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */ - H5D_rdcc_ent_t * ent; /* Cache entry index */ + const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ + H5D_rdcc_ent_t *ent; /* Cache entry index */ hsize_t ii = 0; /* Dimension index */ herr_t ret_value = SUCCEED; /* Return value */ @@ -7379,9 +7611,9 @@ herr_t H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) { - const H5O_layout_t * layout = NULL; /* Dataset layout */ - const H5D_rdcc_t * rdcc = NULL; /* Raw data chunk cache */ - H5D_rdcc_ent_t * ent; /* Cache entry index */ + const H5O_layout_t *layout = NULL; /* Dataset layout */ + const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ + H5D_rdcc_ent_t *ent; /* Cache entry index */ H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5D_chunk_info_iter_ud_t udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -7451,3 +7683,106 @@ H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *offset, unsigned done: FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5D__get_chunk_info_by_coord() */ + +/*------------------------------------------------------------------------- + * Function: H5D__chunk_iter_cb + * + * Purpose: Call the user-defined function with the chunk data. The iterator continues if + * the user-defined function returns H5_ITER_CONT, and stops if H5_ITER_STOP is + * returned. + * + * Return: Success: H5_ITER_CONT or H5_ITER_STOP + * Failure: Negative (H5_ITER_ERROR) + * + * Programmer: Gaute Hope + * August 2020 + * + *------------------------------------------------------------------------- + */ +static int +H5D__chunk_iter_cb(const H5D_chunk_rec_t *chunk_rec, void *udata) +{ + const H5D_chunk_iter_ud_t *data = (H5D_chunk_iter_ud_t *)udata; + const H5O_layout_chunk_t *chunk = data->chunk; + int ret_value = H5_ITER_CONT; + hsize_t offset[H5O_LAYOUT_NDIMS]; + unsigned ii; /* Match H5O_layout_chunk_t.ndims */ + + /* Similar to H5D__get_chunk_info */ + for (ii = 0; ii < chunk->ndims; ii++) + offset[ii] = chunk_rec->scaled[ii] * chunk->dim[ii]; + + FUNC_ENTER_PACKAGE_NOERR + + /* Check for callback failure and pass along return value */ + if ((ret_value = (data->op)(offset, (unsigned)chunk_rec->filter_mask, chunk_rec->chunk_addr, + (hsize_t)chunk_rec->nbytes, data->op_data)) < 0) + HERROR(H5E_DATASET, H5E_CANTNEXT, "iteration operator failed"); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__chunk_iter_cb */ + +/*------------------------------------------------------------------------- + * Function: H5D__chunk_iter + * + * Purpose: Iterate over all the chunks in the dataset with given callback. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Gaute Hope + * August 2020 + * + *------------------------------------------------------------------------- + */ +herr_t +H5D__chunk_iter(H5D_t *dset, H5D_chunk_iter_op_t op, void *op_data) +{ + const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ + H5O_layout_t *layout = NULL; /* Dataset layout */ + H5D_rdcc_ent_t *ent; /* Cache entry index */ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) + + /* Check args */ + HDassert(dset); + HDassert(dset->shared); + + /* Get dataset layout and raw data chunk cache */ + layout = &(dset->shared->layout); + rdcc = &(dset->shared->cache.chunk); + HDassert(layout); + HDassert(rdcc); + HDassert(H5D_CHUNKED == layout->type); + + /* Search for cached chunks that haven't been written out */ + for (ent = rdcc->head; ent; ent = ent->next) + /* Flush the chunk out to disk, to make certain the size is correct later */ + if (H5D__chunk_flush_entry(dset, ent, FALSE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "cannot flush indexed storage buffer") + + /* Compose chunked index info struct */ + idx_info.f = dset->oloc.file; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &layout->u.chunk; + idx_info.storage = &layout->storage.u.chunk; + + /* If the dataset is not written, return without errors */ + if (H5F_addr_defined(idx_info.storage->idx_addr)) { + H5D_chunk_iter_ud_t ud; + + /* Set up info for iteration callback */ + ud.op = op; + ud.op_data = op_data; + ud.chunk = &dset->shared->layout.u.chunk; + + /* Iterate over the allocated chunks calling the iterator callback */ + if ((ret_value = (layout->storage.u.chunk.ops->iterate)(&idx_info, H5D__chunk_iter_cb, &ud)) < 0) + HERROR(H5E_DATASET, H5E_CANTNEXT, "chunk iteration failed"); + } /* end if H5F_addr_defined */ + +done: + FUNC_LEAVE_NOAPI_TAG(ret_value) +} /* end H5D__chunk_iter() */ diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 8a2c7705c6a..5c510fff055 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -55,8 +54,7 @@ static herr_t H5D__compact_construct(H5F_t *f, H5D_t *dset); static hbool_t H5D__compact_is_space_alloc(const H5O_storage_t *storage); static herr_t H5D__compact_io_init(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, - H5D_chunk_map_t *cm); + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *cm); static ssize_t H5D__compact_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]); @@ -71,13 +69,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 */ @@ -228,8 +237,8 @@ H5D__compact_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) */ static herr_t H5D__compact_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *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 H5_ATTR_UNUSED *cm) + hsize_t H5_ATTR_UNUSED nelmts, H5S_t H5_ATTR_UNUSED *file_space, + H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR @@ -403,9 +412,9 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds hid_t tid_src = -1; /* Datatype ID for source datatype */ hid_t tid_dst = -1; /* Datatype ID for destination datatype */ hid_t tid_mem = -1; /* Datatype ID for memory datatype */ - void * buf = NULL; /* Buffer for copying data */ - void * bkg = NULL; /* Temporary buffer for copying data */ - void * reclaim_buf = NULL; /* Buffer for reclaiming data */ + void *buf = NULL; /* Buffer for copying data */ + void *bkg = NULL; /* Temporary buffer for copying data */ + void *reclaim_buf = NULL; /* Buffer for reclaiming data */ hid_t buf_sid = -1; /* ID for buffer dataspace */ H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ @@ -433,9 +442,9 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds /* If there's a VLEN source datatype, do type conversion information */ if (H5T_detect_class(dt_src, H5T_VLEN, FALSE) > 0) { H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */ - H5T_t * dt_dst; /* Destination datatype */ - H5T_t * dt_mem; /* Memory datatype */ - H5S_t * buf_space; /* Dataspace describing buffer */ + H5T_t *dt_dst; /* Destination datatype */ + H5T_t *dt_mem; /* Memory datatype */ + H5S_t *buf_space; /* Dataspace describing buffer */ size_t buf_size; /* Size of copy buffer */ size_t nelmts; /* Number of elements in buffer */ size_t src_dt_size; /* Source datatype size */ @@ -451,7 +460,7 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ - /* create variable-length datatype at the destinaton file */ + /* create variable-length datatype at the destination file */ if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy") if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { @@ -493,7 +502,7 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds if (NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") - /* Atomize */ + /* Register */ if ((buf_sid = H5I_register(H5I_DATASPACE, buf_space, FALSE)) < 0) { H5S_close(buf_space); HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 57c15028417..f91ba431346 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -55,30 +54,30 @@ /* Callback info for sieve buffer readvv operation */ typedef struct H5D_contig_readvv_sieve_ud_t { - H5F_shared_t * f_sh; /* Shared file for dataset */ - H5D_rdcdc_t * dset_contig; /* Cached information about contiguous data */ + H5F_shared_t *f_sh; /* Shared file for dataset */ + H5D_rdcdc_t *dset_contig; /* Cached information about contiguous data */ const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */ - unsigned char * rbuf; /* Pointer to buffer to fill */ + unsigned char *rbuf; /* Pointer to buffer to fill */ } H5D_contig_readvv_sieve_ud_t; /* Callback info for [plain] readvv operation */ typedef struct H5D_contig_readvv_ud_t { - H5F_shared_t * f_sh; /* Shared file for dataset */ + H5F_shared_t *f_sh; /* Shared file for dataset */ haddr_t dset_addr; /* Address of dataset */ unsigned char *rbuf; /* Pointer to buffer to fill */ } H5D_contig_readvv_ud_t; /* Callback info for sieve buffer writevv operation */ typedef struct H5D_contig_writevv_sieve_ud_t { - H5F_shared_t * f_sh; /* Shared file for dataset */ - H5D_rdcdc_t * dset_contig; /* Cached information about contiguous data */ + H5F_shared_t *f_sh; /* Shared file for dataset */ + H5D_rdcdc_t *dset_contig; /* Cached information about contiguous data */ const H5D_contig_storage_t *store_contig; /* Contiguous storage info for this I/O operation */ - const unsigned char * wbuf; /* Pointer to buffer to write */ + const unsigned char *wbuf; /* Pointer to buffer to write */ } H5D_contig_writevv_sieve_ud_t; /* Callback info for [plain] writevv operation */ typedef struct H5D_contig_writevv_ud_t { - H5F_shared_t * f_sh; /* Shared file for dataset */ + H5F_shared_t *f_sh; /* Shared file for dataset */ haddr_t dset_addr; /* Address of dataset */ const unsigned char *wbuf; /* Pointer to buffer to write */ } H5D_contig_writevv_ud_t; @@ -91,8 +90,7 @@ typedef struct H5D_contig_writevv_ud_t { static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset); static herr_t H5D__contig_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id); static herr_t H5D__contig_io_init(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, - H5D_chunk_map_t *cm); + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *cm); static ssize_t H5D__contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); @@ -109,13 +107,24 @@ static herr_t H5D__contig_write_one(H5D_io_info_t *io_info, hsize_t offset, size /*********************/ /* 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 */ @@ -173,7 +182,7 @@ H5D__contig_alloc(H5F_t *f, H5O_storage_contig_t *storage /*out */) herr_t H5D__contig_fill(const H5D_io_info_t *io_info) { - const H5D_t * dset = io_info->dset; /* the dataset pointer */ + const H5D_t *dset = io_info->dset; /* the dataset pointer */ H5D_io_info_t ioinfo; /* Dataset I/O info */ H5D_storage_t store; /* Union of storage info for dataset */ hssize_t snpoints; /* Number of points in space (for error checking) */ @@ -268,9 +277,16 @@ H5D__contig_fill(const H5D_io_info_t *io_info) if (using_mpi) { /* Write the chunks out from only one process */ /* !! Use the internal "independent" DXPL!! -QAK */ - if (H5_PAR_META_WRITE == mpi_rank) - if (H5D__contig_write_one(&ioinfo, offset, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") + if (H5_PAR_META_WRITE == mpi_rank) { + if (H5D__contig_write_one(&ioinfo, offset, size) < 0) { + /* If writing fails, push an error and stop writing, but + * still participate in following MPI_Barrier. + */ + blocks_written = TRUE; + HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset") + break; + } + } /* Indicate that blocks are being written */ blocks_written = TRUE; @@ -521,7 +537,7 @@ H5D__contig_is_space_alloc(const H5O_storage_t *storage) * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner - * Wednessday, March 6, 2016 + * Wednesday, March 6, 2016 * *------------------------------------------------------------------------- */ @@ -550,8 +566,8 @@ H5D__contig_is_data_cached(const H5D_shared_t *shared_dset) */ static herr_t H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *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 H5_ATTR_UNUSED *cm) + hsize_t H5_ATTR_UNUSED nelmts, H5S_t H5_ATTR_UNUSED *file_space, + H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR @@ -574,8 +590,8 @@ H5D__contig_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_ *------------------------------------------------------------------------- */ 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 */ @@ -609,8 +625,8 @@ H5D__contig_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize *------------------------------------------------------------------------- */ 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 */ @@ -686,7 +702,7 @@ H5D__contig_readvv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void * H5D_contig_readvv_sieve_ud_t *udata = (H5D_contig_readvv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */ H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */ - H5D_rdcdc_t * dset_contig = udata->dset_contig; /* Cached information about contiguous data */ + H5D_rdcdc_t *dset_contig = udata->dset_contig; /* Cached information about contiguous data */ const H5D_contig_storage_t *store_contig = udata->store_contig; /* Contiguous storage info for this I/O operation */ unsigned char *buf; /* Pointer to buffer to fill */ @@ -953,7 +969,7 @@ H5D__contig_writevv_sieve_cb(hsize_t dst_off, hsize_t src_off, size_t len, void H5D_contig_writevv_sieve_ud_t *udata = (H5D_contig_writevv_sieve_ud_t *)_udata; /* User data for H5VM_opvv() operator */ H5F_shared_t *f_sh = udata->f_sh; /* Shared file for dataset */ - H5D_rdcdc_t * dset_contig = udata->dset_contig; /* Cached information about contiguous data */ + H5D_rdcdc_t *dset_contig = udata->dset_contig; /* Cached information about contiguous data */ const H5D_contig_storage_t *store_contig = udata->store_contig; /* Contiguous storage info for this I/O operation */ const unsigned char *buf; /* Pointer to buffer to fill */ @@ -1301,9 +1317,9 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f { haddr_t addr_src; /* File offset in source dataset */ haddr_t addr_dst; /* File offset in destination dataset */ - H5T_path_t * tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ - H5T_t * dt_dst = NULL; /* Destination datatype */ - H5T_t * dt_mem = NULL; /* Memory datatype */ + H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ + H5T_t *dt_dst = NULL; /* Destination datatype */ + H5T_t *dt_mem = NULL; /* Memory datatype */ hid_t tid_src = -1; /* Datatype ID for source datatype */ hid_t tid_dst = -1; /* Datatype ID for destination datatype */ hid_t tid_mem = -1; /* Datatype ID for memory datatype */ @@ -1317,10 +1333,10 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f size_t dst_nbytes; /* Number of bytes to write to destination */ hsize_t total_src_nbytes; /* Total number of bytes to copy */ size_t buf_size; /* Size of copy buffer */ - void * buf = NULL; /* Buffer for copying data */ - void * bkg = NULL; /* Temporary buffer for copying data */ - void * reclaim_buf = NULL; /* Buffer for reclaiming data */ - H5S_t * buf_space = NULL; /* Dataspace describing buffer */ + void *buf = NULL; /* Buffer for copying data */ + void *bkg = NULL; /* Temporary buffer for copying data */ + void *reclaim_buf = NULL; /* Buffer for reclaiming data */ + H5S_t *buf_space = NULL; /* Dataspace describing buffer */ hid_t buf_sid = -1; /* ID for buffer dataspace */ hsize_t buf_dim[1] = {0}; /* Dimension for buffer */ hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */ @@ -1367,7 +1383,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ - /* create variable-length datatype at the destinaton file */ + /* create variable-length datatype at the destination file */ if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy") if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(f_dst), H5T_LOC_DISK) < 0) { @@ -1496,7 +1512,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f else /* Read raw data from source file */ if (H5F_block_read(f_src, H5FD_MEM_DRAW, addr_src, src_nbytes, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data") + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data") /* Perform datatype conversion, if necessary */ if (is_vlen) { diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c index d39d357f41e..0dc6bd726da 100644 --- a/src/H5Ddbg.c +++ b/src/H5Ddbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index ec1998f0b07..1b3fa643a2f 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -103,8 +102,8 @@ hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - void * dset = NULL; /* dset object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *dset = NULL; /* dset object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -175,8 +174,8 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t hid_t H5Dopen1(hid_t loc_id, const char *name) { - void * dset = NULL; /* dset object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *dset = NULL; /* dset object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -235,7 +234,7 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) { H5VL_object_t *vol_obj = NULL; /* Dataset structure */ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ - H5S_t * ds = NULL; /* Dataspace struct */ + H5S_t *ds = NULL; /* Dataspace struct */ int ndims; /* Dataset/space rank */ hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ int i; /* Local index variable */ diff --git a/src/H5Dearray.c b/src/H5Dearray.c index abce23308cf..84c9335a738 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -72,7 +71,7 @@ typedef struct H5D_earray_it_ud_t { H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ hbool_t filtered; /* Whether the chunks are filtered */ H5D_chunk_cb_func_t cb; /* Chunk callback routine */ - void * udata; /* User data for chunk callback routine */ + void *udata; /* User data for chunk callback routine */ } H5D_earray_it_ud_t; /* Native extensible array element for chunks w/filters */ @@ -90,13 +89,13 @@ static int H5D__earray_idx_iterate_cb(hsize_t idx, const void *_elmt, void *_uda static int H5D__earray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); /* Extensible array class callbacks for chunks w/o filters */ -static void * H5D__earray_crt_context(void *udata); +static void *H5D__earray_crt_context(void *udata); static herr_t H5D__earray_dst_context(void *ctx); static herr_t H5D__earray_fill(void *nat_blk, size_t nelmts); static herr_t H5D__earray_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); static herr_t H5D__earray_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); static herr_t H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); -static void * H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr); +static void *H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr); static herr_t H5D__earray_dst_dbg_context(void *dbg_ctx); /* Extensible array class callbacks for chunks w/filters */ @@ -215,9 +214,9 @@ H5FL_DEFINE_STATIC(H5D_earray_ctx_ud_t); static void * H5D__earray_crt_context(void *_udata) { - H5D_earray_ctx_t * ctx; /* Extensible array callback context */ + H5D_earray_ctx_t *ctx; /* Extensible array callback context */ H5D_earray_ctx_ud_t *udata = (H5D_earray_ctx_ud_t *)_udata; /* User data for extensible array context */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -323,7 +322,7 @@ static herr_t H5D__earray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) { H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ - const haddr_t * elmt = (const haddr_t *)_elmt; /* Convenience pointer to native elements */ + const haddr_t *elmt = (const haddr_t *)_elmt; /* Convenience pointer to native elements */ FUNC_ENTER_STATIC_NOERR @@ -366,8 +365,8 @@ static herr_t H5D__earray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) { H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ - haddr_t * elmt = (haddr_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t * raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + haddr_t *elmt = (haddr_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ FUNC_ENTER_STATIC_NOERR @@ -417,7 +416,7 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt); FUNC_LEAVE_NOAPI(SUCCEED) @@ -469,8 +468,8 @@ H5D__earray_filt_fill(void *nat_blk, size_t nelmts) static herr_t H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx) { - H5D_earray_ctx_t * ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ - uint8_t * raw = (uint8_t *)_raw; /* Convenience pointer to raw elements */ + H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ + uint8_t *raw = (uint8_t *)_raw; /* Convenience pointer to raw elements */ const H5D_earray_filt_elmt_t *elmt = (const H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ @@ -516,7 +515,7 @@ H5D__earray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx static herr_t H5D__earray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) { - H5D_earray_ctx_t * ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ + H5D_earray_ctx_t *ctx = (H5D_earray_ctx_t *)_ctx; /* Extensible array callback context */ H5D_earray_filt_elmt_t *elmt = (H5D_earray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ @@ -573,7 +572,7 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx); HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr, elmt->nbytes, elmt->filter_mask); @@ -600,7 +599,7 @@ H5D__earray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) H5O_loc_t obj_loc; /* Pointer to an object's location */ hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ H5O_layout_t layout; /* Layout message */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -701,7 +700,7 @@ H5D__earray_dst_dbg_context(void *_dbg_ctx) static herr_t H5D__earray_idx_depend(const H5D_chk_idx_info_t *idx_info) { - H5O_t * oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ H5O_loc_t oloc; /* Temporary object header location for dataset */ H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1272,7 +1271,7 @@ H5D__earray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * static int H5D__earray_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5EA_t * ea; /* Pointer to extensible array structure */ + H5EA_t *ea; /* Pointer to extensible array structure */ H5EA_stat_t ea_stat; /* Extensible array statistics */ int ret_value = H5_ITER_CONT; /* Return value */ @@ -1367,7 +1366,7 @@ H5D__earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t } else /* Patch the top level file pointer contained in ea if needed */ if (H5EA_patch_file(idx_info->storage->u.earray.ea, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch earray file pointer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch earray file pointer") /* Set convenience pointer to extensible array structure */ ea = idx_info->storage->u.earray.ea; @@ -1645,7 +1644,7 @@ H5D__earray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chun static herr_t H5D__earray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5EA_t * ea; /* Pointer to extensible array structure */ + H5EA_t *ea; /* Pointer to extensible array structure */ H5EA_stat_t ea_stat; /* Extensible array statistics */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Defl.c b/src/H5Defl.c index 85c9dbaea44..ae850a79017 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -44,14 +43,14 @@ /* Callback info for readvv operation */ typedef struct H5D_efl_readvv_ud_t { const H5O_efl_t *efl; /* Pointer to efl info */ - const H5D_t * dset; /* The dataset */ - unsigned char * rbuf; /* Read buffer */ + const H5D_t *dset; /* The dataset */ + unsigned char *rbuf; /* Read buffer */ } H5D_efl_readvv_ud_t; /* Callback info for writevv operation */ typedef struct H5D_efl_writevv_ud_t { - const H5O_efl_t * efl; /* Pointer to efl info */ - const H5D_t * dset; /* The dataset */ + const H5O_efl_t *efl; /* Pointer to efl info */ + const H5D_t *dset; /* The dataset */ const unsigned char *wbuf; /* Write buffer */ } H5D_efl_writevv_ud_t; @@ -62,7 +61,7 @@ typedef struct H5D_efl_writevv_ud_t { /* Layout operation callbacks */ static herr_t H5D__efl_construct(H5F_t *f, H5D_t *dset); static herr_t H5D__efl_io_init(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, H5D_chunk_map_t *cm); + H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *cm); static ssize_t H5D__efl_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); @@ -80,12 +79,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 */ @@ -198,8 +209,8 @@ H5D__efl_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) */ static herr_t H5D__efl_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *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 H5_ATTR_UNUSED *cm) + hsize_t H5_ATTR_UNUSED nelmts, H5S_t H5_ATTR_UNUSED *file_space, + H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *cm) { FUNC_ENTER_STATIC_NOERR @@ -235,7 +246,7 @@ H5D__efl_read(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t size haddr_t cur; ssize_t n; size_t u; /* Local index variable */ - char * full_name = NULL; /* File name with prefix */ + char *full_name = NULL; /* File name with prefix */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -323,7 +334,7 @@ H5D__efl_write(const H5O_efl_t *efl, const H5D_t *dset, haddr_t addr, size_t siz haddr_t cur; hsize_t skip = 0; size_t u; /* Local index variable */ - char * full_name = NULL; /* File name with prefix */ + char *full_name = NULL; /* File name with prefix */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index 0741e8f5518..1e92c9e1978 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -70,7 +69,7 @@ typedef struct H5D_farray_it_ud_t { H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ hbool_t filtered; /* Whether the chunks are filtered */ H5D_chunk_cb_func_t cb; /* Chunk callback routine */ - void * udata; /* User data for chunk callback routine */ + void *udata; /* User data for chunk callback routine */ } H5D_farray_it_ud_t; /* Native fixed array element for chunks w/filters */ @@ -89,13 +88,13 @@ static int H5D__farray_idx_iterate_cb(hsize_t idx, const void *_elmt, void *_uda static int H5D__farray_idx_delete_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata); /* Fixed array class callbacks for chunks w/o filters */ -static void * H5D__farray_crt_context(void *udata); +static void *H5D__farray_crt_context(void *udata); static herr_t H5D__farray_dst_context(void *ctx); static herr_t H5D__farray_fill(void *nat_blk, size_t nelmts); static herr_t H5D__farray_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); static herr_t H5D__farray_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); static herr_t H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); -static void * H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr); +static void *H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr); static herr_t H5D__farray_dst_dbg_context(void *dbg_ctx); /* Fixed array class callbacks for chunks w/filters */ @@ -214,9 +213,9 @@ H5FL_DEFINE_STATIC(H5D_farray_ctx_ud_t); static void * H5D__farray_crt_context(void *_udata) { - H5D_farray_ctx_t * ctx; /* Fixed array callback context */ + H5D_farray_ctx_t *ctx; /* Fixed array callback context */ H5D_farray_ctx_ud_t *udata = (H5D_farray_ctx_ud_t *)_udata; /* User data for fixed array context */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -321,7 +320,7 @@ static herr_t H5D__farray_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) { H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ - const haddr_t * elmt = (const haddr_t *)_elmt; /* Convenience pointer to native elements */ + const haddr_t *elmt = (const haddr_t *)_elmt; /* Convenience pointer to native elements */ FUNC_ENTER_STATIC_NOERR @@ -364,8 +363,8 @@ static herr_t H5D__farray_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) { H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ - haddr_t * elmt = (haddr_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t * raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + haddr_t *elmt = (haddr_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ FUNC_ENTER_STATIC_NOERR @@ -415,7 +414,7 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt); FUNC_LEAVE_NOAPI(SUCCEED) @@ -442,7 +441,7 @@ H5D__farray_crt_dbg_context(H5F_t *f, haddr_t obj_addr) H5O_loc_t obj_loc; /* Pointer to an object's location */ hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */ H5O_layout_t layout; /* Layout message */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -571,8 +570,8 @@ H5D__farray_filt_fill(void *nat_blk, size_t nelmts) static herr_t H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx) { - H5D_farray_ctx_t * ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ - uint8_t * raw = (uint8_t *)_raw; /* Convenience pointer to raw elements */ + H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ + uint8_t *raw = (uint8_t *)_raw; /* Convenience pointer to raw elements */ const H5D_farray_filt_elmt_t *elmt = (const H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ @@ -618,7 +617,7 @@ H5D__farray_filt_encode(void *_raw, const void *_elmt, size_t nelmts, void *_ctx static herr_t H5D__farray_filt_decode(const void *_raw, void *_elmt, size_t nelmts, void *_ctx) { - H5D_farray_ctx_t * ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ + H5D_farray_ctx_t *ctx = (H5D_farray_ctx_t *)_ctx; /* Fixed array callback context */ H5D_farray_filt_elmt_t *elmt = (H5D_farray_filt_elmt_t *)_elmt; /* Convenience pointer to native elements */ const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ @@ -675,7 +674,7 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx); HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr, elmt->nbytes, elmt->filter_mask); @@ -699,7 +698,7 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const static herr_t H5D__farray_idx_depend(const H5D_chk_idx_info_t *idx_info) { - H5O_t * oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ H5O_loc_t oloc; /* Temporary object header location for dataset */ H5AC_proxy_entry_t *oh_proxy; /* Dataset's object header proxy */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1151,7 +1150,7 @@ H5D__farray_idx_iterate_cb(hsize_t H5_ATTR_UNUSED idx, const void *_elmt, void * static int H5D__farray_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5FA_t * fa; /* Pointer to fixed array structure */ + H5FA_t *fa; /* Pointer to fixed array structure */ H5FA_stat_t fa_stat; /* Fixed array statistics */ int ret_value = FAIL; /* Return value */ @@ -1247,7 +1246,7 @@ H5D__farray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t } else /* Patch the top level file pointer contained in fa if needed */ if (H5FA_patch_file(idx_info->storage->u.farray.fa, idx_info->f) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch fixed array file pointer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "can't patch fixed array file pointer") /* Set convenience pointer to fixed array structure */ fa = idx_info->storage->u.farray.fa; @@ -1503,7 +1502,7 @@ H5D__farray_idx_copy_shutdown(H5O_storage_chunk_t *storage_src, H5O_storage_chun static herr_t H5D__farray_idx_size(const H5D_chk_idx_info_t *idx_info, hsize_t *index_size) { - H5FA_t * fa; /* Pointer to fixed array structure */ + H5FA_t *fa; /* Pointer to fixed array structure */ H5FA_stat_t fa_stat; /* Fixed array statistics */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dfill.c b/src/H5Dfill.c index b7ecdc99a91..8f549871746 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -164,16 +163,16 @@ H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_ 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 */ - H5WB_t * elem_wb = NULL; /* Wrapped buffer for element data */ + H5WB_t *elem_wb = NULL; /* Wrapped buffer for element data */ uint8_t elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for element data */ - H5WB_t * bkg_elem_wb = NULL; /* Wrapped buffer for background data */ + H5WB_t *bkg_elem_wb = NULL; /* Wrapped buffer for background data */ uint8_t bkg_elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for background data */ - uint8_t * bkg_buf = NULL; /* Background conversion buffer */ - uint8_t * tmp_buf = NULL; /* Temp conversion buffer */ + uint8_t *bkg_buf = NULL; /* Background conversion buffer */ + uint8_t *tmp_buf = NULL; /* Temp conversion buffer */ hid_t src_id = -1, dst_id = -1; /* Temporary type IDs */ size_t dst_type_size; /* Size of destination type*/ herr_t ret_value = SUCCEED; /* Return value */ @@ -560,7 +559,7 @@ herr_t H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts) { herr_t ret_value = SUCCEED; /* Return value */ - void * buf = NULL; /* Temporary fill buffer */ + void *buf = NULL; /* Temporary fill buffer */ FUNC_ENTER_PACKAGE diff --git a/src/H5Dint.c b/src/H5Dint.c index 5782d70f175..f5455e13a96 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -43,8 +42,8 @@ /* Shared data structure for computing variable-length dataset's total size */ /* (Used for both native and generic 'get vlen buf size' operation) */ typedef struct { - void * fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ - void * vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ + void *fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ + void *vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ size_t vl_tbuf_size; /* Current size of the temp. buffer for VL data */ hsize_t size; /* Accumulated number of bytes for the selection */ } H5D_vlen_bufsize_common_t; @@ -52,18 +51,18 @@ typedef struct { /* Internal data structure for computing variable-length dataset's total size */ /* (Used for native 'get vlen buf size' operation) */ typedef struct { - H5D_t * dset; /* Dataset for operation */ - H5S_t * fspace; /* Dataset's dataspace for operation */ - H5S_t * mspace; /* Memory dataspace for operation */ + H5D_t *dset; /* Dataset for operation */ + H5S_t *fspace; /* Dataset's dataspace for operation */ + H5S_t *mspace; /* Memory dataspace for operation */ H5D_vlen_bufsize_common_t common; /* VL data buffers & accumulatd size */ } H5D_vlen_bufsize_native_t; /* Internal data structure for computing variable-length dataset's total size */ /* (Used for generic 'get vlen buf size' operation) */ typedef struct { - H5VL_object_t * dset_vol_obj; /* VOL object for the dataset */ + H5VL_object_t *dset_vol_obj; /* VOL object for the dataset */ hid_t fspace_id; /* Dataset dataspace ID of the dataset we are working on */ - H5S_t * fspace; /* Dataset's dataspace for operation */ + H5S_t *fspace; /* Dataset's dataspace for operation */ hid_t mspace_id; /* Memory dataspace ID of the dataset we are working on */ hid_t dxpl_id; /* Dataset transfer property list to pass to dataset read */ H5D_vlen_bufsize_common_t common; /* VL data buffers & accumulatd size */ @@ -75,7 +74,7 @@ typedef struct { /* General stuff */ static H5D_shared_t *H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type); -static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type); +static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, H5T_t *type); static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id); @@ -87,7 +86,7 @@ static herr_t H5D__close_cb(H5VL_object_t *dset_vol_obj); static herr_t H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize); static herr_t H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc); static size_t H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr); -static void * H5D__vlen_get_buf_size_alloc(size_t size, void *info); +static void *H5D__vlen_get_buf_size_alloc(size_t size, void *info); static herr_t H5D__vlen_get_buf_size_cb(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *op_data); static herr_t H5D__vlen_get_buf_size_gen_cb(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, @@ -192,7 +191,7 @@ H5D__init_package(void) FUNC_ENTER_PACKAGE - /* Initialize the atom group for the dataset IDs */ + /* Initialize the ID group for the dataset IDs */ if (H5I_register_type(H5I_DATASET_CLS) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface") @@ -367,7 +366,7 @@ H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, const H { H5O_obj_create_t ocrt_info; /* Information for object creation */ H5D_obj_create_t dcrt_info; /* Information for dataset creation */ - H5D_t * ret_value = NULL; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -410,7 +409,7 @@ H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, const H * * Return: * Success: Non-negative - * Failture: Negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -424,40 +423,18 @@ H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation) /* Check for chunked layout */ if (dset->shared->layout.type == H5D_CHUNKED) { - hsize_t space_allocated; /* The number of bytes allocated for chunks */ - hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ - hsize_t nelmts; /* Number of elements in dataspace */ - size_t dt_size; /* Size of datatype */ - hsize_t full_size; /* The number of bytes in the dataset when fully populated */ - - /* For chunked layout set the space status by the storage size */ - /* Get the dataset's dataspace */ - HDassert(dset->shared->space); - - /* Get the total number of elements in dataset's dataspace */ - if ((snelmts = H5S_GET_EXTENT_NPOINTS(dset->shared->space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") - nelmts = (hsize_t)snelmts; - - /* Get the size of the dataset's datatype */ - if (0 == (dt_size = H5T_GET_SIZE(dset->shared->type))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") - - /* Compute the maximum size of the dataset in bytes */ - full_size = nelmts * dt_size; - - /* Check for overflow during multiplication */ - if (nelmts != (full_size / dt_size)) - HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") - - /* Difficult to error check, since the error value is 0 and 0 is a valid value... :-/ */ - if (H5D__get_storage_size(dset, &space_allocated) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") - - /* Decide on how much of the space is allocated */ - if (space_allocated == 0) + hsize_t n_chunks_total = dset->shared->layout.u.chunk.nchunks; + hsize_t n_chunks_alloc = 0; + + if (H5D__get_num_chunks(dset, dset->shared->space, &n_chunks_alloc) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to retrieve number of allocated chunks in dataset") + + HDassert(n_chunks_alloc <= n_chunks_total); + + if (n_chunks_alloc == 0) *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED; - else if (space_allocated == full_size) + else if (n_chunks_alloc == n_chunks_total) *allocation = H5D_SPACE_STATUS_ALLOCATED; else *allocation = H5D_SPACE_STATUS_PART_ALLOCATED; @@ -487,9 +464,9 @@ H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation) static H5D_shared_t * H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) { - H5D_shared_t * new_dset = NULL; /* New dataset object */ + H5D_shared_t *new_dset = NULL; /* New dataset object */ H5P_genplist_t *plist; /* Property list created */ - H5D_shared_t * ret_value = NULL; /* Return value */ + H5D_shared_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -556,7 +533,7 @@ H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) *------------------------------------------------------------------------- */ static herr_t -H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) +H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, H5T_t *type) { htri_t relocatable; /* Flag whether the type is relocatable */ htri_t immutable; /* Flag whether the type is immutable */ @@ -612,8 +589,8 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) /* Use existing datatype */ dset->shared->type_id = type_id; - dset->shared->type = (H5T_t *)type; /* (Cast away const OK - QAK) */ - } /* end else */ + dset->shared->type = type; + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -754,10 +731,10 @@ H5D__use_minimized_dset_headers(H5F_t *file, hbool_t *minimize) static size_t H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) { - H5T_t * type = NULL; + H5T_t *type = NULL; H5O_fill_t *fill_prop = NULL; hbool_t use_at_least_v18 = FALSE; - const char continuation[1] = ""; /* requred for work-around */ + const char continuation[1] = ""; /* required for work-around */ size_t get_value = 0; size_t ret_value = 0; @@ -804,7 +781,7 @@ H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of continuation message") ret_value += get_value; - /* Fill Value (backwards compatability) message size */ + /* Fill Value (backwards compatibility) message size */ if (fill_prop->buf && !use_at_least_v18) { H5O_fill_t old_fill_prop; /* Copy for writing "old" fill value */ @@ -893,7 +870,7 @@ H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) if (ohdr_size == 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "computed header size is invalid") - /* Special allocation of space for compact datsets is handled by the call here. */ + /* Special allocation of space for compact datasets is handled by the call here. */ if (H5O_apply_ohdr(file, oh, dset->shared->dcpl_id, ohdr_size, (size_t)1, oloc) == FAIL) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't apply object header to file") @@ -913,12 +890,12 @@ H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) { - H5O_t * oh = NULL; /* Pointer to dataset's object header */ + H5O_t *oh = NULL; /* Pointer to dataset's object header */ size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ - H5O_loc_t * oloc = NULL; /* Dataset's object location */ - H5O_layout_t * layout; /* Dataset's layout information */ - H5T_t * type; /* Dataset's datatype */ - H5O_fill_t * fill_prop; /* Pointer to dataset's fill value information */ + H5O_loc_t *oloc = NULL; /* Dataset's object location */ + H5O_layout_t *layout; /* Dataset's layout information */ + H5T_t *type; /* Dataset's datatype */ + H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ H5D_fill_value_t fill_status; /* Fill value status */ hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ @@ -1122,7 +1099,7 @@ static herr_t H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char **file_prefix /*out*/) { const char *prefix = NULL; /* prefix used to look for the file */ - char * filepath = NULL; /* absolute path of directory the HDF5 file is in */ + char *filepath = NULL; /* absolute path of directory the HDF5 file is in */ size_t filepath_len; /* length of file path */ size_t prefix_len; /* length of prefix */ size_t file_prefix_len; /* length of expanded prefix */ @@ -1206,9 +1183,9 @@ H5D__build_file_prefix(const H5D_t *dset, H5F_prefix_open_t prefix_type, char ** H5D_t * H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id) { - H5T_t * type = NULL; /* Datatype for dataset (VOL pointer) */ - H5T_t * dt = NULL; /* Datatype for dataset (non-VOL pointer) */ - H5D_t * new_dset = NULL; + H5T_t *type = NULL; /* Datatype for dataset (VOL pointer) */ + H5T_t *dt = NULL; /* Datatype for dataset (non-VOL pointer) */ + H5D_t *new_dset = NULL; H5P_genplist_t *dc_plist = NULL; /* New Property list */ hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ @@ -1217,7 +1194,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t hbool_t pline_copied = FALSE; /* Flag to indicate that pipeline message was copied */ hbool_t efl_copied = FALSE; /* Flag to indicate that external file list message was copied */ H5G_loc_t dset_loc; /* Dataset location */ - H5D_t * ret_value = NULL; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1273,9 +1250,9 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t /* Check if the dataset has a non-default DCPL & get important values, if so */ if (new_dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) { H5O_layout_t *layout; /* Dataset's layout information */ - H5O_pline_t * pline; /* Dataset's I/O pipeline information */ - H5O_fill_t * fill; /* Dataset's fill value info */ - H5O_efl_t * efl; /* Dataset's external file list info */ + H5O_pline_t *pline; /* Dataset's I/O pipeline information */ + H5O_fill_t *fill; /* Dataset's fill value info */ + H5O_efl_t *efl; /* Dataset's external file list info */ htri_t ignore_filters = FALSE; /* Ignore optional filters or not */ if ((ignore_filters = H5Z_ignore_filters(new_dset->shared->dcpl_id, dt, space)) < 0) @@ -1347,10 +1324,19 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest indexing") } /* end if */ - /* Check if this dataset is going into a parallel file and set space allocation time */ + /* Check if the file driver would like to force early space allocation */ if (H5F_HAS_FEATURE(file, H5FD_FEAT_ALLOCATE_EARLY)) new_dset->shared->dcpl_cache.fill.alloc_time = H5D_ALLOC_TIME_EARLY; + /* + * Check if this dataset is going into a parallel file and set space allocation time. + * If the dataset has filters applied to it, writes to the dataset must be collective, + * so we don't need to force early space allocation. Otherwise, we force early space + * allocation to facilitate independent raw data operations. + */ + if (H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI) && (new_dset->shared->dcpl_cache.pline.nused == 0)) + new_dset->shared->dcpl_cache.fill.alloc_time = H5D_ALLOC_TIME_EARLY; + /* Set the dataset's I/O operations */ if (H5D__layout_set_io_ops(new_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize I/O operations") @@ -1459,13 +1445,13 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t H5D_t * H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id) { - H5D_t * dset = NULL; + H5D_t *dset = NULL; H5G_loc_t dset_loc; /* Object location of dataset */ H5G_name_t path; /* Dataset group hier. path */ H5O_loc_t oloc; /* Dataset object location */ H5O_type_t obj_type; /* Type of object at location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ - H5D_t * ret_value = NULL; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1519,10 +1505,10 @@ H5D_t * H5D_open(const H5G_loc_t *loc, hid_t dapl_id) { H5D_shared_t *shared_fo = NULL; - H5D_t * dataset = NULL; - char * extfile_prefix = NULL; /* Expanded external file prefix */ - char * vds_prefix = NULL; /* Expanded vds prefix */ - H5D_t * ret_value = NULL; /* Return value */ + H5D_t *dataset = NULL; + char *extfile_prefix = NULL; /* Expanded external file prefix */ + char *vds_prefix = NULL; /* Expanded vds prefix */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1729,12 +1715,13 @@ H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id) static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id) { - H5P_genplist_t *plist; /* Property list */ - H5O_fill_t * fill_prop; /* Pointer to dataset's fill value info */ - unsigned alloc_time_state; /* Allocation time state */ - htri_t msg_exists; /* Whether a particular type of message exists */ - hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list */ + H5O_fill_t *fill_prop; /* Pointer to dataset's fill value info */ + unsigned alloc_time_state; /* Allocation time state */ + htri_t msg_exists; /* Whether a particular type of message exists */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + hbool_t must_init_storage = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dataset->oloc.addr) @@ -1778,6 +1765,33 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) /* Indicate that the layout information was initialized */ layout_init = TRUE; + /* + * Now that we've read the dataset's datatype, dataspace and + * layout information, perform a quick check for compact datasets + * to ensure that the size of the internal buffer that was + * allocated for the dataset's raw data matches the size of + * the data. A corrupted file can cause a mismatch between the + * two, which might result in buffer overflows during future + * I/O to the dataset. + */ + if (H5D_COMPACT == dataset->shared->layout.type) { + hssize_t dset_nelemts = 0; + size_t dset_type_size = H5T_GET_SIZE(dataset->shared->type); + size_t dset_data_size = 0; + + HDassert(H5D_COMPACT == dataset->shared->layout.storage.type); + + if ((dset_nelemts = H5S_GET_EXTENT_NPOINTS(dataset->shared->space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get number of elements in dataset's dataspace") + + dset_data_size = (size_t)dset_nelemts * dset_type_size; + + if (dataset->shared->layout.storage.u.compact.size != dset_data_size) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, + "bad value from dataset header - size of compact dataset's data buffer doesn't match " + "size of dataset data"); + } + /* Set up flush append property */ if (H5D__append_flush_setup(dataset, dapl_id)) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set up flush append property") @@ -1849,17 +1863,30 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id) * Make sure all storage is properly initialized. * This is important only for parallel I/O where the space must * be fully allocated before I/O can happen. + * + * Storage will be initialized here if either the VFD being used + * has set the H5FD_FEAT_ALLOCATE_EARLY flag to indicate that it + * wishes to force early space allocation OR a parallel VFD is + * being used and the dataset in question doesn't have any filters + * applied to it. If filters are applied to the dataset, collective + * I/O will be required when writing to the dataset, so we don't + * need to initialize storage here, as the collective I/O process + * will coordinate that. */ - if ((H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR) && - !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) && - H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_ALLOCATE_EARLY)) { + must_init_storage = (H5F_INTENT(dataset->oloc.file) & H5F_ACC_RDWR) && + !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage); + must_init_storage = must_init_storage && (H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_ALLOCATE_EARLY) || + (H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI) && + dataset->shared->dcpl_cache.pline.nused == 0)); + + if (must_init_storage) { H5D_io_info_t io_info; io_info.dset = dataset; if (H5D__alloc_storage(&io_info, H5D_ALLOC_OPEN, FALSE, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file storage") - } /* end if */ + } done: if (ret_value < 0) { @@ -2077,7 +2104,7 @@ H5D_close(H5D_t *dataset) else /* Free object location (i.e. "unhold" the file if appropriate) */ if (H5O_loc_free(&(dataset->oloc)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "problem attempting to free location") + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "problem attempting to free location") } /* end else */ /* Release the dataset's path info */ @@ -2251,7 +2278,7 @@ H5D_oloc(H5D_t *dataset) *------------------------------------------------------------------------- */ H5G_name_t * -H5D_nameof(const H5D_t *dataset) +H5D_nameof(H5D_t *dataset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2271,8 +2298,8 @@ herr_t H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, hbool_t full_overwrite, hsize_t old_dim[]) { - const H5D_t * dset = io_info->dset; /* The dataset object */ - H5F_t * f = dset->oloc.file; /* The dataset's file pointer */ + const H5D_t *dset = io_info->dset; /* The dataset object */ + H5F_t *f = dset->oloc.file; /* The dataset's file pointer */ H5O_layout_t *layout; /* The dataset's layout information */ hbool_t must_init_space = FALSE; /* Flag to indicate that space should be initialized */ hbool_t addr_set = FALSE; /* Flag to indicate that the dataset's storage address was set */ @@ -2622,7 +2649,7 @@ static void * H5D__vlen_get_buf_size_alloc(size_t size, void *info) { H5D_vlen_bufsize_common_t *vlen_bufsize_com = (H5D_vlen_bufsize_common_t *)info; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -2708,11 +2735,11 @@ herr_t H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, hsize_t *size) { H5D_vlen_bufsize_native_t vlen_bufsize = {NULL, NULL, NULL, {NULL, NULL, 0, 0}}; - H5S_t * fspace = NULL; /* Dataset's dataspace */ - H5S_t * mspace = NULL; /* Memory dataspace */ + H5S_t *fspace = NULL; /* Dataset's dataspace */ + H5S_t *mspace = NULL; /* Memory dataspace */ char bogus; /* bogus value to pass to H5Diterate() */ - H5S_t * space; /* Dataspace for iteration */ - H5T_t * type; /* Datatype */ + H5S_t *space; /* Dataspace for iteration */ + H5T_t *type; /* Datatype */ H5S_sel_iter_op_t dset_op; /* Operator for iteration */ herr_t ret_value = FAIL; /* Return value */ @@ -2803,7 +2830,7 @@ H5D__vlen_get_buf_size_gen_cb(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned const hsize_t *point, void *op_data) { H5D_vlen_bufsize_generic_t *vlen_bufsize = (H5D_vlen_bufsize_generic_t *)op_data; - H5T_t * dt; /* Datatype for operation */ + H5T_t *dt; /* Datatype for operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2853,11 +2880,11 @@ H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id { H5D_vlen_bufsize_generic_t vlen_bufsize = { NULL, H5I_INVALID_HID, NULL, H5I_INVALID_HID, H5I_INVALID_HID, {NULL, NULL, 0, 0}}; - H5P_genplist_t * dxpl = NULL; /* DXPL for operation */ - H5S_t * mspace = NULL; /* Memory dataspace */ + H5P_genplist_t *dxpl = NULL; /* DXPL for operation */ + H5S_t *mspace = NULL; /* Memory dataspace */ char bogus; /* Bogus value to pass to H5Diterate() */ - H5S_t * space; /* Dataspace for iteration */ - H5T_t * type; /* Datatype */ + H5S_t *space; /* Dataspace for iteration */ + H5T_t *type; /* Datatype */ H5S_sel_iter_op_t dset_op; /* Operator for iteration */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3159,7 +3186,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size) } /*------------------------------------------------------------------------- * Remove chunk information in the case of chunked datasets - * This removal takes place only in case we are shrinking the dateset + * This removal takes place only in case we are shrinking the dataset * and if the chunks are written *------------------------------------------------------------------------- */ @@ -3304,7 +3331,7 @@ H5D__format_convert(H5D_t *dataset) { H5D_chk_idx_info_t new_idx_info; /* Index info for the new layout */ H5D_chk_idx_info_t idx_info; /* Index info for the current layout */ - H5O_layout_t * newlayout = NULL; /* The new layout */ + H5O_layout_t *newlayout = NULL; /* The new layout */ hbool_t init_new_index = FALSE; /* Indicate that the new chunk index is initialized */ hbool_t delete_old_layout = FALSE; /* Indicate that the old layout message is deleted */ hbool_t add_new_layout = FALSE; /* Indicate that the new layout message is added */ @@ -3755,11 +3782,13 @@ H5D_get_create_plist(const H5D_t *dset) hid_t H5D_get_access_plist(const H5D_t *dset) { - H5P_genplist_t * old_plist; /* Stored DAPL from dset */ - H5P_genplist_t * new_plist; /* New DAPL */ - H5P_genplist_t * def_fapl; /* Default FAPL */ - H5D_append_flush_t def_append_flush_info = {0}; /* Default append flush property */ - H5D_rdcc_t def_chunk_info; /* Default chunk cache property */ + H5P_genplist_t *old_plist; /* Stored DAPL from dset */ + H5P_genplist_t *new_plist; /* New DAPL */ + H5P_genplist_t *def_dapl = NULL; /* Default DAPL */ + H5D_append_flush_t def_append_flush_info = {0}; /* Default append flush property */ + H5D_rdcc_t def_chunk_info; /* Default chunk cache property */ + H5D_vds_view_t def_vds_view; /* Default virtual view property */ + hsize_t def_vds_gap; /* Default virtual printf gap property */ hid_t new_dapl_id = FAIL; hid_t ret_value = FAIL; @@ -3788,23 +3817,23 @@ H5D_get_access_plist(const H5D_t *dset) } else { /* Get the default FAPL */ - if (NULL == (def_fapl = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) + if (NULL == (def_dapl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_ACCESS_ID_g))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a property list") /* Set the data cache number of slots to the value of the default FAPL */ - if (H5P_get(def_fapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &def_chunk_info.nslots) < 0) + if (H5P_get(def_dapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &def_chunk_info.nslots) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data number of slots"); if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &def_chunk_info.nslots) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set data cache number of slots") /* Set the data cache byte size to the value of the default FAPL */ - if (H5P_get(def_fapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &def_chunk_info.nbytes_max) < 0) + if (H5P_get(def_dapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &def_chunk_info.nbytes_max) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data cache byte size"); if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &def_chunk_info.nbytes_max) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set data cache byte size") /* Set the preempt read chunks property to the value of the default FAPL */ - if (H5P_get(def_fapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &def_chunk_info.w0) < 0) + if (H5P_get(def_dapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &def_chunk_info.w0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get preempt read chunks"); if (H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &def_chunk_info.w0) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set preempt read chunks") @@ -3814,12 +3843,32 @@ H5D_get_access_plist(const H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set append flush property") } /* end if-else */ - /* Set the VDS view & printf gap options */ - if (H5P_set(new_plist, H5D_ACS_VDS_VIEW_NAME, &(dset->shared->layout.storage.u.virt.view)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VDS view") - if (H5P_set(new_plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &(dset->shared->layout.storage.u.virt.printf_gap)) < - 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VDS printf gap") + /* If the dataset is virtual then copy the VDS view & printf gap options. + * Otherwise, use the default values. */ + if (dset->shared->layout.type == H5D_VIRTUAL) { + if (H5P_set(new_plist, H5D_ACS_VDS_VIEW_NAME, &(dset->shared->layout.storage.u.virt.view)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VDS view") + if (H5P_set(new_plist, H5D_ACS_VDS_PRINTF_GAP_NAME, + &(dset->shared->layout.storage.u.virt.printf_gap)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VDS printf gap") + } + else { + /* Get the default FAPL if necessary */ + if (!def_dapl && NULL == (def_dapl = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_ACCESS_ID_g))) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a property list") + + /* Set the data cache number of slots to the value of the default FAPL */ + if (H5P_get(def_dapl, H5D_ACS_VDS_VIEW_NAME, &def_vds_view) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS view"); + if (H5P_set(new_plist, H5D_ACS_VDS_VIEW_NAME, &def_vds_view) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set VDS view") + + /* Set the data cache byte size to the value of the default FAPL */ + if (H5P_get(def_dapl, H5D_ACS_VDS_PRINTF_GAP_NAME, &def_vds_gap) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get VDS printf gap"); + if (H5P_set(new_plist, H5D_ACS_VDS_PRINTF_GAP_NAME, &def_vds_gap) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set VDS printf gap") + } /* Set the vds prefix option */ if (H5P_set(new_plist, H5D_ACS_VDS_PREFIX_NAME, &(dset->shared->vds_prefix)) < 0) @@ -3867,7 +3916,7 @@ H5D__get_space(const H5D_t *dset) if (NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") - /* Create an atom */ + /* Create an ID */ if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace") @@ -3914,7 +3963,7 @@ H5D__get_type(const H5D_t *dset) if (H5T_lock(dt, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to lock transient datatype") - /* Create an atom */ + /* Create an ID */ if (H5T_is_named(dt)) { /* If this is a committed datatype, we need to recreate the * two-level IDs, where the VOL object is a copy of the diff --git a/src/H5Dio.c b/src/H5Dio.c index 355aec18d49..2118c96b97b 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -361,14 +360,14 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of *------------------------------------------------------------------------- */ 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 */ H5D_type_info_t type_info; /* Datatype info for operation */ + H5D_layout_t layout_type; /* Dataset's layout type (contig, chunked, compact, etc.) */ hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */ - H5S_t * projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ + H5S_t *projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ /* projection of the supplied mem_space to a new */ /* dataspace with rank equal to that of */ /* file_space. */ @@ -398,6 +397,8 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t mem_space = file_space; nelmts = H5S_GET_SELECT_NPOINTS(mem_space); + layout_type = dataset->shared->layout.type; + /* Set up datatype info for operation */ if (H5D__typeinfo_init(dataset, mem_type_id, FALSE, &type_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up type info") @@ -448,7 +449,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t * difficulties with the notion. * * To solve this, we check to see if H5S_select_shape_same() returns true, - * and if the ranks of the mem and file spaces are different. If the are, + * and if the ranks of the mem and file spaces are different. If they are, * construct a new mem space that is equivalent to the old mem space, and * use that instead. * @@ -457,21 +458,21 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t */ if (TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { - const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ - /* to the beginning of the projected mem space. */ + ptrdiff_t buf_adj = 0; /* Attempt to construct projected dataspace for memory dataspace */ if (H5S_select_construct_projection(mem_space, &projected_mem_space, - (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf, - type_info.dst_type_size) < 0) + (unsigned)H5S_GET_EXTENT_NDIMS(file_space), + type_info.dst_type_size, &buf_adj) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace") HDassert(projected_mem_space); - HDassert(adj_buf); + + /* Adjust the buffer by the given amount */ + buf = (void *)(((uint8_t *)buf) + buf_adj); /* Switch to using projected memory dataspace & adjusted buffer */ mem_space = projected_mem_space; - buf = (void *)adj_buf; /* Casting away 'const' OK -QAK */ - } /* end if */ + } /* end if */ /* Retrieve dataset properties */ /* */ @@ -522,11 +523,13 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t HDassert((*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage) || (dataset->shared->layout.ops->is_data_cached && (*dataset->shared->layout.ops->is_data_cached)(dataset->shared)) || - dataset->shared->dcpl_cache.efl.nused > 0 || dataset->shared->layout.type == H5D_COMPACT); + dataset->shared->dcpl_cache.efl.nused > 0 || layout_type == H5D_COMPACT); /* Allocate the chunk map */ - if (NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk map") + if (H5D_CONTIGUOUS != layout_type && H5D_COMPACT != layout_type) { + if (NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk map") + } /* Call storage method's I/O initialization routine */ if (io_info.layout_ops.io_init && @@ -577,14 +580,15 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *------------------------------------------------------------------------- */ 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 */ H5D_type_info_t type_info; /* Datatype info for operation */ + H5D_layout_t layout_type; /* Dataset's layout type (contig, chunked, compact, etc.) */ hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */ - H5S_t * projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ + hbool_t should_alloc_space = FALSE; /* Whether or not to initialize dataset's storage */ + H5S_t *projected_mem_space = NULL; /* If not NULL, ptr to dataspace containing a */ /* projection of the supplied mem_space to a new */ /* dataspace with rank equal to that of */ /* file_space. */ @@ -608,6 +612,8 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ /* check args */ HDassert(dataset && dataset->oloc.file); + layout_type = dataset->shared->layout.type; + /* All filters in the DCPL must have encoding enabled. */ if (!dataset->shared->checked_filters) { if (H5Z_can_apply(dataset->shared->dcpl_id, dataset->shared->type_id) < 0) @@ -695,20 +701,20 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ */ if (TRUE == H5S_SELECT_SHAPE_SAME(mem_space, file_space) && H5S_GET_EXTENT_NDIMS(mem_space) != H5S_GET_EXTENT_NDIMS(file_space)) { - const void *adj_buf = NULL; /* Pointer to the location in buf corresponding */ - /* to the beginning of the projected mem space. */ + ptrdiff_t buf_adj = 0; /* Attempt to construct projected dataspace for memory dataspace */ if (H5S_select_construct_projection(mem_space, &projected_mem_space, - (unsigned)H5S_GET_EXTENT_NDIMS(file_space), buf, &adj_buf, - type_info.src_type_size) < 0) + (unsigned)H5S_GET_EXTENT_NDIMS(file_space), + type_info.src_type_size, &buf_adj) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to construct projected memory dataspace") HDassert(projected_mem_space); - HDassert(adj_buf); + + /* Adjust the buffer by the given amount */ + buf = (const void *)(((const uint8_t *)buf) + buf_adj); /* Switch to using projected memory dataspace & adjusted buffer */ mem_space = projected_mem_space; - buf = adj_buf; } /* end if */ /* Retrieve dataset properties */ @@ -721,8 +727,20 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set up I/O operation") /* Allocate dataspace and initialize it if it hasn't been. */ - if (nelmts > 0 && dataset->shared->dcpl_cache.efl.nused == 0 && - !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage)) { + should_alloc_space = dataset->shared->dcpl_cache.efl.nused == 0 && + !(*dataset->shared->layout.ops->is_space_alloc)(&dataset->shared->layout.storage); + + /* + * If not using an MPI-based VFD, we only need to allocate + * and initialize storage if there's a selection in the + * dataset's dataspace. Otherwise, we always need to participate + * in the storage allocation since this may use collective + * operations and we will hang if we don't participate. + */ + if (!H5F_HAS_FEATURE(dataset->oloc.file, H5FD_FEAT_HAS_MPI)) + should_alloc_space = should_alloc_space && (nelmts > 0); + + if (should_alloc_space) { hssize_t file_nelmts; /* Number of elements in file dataset's dataspace */ hbool_t full_overwrite; /* Whether we are over-writing all the elements */ @@ -742,8 +760,10 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_ } /* end if */ /* Allocate the chunk map */ - if (NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk map") + if (H5D_CONTIGUOUS != layout_type && H5D_COMPACT != layout_type) { + if (NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk map") + } /* Call storage method's I/O initialization routine */ if (io_info.layout_ops.io_init && @@ -876,8 +896,8 @@ H5D__ioinfo_init(H5D_t *dset, const H5D_type_info_t *type_info, H5D_storage_t *s static herr_t H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, H5D_type_info_t *type_info) { - const H5T_t * src_type; /* Source datatype */ - const H5T_t * dst_type; /* Destination datatype */ + const H5T_t *src_type; /* Source datatype */ + const H5T_t *dst_type; /* Destination datatype */ H5Z_data_xform_t *data_transform; /* Data transform info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -937,8 +957,8 @@ H5D__typeinfo_init(const H5D_t *dset, hid_t mem_type_id, hbool_t do_write, H5D_t type_info->need_bkg = H5T_BKG_NO; } /* end if */ else { - void * tconv_buf; /* Temporary conversion buffer pointer */ - void * bkgr_buf; /* Background conversion buffer pointer */ + void *tconv_buf; /* Temporary conversion buffer pointer */ + void *bkgr_buf; /* Background conversion buffer pointer */ size_t max_temp_buf; /* Maximum temporary buffer size */ H5T_bkg_t bkgr_buf_type; /* Background buffer type */ size_t target_size; /* Desired buffer size */ @@ -1098,77 +1118,34 @@ H5D__ioinfo_adjust(H5D_io_info_t *io_info, const H5D_t *dset, const H5S_t *file_ } /* end if */ else { /* Check if there are any filters in the pipeline. If there are, - * we cannot break to independent I/O if this is a write operation; - * otherwise there will be metadata inconsistencies in the file. + * we cannot break to independent I/O if this is a write operation + * with multiple ranks involved; otherwise, there will be metadata + * inconsistencies in the file. */ if (io_info->op_type == H5D_IO_OP_WRITE && io_info->dset->shared->dcpl_cache.pline.nused > 0) { - H5D_mpio_no_collective_cause_t cause; - uint32_t local_no_collective_cause; - uint32_t global_no_collective_cause; - hbool_t local_error_message_previously_written = FALSE; - hbool_t global_error_message_previously_written = FALSE; - size_t idx; - size_t cause_strings_len; - char local_no_collective_cause_string[512] = ""; - char global_no_collective_cause_string[512] = ""; - const char * cause_strings[] = { - "independent I/O was requested", - "datatype conversions were required", - "data transforms needed to be applied", - "optimized MPI types flag wasn't set", - "one of the dataspaces was neither simple nor scalar", - "dataset was not contiguous or chunked", - "parallel writes to filtered datasets are disabled", - "an error occurred while checking if collective I/O was possible"}; - - cause_strings_len = sizeof(cause_strings) / sizeof(cause_strings[0]); - - if (H5CX_get_mpio_local_no_coll_cause(&local_no_collective_cause) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, - "unable to get local no collective cause value") - if (H5CX_get_mpio_global_no_coll_cause(&global_no_collective_cause) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, - "unable to get global no collective cause value") - - /* Append each of the "reason for breaking collective I/O" error messages to the - * local and global no collective cause strings */ - for (cause = 1, idx = 0; - (cause < H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE) && (idx < cause_strings_len); - cause <<= 1, idx++) { - size_t cause_strlen = HDstrlen(cause_strings[idx]); - - if (cause & local_no_collective_cause) { - /* Check if there were any previous error messages included. If so, prepend a - * semicolon to separate the messages. - */ - if (local_error_message_previously_written) - HDstrncat(local_no_collective_cause_string, "; ", 2); - - HDstrncat(local_no_collective_cause_string, cause_strings[idx], cause_strlen); - - local_error_message_previously_written = TRUE; - } /* end if */ - - if (cause & global_no_collective_cause) { - /* Check if there were any previous error messages included. If so, prepend a - * semicolon to separate the messages. - */ - if (global_error_message_previously_written) - HDstrncat(global_no_collective_cause_string, "; ", 2); - - HDstrncat(global_no_collective_cause_string, cause_strings[idx], cause_strlen); - - global_error_message_previously_written = TRUE; - } /* end if */ - } /* end for */ - - HGOTO_ERROR(H5E_IO, H5E_NO_INDEPENDENT, FAIL, - "Can't perform independent write with filters in pipeline.\n" - " The following caused a break from collective I/O:\n" - " Local causes: %s\n" - " Global causes: %s", - local_no_collective_cause_string, global_no_collective_cause_string); - } /* end if */ + int comm_size = 0; + + /* Retrieve size of MPI communicator used for file */ + if ((comm_size = H5F_shared_mpi_get_size(io_info->f_sh)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MPI communicator size") + + if (comm_size > 1) { + char local_no_coll_cause_string[512]; + char global_no_coll_cause_string[512]; + + if (H5D__mpio_get_no_coll_cause_strings(local_no_coll_cause_string, 512, + global_no_coll_cause_string, 512) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't get reasons for breaking collective I/O") + + HGOTO_ERROR(H5E_IO, H5E_NO_INDEPENDENT, FAIL, + "Can't perform independent write with filters in pipeline.\n" + " The following caused a break from collective I/O:\n" + " Local causes: %s\n" + " Global causes: %s", + local_no_coll_cause_string, global_no_coll_cause_string); + } + } /* If we won't be doing collective I/O, but the user asked for * collective I/O, change the request to use independent I/O diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index c02b89eb018..019ead1e7cd 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -212,7 +211,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ ret_value++; /* Dimension sizes */ - ret_value += layout->u.chunk.ndims * layout->u.chunk.enc_bytes_per_dim; + ret_value += layout->u.chunk.ndims * (size_t)layout->u.chunk.enc_bytes_per_dim; /* Type of chunk index */ ret_value++; @@ -450,7 +449,7 @@ H5D__layout_set_latest_indexing(H5O_layout_t *layout, const H5S_t *space, const herr_t H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) { - H5O_layout_t * layout; /* Dataset's layout information */ + H5O_layout_t *layout; /* Dataset's layout information */ const H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ unsigned layout_mesg_flags; /* Flags for inserting layout message */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ @@ -500,7 +499,7 @@ H5D__layout_oh_create(H5F_t *file, H5O_t *oh, H5D_t *dset, hid_t dapl_id) /* Update external storage message, if it's used */ if (dset->shared->dcpl_cache.efl.nused > 0) { H5O_efl_t *efl = &dset->shared->dcpl_cache.efl; /* Dataset's external file list */ - H5HL_t * heap; /* Pointer to local heap for EFL file names */ + H5HL_t *heap; /* Pointer to local heap for EFL file names */ size_t heap_size = H5HL_ALIGN(1); size_t u; size_t name_offset; @@ -592,7 +591,9 @@ herr_t H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) { htri_t msg_exists; /* Whether a particular type of message exists */ + hbool_t pline_copied = FALSE; /* Flag to indicate that dcpl_cache.pline's message was copied */ hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ + hbool_t efl_copied = FALSE; /* Flag to indicate that the EFL message was copied */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -608,6 +609,7 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) /* Retrieve the I/O pipeline message */ if (NULL == H5O_msg_read(&(dataset->oloc), H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") + pline_copied = TRUE; /* Set the I/O pipeline info in the property list */ if (H5P_set(plist, H5O_CRT_PIPELINE_NAME, &dataset->shared->dcpl_cache.pline) < 0) @@ -628,9 +630,10 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) if ((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_EFL_ID)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") if (msg_exists) { - /* Retrieve the EFL message */ + /* Retrieve the EFL message */ if (NULL == H5O_msg_read(&(dataset->oloc), H5O_EFL_ID, &dataset->shared->dcpl_cache.efl)) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") + efl_copied = TRUE; /* Set the EFL info in the property list */ if (H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->dcpl_cache.efl) < 0) @@ -662,10 +665,17 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dapl_id, H5P_genplist_t *plist) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to set chunk sizes") done: - if (ret_value < 0 && layout_copied) - if (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info") - + if (ret_value < 0) { + if (pline_copied) + if (H5O_msg_reset(H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset pipeline info") + if (layout_copied) + if (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info") + if (efl_copied) + if (H5O_msg_reset(H5O_EFL_ID, &dataset->shared->dcpl_cache.efl) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset efl message") + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__layout_oh_read() */ diff --git a/src/H5Dmodule.h b/src/H5Dmodule.h index 595c7146fd0..8d2f23a142b 100644 --- a/src/H5Dmodule.h +++ b/src/H5Dmodule.h @@ -29,7 +29,2666 @@ #define H5_MY_PKG_ERR H5E_DATASET #define H5_MY_PKG_INIT YES -/**\defgroup H5D H5D +/** \page H5D_UG HDF5 Datasets + * + * \section sec_dataset HDF5 Datasets + * + * \subsection subsec_dataset_intro Introduction + * + * An HDF5 dataset is an object composed of a collection of data elements, or raw data, and + * metadata that stores a description of the data elements, data layout, and all other information + * necessary to write, read, and interpret the stored data. From the viewpoint of the application the + * raw data is stored as a one-dimensional or multi-dimensional array of elements (the raw data), + * those elements can be any of several numerical or character types, small arrays, or even + * compound types similar to C structs. The dataset object may have attribute objects. See the + * figure below. + * + * + * + * + * + *
+ * \image html Dsets_fig1.gif "Application view of a dataset" + *
+ * + * A dataset object is stored in a file in two parts: a header and a data array. The header contains + * information that is needed to interpret the array portion of the dataset, as well as metadata (or + * pointers to metadata) that describes or annotates the dataset. Header information includes the + * name of the object, its dimensionality, its number-type, information about how the data itself is + * stored on disk (the storage layout), and other information used by the library to speed up access + * to the dataset or maintain the file’s integrity. + * + * The HDF5 dataset interface, comprising the @ref H5D functions, provides a mechanism for managing + * HDF5 datasets including the transfer of data between memory and disk and the description of + * dataset properties. + * + * A dataset is used by other HDF5 APIs, either by name or by an identifier. For more information, + * \see \ref api-compat-macros. + * + * \subsubsection subsubsec_dataset_intro_link Link/Unlink + * A dataset can be added to a group with one of the H5Lcreate calls, and deleted from a group with + * #H5Ldelete. The link and unlink operations use the name of an object, which may be a dataset. + * The dataset does not have to open to be linked or unlinked. + * + * \subsubsection subsubsec_dataset_intro_obj Object Reference + * A dataset may be the target of an object reference. The object reference is created by + * #H5Rcreate with the name of an object which may be a dataset and the reference type + * #H5R_OBJECT. The dataset does not have to be open to create a reference to it. + * + * An object reference may also refer to a region (selection) of a dataset. The reference is created + * with #H5Rcreate and a reference type of #H5R_DATASET_REGION. + * + * An object reference can be accessed by a call to #H5Rdereference. When the reference is to a + * dataset or dataset region, the #H5Rdereference call returns an identifier to the dataset just as if + * #H5Dopen has been called. + * + * \subsubsection subsubsec_dataset_intro_attr Adding Attributes + * A dataset may have user-defined attributes which are created with #H5Acreate and accessed + * through the @ref H5A API. To create an attribute for a dataset, the dataset must be open, and the + * identifier is passed to #H5Acreate. The attributes of a dataset are discovered and opened using + * #H5Aopen_name, #H5Aopen_idx, or #H5Aiterate; these functions use the identifier of the dataset. + * An attribute can be deleted with #H5Adelete which also uses the identifier of the dataset. + * + * \subsection subsec_dataset_function Dataset Function Summaries + * Functions that can be used with datasets (@ref H5D functions) and property list functions that can + * used with datasets (@ref H5P functions) are listed below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Dataset functions
FunctionPurpose
#H5DcreateCreates a dataset at the specified location. The + * C function is a macro: \see \ref api-compat-macros.
#H5Dcreate_anonCreates a dataset in a file without linking it into the file structure.
#H5DopenOpens an existing dataset. The C function is a macro: \see \ref api-compat-macros.
#H5DcloseCloses the specified dataset.
#H5Dget_spaceReturns an identifier for a copy of the dataspace for a dataset.
#H5Dget_space_statusDetermines whether space has been allocated for a dataset.
#H5Dget_typeReturns an identifier for a copy of the datatype for a dataset.
#H5Dget_create_plistReturns an identifier for a copy of the dataset creation property list for a dataset.
#H5Dget_access_plistReturns the dataset access property list associated with a dataset.
#H5Dget_offsetReturns the dataset address in a file.
#H5Dget_storage_sizeReturns the amount of storage required for a dataset.
#H5Dvlen_get_buf_sizeDetermines the number of bytes required to store variable-length (VL) data.
#H5Dvlen_reclaimReclaims VL datatype memory buffers.
#H5DreadReads raw data from a dataset into a buffer.
#H5DwriteWrites raw data from a buffer to a dataset.
#H5DiterateIterates over all selected elements in a dataspace.
#H5DgatherGathers data from a selection within a memory buffer.
#H5DscatterScatters data into a selection within a memory buffer.
#H5DfillFills dataspace elements with a fill value in a memory buffer.
#H5Dset_extentChanges the sizes of a dataset’s dimensions.
+ * + * \anchor dcpl_table_tag Dataset creation property list functions (H5P) + * \snippet{doc} tables/propertyLists.dox dcpl_table + * + * \anchor dapl_table_tag Dataset access property list functions (H5P) + * \snippet{doc} tables/propertyLists.dox dapl_table + * + * \subsection subsec_dataset_program Programming Model for Datasets + * This section explains the programming model for datasets. + * + * \subsubsection subsubsec_dataset_program_general General Model + * + * The programming model for using a dataset has three main phases: + * \li Obtain access to the dataset + * \li Operate on the dataset using the dataset identifier returned at access + * \li Release the dataset + * + * These three phases or steps are described in more detail below the figure. + * + * A dataset may be opened several times and operations performed with several different + * identifiers to the same dataset. All the operations affect the dataset although the calling program + * must synchronize if necessary to serialize accesses. + * + * Note that the dataset remains open until every identifier is closed. The figure below shows the + * basic sequence of operations. + * + * + * + * + * + *
+ * \image html Dsets_fig2.gif "Dataset programming sequence" + *
+ * + * Creation and data access operations may have optional parameters which are set with property + * lists. The general programming model is: + * \li Create property list of appropriate class (dataset create, dataset transfer) + * \li Set properties as needed; each type of property has its own format and datatype + * \li Pass the property list as a parameter of the API call + * + * The steps below describe the programming phases or steps for using a dataset. + *

Step 1. Obtain Access

+ * A new dataset is created by a call to #H5Dcreate. If successful, the call returns an identifier for the + * newly created dataset. + * + * Access to an existing dataset is obtained by a call to #H5Dopen. This call returns an identifier for + * the existing dataset. + * + * An object reference may be dereferenced to obtain an identifier to the dataset it points to. + * + * In each of these cases, the successful call returns an identifier to the dataset. The identifier is + * used in subsequent operations until the dataset is closed. + * + *

Step 2. Operate on the Dataset

+ * The dataset identifier can be used to write and read data to the dataset, to query and set + * properties, and to perform other operations such as adding attributes, linking in groups, and + * creating references. + * + * The dataset identifier can be used for any number of operations until the dataset is closed. + * + *

Step 3. Close the Dataset

+ * When all operations are completed, the dataset identifier should be closed with a call to + * #H5Dclose. This releases the dataset. + * + * After the identifier is closed, it cannot be used for further operations. + * + * \subsubsection subsubsec_dataset_program_create Create Dataset + * + * A dataset is created and initialized with a call to #H5Dcreate. The dataset create operation sets + * permanent properties of the dataset: + * \li Name + * \li Dataspace + * \li Datatype + * \li Storage properties + * + * These properties cannot be changed for the life of the dataset, although the dataspace may be + * expanded up to its maximum dimensions. + * + *

Name

+ * A dataset name is a sequence of alphanumeric ASCII characters. The full name would include a + * tracing of the group hierarchy from the root group of the file. An example is + * /rootGroup/groupA/subgroup23/dataset1. The local name or relative name within the lowest- + * level group containing the dataset would include none of the group hierarchy. An example is + * Dataset1. + * + *

Dataspace

+ * The dataspace of a dataset defines the number of dimensions and the size of each dimension. The + * dataspace defines the number of dimensions, and the maximum dimension sizes and current size + * of each dimension. The maximum dimension size can be a fixed value or the constant + * #H5S_UNLIMITED, in which case the actual dimension size can be changed with calls to + * #H5Dset_extent, up to the maximum set with the maxdims parameter in the #H5Screate_simple + * call that established the dataset’s original dimensions. The maximum dimension size is set when + * the dataset is created and cannot be changed. + * + *

Datatype

+ * Raw data has a datatype which describes the layout of the raw data stored in the file. The + * datatype is set when the dataset is created and can never be changed. When data is transferred to + * and from the dataset, the HDF5 library will assure that the data is transformed to and from the + * stored format. + * + *

Storage Properties

+ * Storage properties of the dataset are set when it is created. The required inputs table below shows + * the categories of storage properties. The storage properties cannot be changed after the dataset is + * created. + * + *

Filters

+ * When a dataset is created, optional filters are specified. The filters are added to the data transfer + * pipeline when data is read or written. The standard library includes filters to implement + * compression, data shuffling, and error detection code. Additional user-defined filters may also be + * used. + * + * The required filters are stored as part of the dataset, and the list may not be changed after the + * dataset is created. The HDF5 library automatically applies the filters whenever data is + * transferred. + * + *

Summary

+ * + * A newly created dataset has no attributes and no data values. The dimensions, datatype, storage + * properties, and selected filters are set. The table below lists the required inputs, and the second + * table below lists the optional inputs. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Required inputs
Required InputsDescription
DataspaceThe shape of the array.
DatatypeThe layout of the stored elements.
NameThe name of the dataset in the group.
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Optional inputs
Optional InputsDescription
Storage LayoutHow the data is organized in the file including chunking.
Fill ValueThe behavior and value for uninitialized data.
External StorageOption to store the raw data in an external file.
FiltersSelect optional filters to be applied. One of the filters that might be applied is compression.
+ * + *

Example

+ * To create a new dataset, go through the following general steps: + * \li Set dataset characteristics (optional where default settings are acceptable) + * \li Datatype + * \li Dataspace + * \li Dataset creation property list + * \li Create the dataset + * \li Close the datatype, dataspace, and property list (as necessary) + * \li Close the dataset + * + * Example 1 below shows example code to create an empty dataset. The dataspace is 7 x 8, and the + * datatype is a big-endian integer. The dataset is created with the name “dset1†and is a member of + * the root group, “/â€. + * + * Example 1. Create an empty dataset + * \code + * hid_t dataset, datatype, dataspace; + * + * // Create dataspace: Describe the size of the array and create the dataspace for fixed-size dataset. + * dimsf[0] = 7; + * dimsf[1] = 8; + * dataspace = H5Screate_simple(2, dimsf, NULL); + * + * // Define datatype for the data in the file. + * // For this example, store little-endian integer numbers. + * datatype = H5Tcopy(H5T_NATIVE_INT); + * status = H5Tset_order(datatype, H5T_ORDER_LE); + * + * // Create a new dataset within the file using defined + * // dataspace and datatype. No properties are set. + * dataset = H5Dcreate(file, "/dset", datatype, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * H5Dclose(dataset); + * H5Sclose(dataspace); + * H5Tclose(datatype); + * \endcode + * + * Example 2, below, shows example code to create a similar dataset with a fill value of ‘-1’. This + * code has the same steps as in the example above, but uses a non-default property list. A file + * creation property list is created, and then the fill value is set to the desired value. Then the + * property list is passed to the #H5Dcreate call. + * + * Example 2. Create a dataset with fill value set + * \code + * hid_t plist; // property list + * hid_t dataset, datatype, dataspace; + * int fillval = -1; + * + * dimsf[0] = 7; + * dimsf[1] = 8; + * dataspace = H5Screate_simple(2, dimsf, NULL); + * datatype = H5Tcopy(H5T_NATIVE_INT); + * status = H5Tset_order(datatype, H5T_ORDER_LE); + * + * // Example of Dataset Creation property list: set fill value to '-1' + * plist = H5Pcreate(H5P_DATASET_CREATE); + * status = H5Pset_fill_value(plist, datatype, &fillval); + * + * // Same as above, but use the property list + * dataset = H5Dcreate(file, "/dset", datatype, dataspace, H5P_DEFAULT, plist, H5P_DEFAULT); + * H5Dclose(dataset); + * H5Sclose(dataspace); + * H5Tclose(datatype); + * H5Pclose(plist); + * \endcode + * + * After this code is executed, the dataset has been created and written to the file. The data array is + * uninitialized. Depending on the storage strategy and fill value options that have been selected, + * some or all of the space may be allocated in the file, and fill values may be written in the file. + * + * \subsubsection subsubsec_dataset_program_transfer Data Transfer Operations on a Dataset + * Data is transferred between memory and the raw data array of the dataset through #H5Dwrite and + * #H5Dread operations. A data transfer has the following basic steps: + * \li 1. Allocate and initialize memory space as needed + * \li 2. Define the datatype of the memory elements + * \li 3. Define the elements to be transferred (a selection, or all the elements) + * \li 4. Set data transfer properties (including parameters for filters or file drivers) as needed + * \li 5. Call the @ref H5D API + * + * Note that the location of the data in the file, the datatype of the data in the file, the storage + * properties, and the filters do not need to be specified because these are stored as a permanent part + * of the dataset. A selection of elements from the dataspace is specified; the selected elements may + * be the whole dataspace. + * + * The following figure shows a diagram of a write operation which + * transfers a data array from memory to a dataset in the file (usually on disk). A read operation has + * similar parameters with the data flowing the other direction. + * + * + * + * + * + *
+ * \image html Dsets_fig3.gif "A write operation" + *
+ * + *

Memory Space

+ * The calling program must allocate sufficient memory to store the data elements to be transferred. + * For a write (from memory to the file), the memory must be initialized with the data to be written + * to the file. For a read, the memory must be large enough to store the elements that will be read. + * The amount of storage needed can be computed from the memory datatype (which defines the + * size of each data element) and the number of elements in the selection. + * + *

Memory Datatype

+ * The memory layout of a single data element is specified by the memory datatype. This specifies + * the size, alignment, and byte order of the element as well as the datatype class. Note that the + * memory datatype must be the same datatype class as the file, but may have different byte order + * and other properties. The HDF5 Library automatically transforms data elements between the + * source and destination layouts. For more information, \ref sec_datatype. + * + * For a write, the memory datatype defines the layout of the data to be written; an example is IEEE + * floating-point numbers in native byte order. If the file datatype (defined when the dataset is + * created) is different but compatible, the HDF5 Library will transform each data element when it + * is written. For example, if the file byte order is different than the native byte order, the HDF5 + * library will swap the bytes. + * + * For a read, the memory datatype defines the desired layout of the data to be read. This must be + * compatible with the file datatype, but should generally use native formats such as byte orders. + * The HDF5 library will transform each data element as it is read. + * + *

Selection

+ * The data transfer will transfer some or all of the elements of the dataset depending on the + * dataspace selection. The selection has two dataspace objects: one for the source, and one for the + * destination. These objects describe which elements of the dataspace to be transferred. Some + * (partial I/O) or all of the data may be transferred. Partial I/O is defined by defining hyperslabs or + * lists of elements in a dataspace object. + * + * The dataspace selection for the source defines the indices of the elements to be read or written. + * The two selections must define the same number of points, but the order and layout may be + * different. The HDF5 Library automatically selects and distributes the elements according to the + * selections. It might, for example, perform a scatter-gather or sub-set of the data. + * + *

Data Transfer Properties

+ * For some data transfers, additional parameters should be set using the transfer property list. The + * table below lists the categories of transfer properties. These properties set parameters for the + * HDF5 Library and may be used to pass parameters for optional filters and file drivers. For + * example, transfer properties are used to select independent or collective operation when using + * MPI-I/O. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Categories of transfer properties
PropertiesDescription
Library parametersInternal caches, buffers, B-Trees, etc.
Memory managementVariable-length memory management, data overwrite
File driver managementParameters for file drivers
Filter managementParameters for filters
+ * + *

Data Transfer Operation (Read or Write)

+ * The data transfer is done by calling #H5Dread or #H5Dwrite with the parameters described above. + * The HDF5 Library constructs the required pipeline, which will scatter-gather, transform + * datatypes, apply the requested filters, and use the correct file driver. + * + * During the data transfer, the transformations and filters are applied to each element of the data in + * the required order until all the data is transferred. + * + *

Summary

+ * To perform a data transfer, it is necessary to allocate and initialize memory, describe the source + * and destination, set required and optional transfer properties, and call the \ref H5D API. + * + *

Examples

+ * The basic procedure to write to a dataset is the following: + * \li Open the dataset. + * \li Set the dataset dataspace for the write (optional if dataspace is #H5S_ALL). + * \li Write data. + * \li Close the datatype, dataspace, and property list (as necessary). + * \li Close the dataset. + * + * Example 3 below shows example code to write a 4 x 6 array of integers. In the example, the data + * is initialized in the memory array dset_data. The dataset has already been created in the file, so it + * is opened with H5Dopen. + * + * The data is written with #H5Dwrite. The arguments are the dataset identifier, the memory + * datatype (#H5T_NATIVE_INT), the memory and file selections (#H5S_ALL in this case: the + * whole array), and the default (empty) property list. The last argument is the data to be + * transferred. + * + * Example 3. Write an array of integers + * \code + * hid_t file_id, dataset_id; // identifiers + * herr_t status; + * int i, j, dset_data[4][6]; + * + * // Initialize the dataset. + * for (i = 0; i < 4; i++) + * for (j = 0; j < 6; j++) + * dset_data[i][j] = i * 6 + j + 1; + * + * // Open an existing file. + * file_id = H5Fopen("dset.h5", H5F_ACC_RDWR, H5P_DEFAULT); + * + * // Open an existing dataset. + * dataset_id = H5Dopen(file_id, "/dset", H5P_DEFAULT); + * + * // Write the entire dataset, using 'dset_data': memory type is 'native int' + * // write the entire dataspace to the entire dataspace, no transfer properties + * status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data); + * + * status = H5Dclose(dataset_id); + * \endcode + * + * Example 4 below shows a similar write except for setting a non-default value for the transfer + * buffer. The code is the same as Example 3, but a transfer property list is created, and the desired + * buffer size is set. The #H5Dwrite function has the same arguments, but uses the property list to set + * the buffer. + * + * Example 4. Write an array using a property list + * \code + * hid_t file_id, dataset_id; + * hid_t xferplist; + * herr_t status; + * int i, j, dset_data[4][6]; + * + * file_id = H5Fopen("dset.h5", H5F_ACC_RDWR, H5P_DEFAULT); + * dataset_id = H5Dopen(file_id, "/dset", H5P_DEFAULT); + * + * // Example: set type conversion buffer to 64MB + * xferplist = H5Pcreate(H5P_DATASET_XFER); + * status = H5Pset_buffer( xferplist, 64 * 1024 *1024, NULL, NULL); + * + * // Write the entire dataset, using 'dset_data': memory type is 'native int' + * write the entire dataspace to the entire dataspace, set the buffer size with the property list + * status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xferplist, dset_data); + * + * status = H5Dclose(dataset_id); + * \endcode + * + * The basic procedure to read from a dataset is the following: + * \li Define the memory dataspace of the read (optional if dataspace is #H5S_ALL). + * \li Open the dataset. + * \li Get the dataset dataspace (if using #H5S_ALL above). + * + * Else define dataset dataspace of read. + * \li Define the memory datatype (optional). + * \li Define the memory buffer. + * \li Open the dataset. + * \li Read data. + * \li Close the datatype, dataspace, and property list (as necessary). + * \li Close the dataset. + * + * The example below shows code that reads a 4 x 6 array of integers from a dataset called “dset1â€. + * First, the dataset is opened. The #H5Dread call has parameters: + * \li The dataset identifier (from #H5Dopen) + * \li The memory datatype (#H5T_NATIVE_INT) + * \li The memory and file dataspace (#H5S_ALL, the whole array) + * \li A default (empty) property list + * \li The memory to be filled + * + * Example 5. Read an array from a dataset + * \code + * hid_t file_id, dataset_id; + * herr_t status; + * int i, j, dset_data[4][6]; + * + * // Open an existing file. + * file_id = H5Fopen("dset.h5", H5F_ACC_RDWR, H5P_DEFAULT); + * + * // Open an existing dataset. + * dataset_id = H5Dopen(file_id, "/dset", H5P_DEFAULT); + * + * // read the entire dataset, into 'dset_data': memory type is 'native int' + * // read the entire dataspace to the entire dataspace, no transfer properties, + * status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data); + * + * status = H5Dclose(dataset_id); + * \endcode + * + * \subsubsection subsubsec_dataset_program_read Retrieve the Properties of a Dataset + * The functions listed below allow the user to retrieve information regarding a dataset including + * the datatype, the dataspace, the dataset creation property list, and the total stored size of the data. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Retrieve dataset information
Query FunctionDescription
H5Dget_spaceRetrieve the dataspace of the dataset as stored in the file.
H5Dget_typeRetrieve the datatype of the dataset as stored in the file.
H5Dget_create_plistRetrieve the dataset creation properties.
H5Dget_storage_sizeRetrieve the total bytes for all the data of the dataset.
H5Dvlen_get_buf_sizeRetrieve the total bytes for all the variable-length data of the dataset.
+ * + * The example below illustrates how to retrieve dataset information. + * + * Example 6. Retrieve dataset + * \code + * hid_t file_id, dataset_id; + * hid_t dspace_id, dtype_id, plist_id; + * herr_t status; + * + * // Open an existing file. + * file_id = H5Fopen("dset.h5", H5F_ACC_RDWR, H5P_DEFAULT); + * + * // Open an existing dataset. + * dataset_id = H5Dopen(file_id, "/dset", H5P_DEFAULT); + * dspace_id = H5Dget_space(dataset_id); + * dtype_id = H5Dget_type(dataset_id); + * plist_id = H5Dget_create_plist(dataset_id); + * + * // use the objects to discover the properties of the dataset + * status = H5Dclose(dataset_id); + * \endcode + * + * \subsection subsec_dataset_transfer Data Transfer + * The HDF5 library implements data transfers through a pipeline which implements data + * transformations (according to the datatype and selections), chunking (as requested), and I/O + * operations using different mechanisms (file drivers). The pipeline is automatically configured by + * the HDF5 library. Metadata is stored in the file so that the correct pipeline can be constructed to + * retrieve the data. In addition, optional filters such as compression may be added to the standard + * pipeline. + * + * The figure below illustrates data layouts for different layers of an application using HDF5. The + * application data is organized as a multidimensional array of elements. The HDF5 format + * specification defines the stored layout of the data and metadata. The storage layout properties + * define the organization of the abstract data. This data is written to and read from some storage + * medium. + * + * + * + * + * + *
+ * \image html Dsets_fig4.gif "Data layouts in an application" + *
+ * + * The last stage of a write (and first stage of a read) is managed by an HDF5 file driver module. + * The virtual file layer of the HDF5 Library implements a standard interface to alternative I/O + * methods, including memory (AKA “coreâ€) files, single serial file I/O, multiple file I/O, and + * parallel I/O. The file driver maps a simple abstract HDF5 file to the specific access methods. + * + * The raw data of an HDF5 dataset is conceived to be a multidimensional array of data elements. + * This array may be stored in the file according to several storage strategies: + * \li Contiguous + * \li Chunked + * \li Compact + * + * The storage strategy does not affect data access methods except that certain operations may be + * more or less efficient depending on the storage strategy and the access patterns. + * + * Overall, the data transfer operations (#H5Dread and #H5Dwrite) work identically for any storage + * method, for any file driver, and for any filters and transformations. The HDF5 library + * automatically manages the data transfer process. In some cases, transfer properties should or + * must be used to pass additional parameters such as MPI/IO directives when using the parallel file + * driver. + * + * \subsubsection subsubsec_dataset_transfer_pipe The Data Pipeline + * When data is written or read to or from an HDF5 file, the HDF5 library passes the data through a + * sequence of processing steps which are known as the HDF5 data pipeline. This data pipeline + * performs operations on the data in memory such as byte swapping, alignment, scatter-gather, and + * hyperslab selections. The HDF5 library automatically determines which operations are needed + * and manages the organization of memory operations such as extracting selected elements from a + * data block. The data pipeline modules operate on data buffers: each module processes a buffer + * and passes the transformed buffer to the next stage. + * + * The table below lists the stages of the data pipeline. The figure below the table shows the order + * of processing during a read or write. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Stages of the data pipeline
LayersDescription
I/O initiationInitiation of HDF5 I/O activities (#H5Dwrite and #H5Dread) in a user’s application program.
Memory hyperslab operationData is scattered to (for read), or gathered from (for write) the application’s memory buffer + * (bypassed if no datatype conversion is needed).
Datatype conversionDatatype is converted if it is different between memory and storage (bypassed if no datatype + * conversion is needed).
File hyperslab operationData is gathered from (for read), or scattered to (for write) to file space in memory (bypassed + * if no datatype conversion is needed).
Filter pipelineData is processed by filters when it passes. Data can be modified and restored here (bypassed + * if no datatype conversion is needed, no filter is enabled, or dataset is not chunked).
Virtual File LayerFacilitate easy plug-in file drivers such as MPIO or POSIX I/O.
Actual I/OActual file driver used by the library such as MPIO or STDIO.
+ * + * + * + * + * + *
+ * \image html Dsets_fig5.gif "The processing order in the data pipeline" + *
+ * + * The HDF5 library automatically applies the stages as needed. + * + * When the memory dataspace selection is other than the whole dataspace, the memory hyperslab + * stage scatters/gathers the data elements between the application memory (described by the + * selection) and a contiguous memory buffer for the pipeline. On a write, this is a gather operation; + * on a read, this is a scatter operation. + * + * When the memory datatype is different from the file datatype, the datatype conversion stage + * transforms each data element. For example, if data is written from 32-bit big-endian memory, + * and the file datatype is 32-bit little-endian, the datatype conversion stage will swap the bytes of + * every element. Similarly, when data is read from the file to native memory, byte swapping will + * be applied automatically when needed. + * + * The file hyperslab stage is similar to the memory hyperslab stage, but is managing the + * arrangement of the elements according to the dataspace selection. When data is read, data + * elements are gathered from the data blocks from the file to fill the contiguous buffers which are + * then processed by the pipeline. When data is read, the elements from a buffer are scattered to the + * data blocks of the file. + * + * \subsubsection subsubsec_dataset_transfer_filter Data Pipeline Filters + * In addition to the standard pipeline, optional stages, called filters, can be inserted in the pipeline. + * The standard distribution includes optional filters to implement compression and error checking. + * User applications may add custom filters as well. + * + * The HDF5 library distribution includes or employs several optional filters. These are listed in the + * table below. The filters are applied in the pipeline between the virtual file layer and the file + * hyperslab operation. See the figure above. The application can use any number of filters in any + * order. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Data pipeline filters
FilterDescription
gzip compressionData compression using zlib.
Szip compressionData compression using the Szip library. See The HDF Group website for more information + * regarding the Szip filter.
N-bit compressionData compression using an algorithm specialized for n-bit datatypes.
Scale-offset compressionData compression using a “scale and offset†algorithm.
ShufflingTo improve compression performance, data is regrouped by its byte position in the data + * unit. In other words, the 1st, 2nd, 3rd, and 4th bytes of integers are stored together + * respectively.
Fletcher32Fletcher32 checksum for error-detection.
+ * + * Filters may be used only for chunked data and are applied to chunks of data between the file + * hyperslab stage and the virtual file layer. At this stage in the pipeline, the data is organized as + * fixed-size blocks of elements, and the filter stage processes each chunk separately. + * + * Filters are selected by dataset creation properties, and some behavior may be controlled by data + * transfer properties. The library determines what filters must be applied and applies them in the + * order in which they were set by the application. That is, if an application calls + * #H5Pset_shuffle and then #H5Pset_deflate when creating a dataset’s creation property list, the + * library will apply the shuffle filter first and then the deflate filter. + * + * For more information, + * \li @see @ref subsubsec_dataset_filters_nbit + * \li @see @ref subsubsec_dataset_filters_scale + * + * \subsubsection subsubsec_dataset_transfer_drive File Drivers + * I/O is performed by the HDF5 virtual file layer. The file driver interface writes and reads blocks + * of data; each driver module implements the interface using different I/O mechanisms. The table + * below lists the file drivers currently supported. Note that the I/O mechanisms are separated from + * the pipeline processing: the pipeline and filter operations are identical no matter what data access + * mechanism is used. + * + * \snippet{doc} tables/propertyLists.dox lcpl_table + * + * Each file driver writes/reads contiguous blocks of bytes from a logically contiguous address + * space. The file driver is responsible for managing the details of the different physical storage + * methods. + * + * In serial environments, everything above the virtual file layer tends to work identically no matter + * what storage method is used. + * + * Some options may have substantially different performance depending on the file driver that is + * used. In particular, multi-file and parallel I/O may perform considerably differently from serial + * drivers depending on chunking and other settings. + * + * \subsubsection subsubsec_dataset_transfer_props Data Transfer Properties to Manage the Pipeline + * Data transfer properties set optional parameters that control parts of the data pipeline. The + * function listing below shows transfer properties that control the behavior of the library. + * + * \snippet{doc} tables/fileDriverLists.dox file_driver_table + * + * Some filters and file drivers require or use additional parameters from the application program. + * These can be passed in the data transfer property list. The table below shows file driver property + * list functions. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
File driver property list functions
C FunctionPurpose
#H5Pset_dxpl_mpioControl the MPI I/O transfer mode (independent or collective) during data I/O operations.
#H5Pset_small_data_block_sizeReserves blocks of size bytes for the contiguous storage of the raw data portion of small + * datasets. The HDF5 Library then writes the raw data from small datasets to this reserved space + * which reduces unnecessary discontinuities within blocks of metadata and improves + * I/O performance.
#H5Pset_edc_checkDisable/enable EDC checking for read. When selected, EDC is always written.
+ * + * The transfer properties are set in a property list which is passed as a parameter of the #H5Dread or + * #H5Dwrite call. The transfer properties are passed to each pipeline stage. Each stage may use or + * ignore any property in the list. In short, there is one property list that contains all the properties. + * + * \subsubsection subsubsec_dataset_transfer_store Storage Strategies + * The raw data is conceptually a multi-dimensional array of elements that is stored as a contiguous + * array of bytes. The data may be physically stored in the file in several ways. The table below lists + * the storage strategies for a dataset. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Dataset storage strategies
Storage StrategyDescription
ContiguousThe dataset is stored as one continuous array of bytes.
Chunked The dataset is stored as fixed-size chunks.
CompactA small dataset is stored in the metadata header.
+ * + * The different storage strategies do not affect the data transfer operations of the dataset: reads and + * writes work the same for any storage strategy. + * + * These strategies are described in the following sections. + * + *

Contiguous

+ * A contiguous dataset is stored in the file as a header and a single continuous array of bytes. See + * the figure below. In the case of a multi-dimensional array, the data is serialized in row major order. By + * default, data is stored contiguously. + * + * + * + * + * + *
+ * \image html Dsets_fig6.gif "Contiguous data storage" + *
+ * + * Contiguous storage is the simplest model. It has several limitations. First, the dataset must be a + * fixed-size: it is not possible to extend the limit of the dataset or to have unlimited dimensions. In + * other words, if the number of dimensions of the array might change over time, then chunking + * storage must be used instead of contiguous. Second, because data is passed through the pipeline + * as fixed-size blocks, compression and other filters cannot be used with contiguous data. + * + *

Chunked

+ * The data of a dataset may be stored as fixed-size chunks. A chunk is a hyper- + * rectangle of any shape. When a dataset is chunked, each chunk is read or written as a single I/O + * operation, and individually passed from stage to stage of the data pipeline. + * + * + * + * + * + *
+ * \image html Dsets_fig7.gif "Chunked data storage" + *
+ * + * Chunks may be any size and shape that fits in the dataspace of the dataset. For example, a three + * dimensional dataspace can be chunked as 3-D cubes, 2-D planes, or 1-D lines. The chunks may + * extend beyond the size of the dataspace. For example, a 3 x 3 dataset might by chunked in 2 x 2 + * chunks. Sufficient chunks will be allocated to store the array, and any extra space will not be + * accessible. So, to store the 3 x 3 array, four 2 x 2 chunks would be allocated with 5 unused + * elements stored. + * + * Chunked datasets can be unlimited in any direction and can be compressed or filtered. + * + * Since the data is read or written by chunks, chunking can have a dramatic effect on performance + * by optimizing what is read and written. Note, too, that for specific access patterns such as + * parallel I/O, decomposition into chunks can have a large impact on performance. + * + * Two restrictions have been placed on chunk shape and size: + *
  • The rank of a chunk must be less than or equal to the rank of the dataset
  • + *
  • Chunk size cannot exceed the size of a fixed-size dataset; for example, a dataset consisting of + * a 5 x 4 fixed-size array cannot be defined with 10 x 10 chunks
+ * + *

Compact

+ * For contiguous and chunked storage, the dataset header information and data are stored in two + * (or more) blocks. Therefore, at least two I/O operations are required to access the data: one to + * access the header, and one (or more) to access data. For a small dataset, this is considerable + * overhead. + * + * A small dataset may be stored in a continuous array of bytes in the header block using the + * compact storage option. This dataset can be read entirely in one operation which retrieves the + * header and data. The dataset must fit in the header. This may vary depending on the metadata + * that is stored. In general, a compact dataset should be approximately 30 KB or less total size. + * + * + * + * + * + *
+ * \image html Dsets_fig8.gif "Compact data storage" + *
+ * + * \subsubsection subsubsec_dataset_transfer_partial Partial I/O Subâ€setting and Hyperslabs + * Data transfers can write or read some of the data elements of the dataset. This is controlled by + * specifying two selections: one for the source and one for the destination. Selections are specified + * by creating a dataspace with selections. + * + * Selections may be a union of hyperslabs or a list of points. A hyperslab is a contiguous hyper- + * rectangle from the dataspace. Selected fields of a compound datatype may be read or written. In + * this case, the selection is controlled by the memory and file datatypes. + * + * Summary of procedure: + * \li 1. Open the dataset + * \li 2. Define the memory datatype + * \li 3. Define the memory dataspace selection and file dataspace selection + * \li 4. Transfer data (#H5Dread or #H5Dwrite) + * + * For more information, + * @see @ref sec_dataspace + * + * \subsection subsec_dataset_allocation Allocation of Space in the File + * When a dataset is created, space is allocated in the file for its header and initial data. The amount +of space allocated when the dataset is created depends on the storage properties. When the +dataset is modified (data is written, attributes added, or other changes), additional storage may be +allocated if necessary. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Initial dataset size
ObjectSize
HeaderVariable, but typically around 256 bytes at the creation of a simple dataset with a simple + * datatype.
DataSize of the data array (number of elements x size of element). Space allocated in + * the file depends on the storage strategy and the allocation strategy.
+ * + *

Header

+ * A dataset header consists of one or more header messages containing persistent metadata + * describing various aspects of the dataset. These records are defined in the HDF5 File Format + * Specification. The amount of storage required for the metadata depends on the metadata to be + * stored. The table below summarizes the metadata. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Metadata storage sizes
Header InformationApproximate Storage Size
Datatype (required)Bytes or more. Depends on type.
Dataspace (required)Bytes or more. Depends on number of dimensions and hsize_t.
Layout (required)Points to the stored data. Bytes or more. Depends on hsize_t and number of dimensions.
FiltersDepends on the number of filters. The size of the filter message depends on the name and + * data that will be passed.
+ * + * The header blocks also store the name and values of attributes, so the total storage depends on + * the number and size of the attributes. + * + * In addition, the dataset must have at least one link, including a name, which is stored in the file + * and in the group it is linked from. + * + * The different storage strategies determine when and how much space is allocated for the data + * array. See the discussion of fill values below for a detailed explanation of the storage allocation. + * + *

Contiguous Storage

+ * For a continuous storage option, the data is stored in a single, contiguous block in the file. The + * data is nominally a fixed-size, (number of elements x size of element). The figure below shows + * an example of a two dimensional array stored as a contiguous dataset. + * + * Depending on the fill value properties, the space may be allocated when the dataset is created or + * when first written (default), and filled with fill values if specified. For parallel I/O, by default the + * space is allocated when the dataset is created. + * + * + * + * + * + *
+ * \image html Dsets_fig9.gif "A two dimensional array stored as a contiguous dataset" + *
+ * + *

Chunked Storage

+ * For chunked storage, the data is stored in one or more chunks. Each chunk is a continuous block + * in the file, but chunks are not necessarily stored contiguously. Each chunk has the same size. The + * data array has the same nominal size as a contiguous array (number of elements x size of + * element), but the storage is allocated in chunks, so the total size in the file can be larger than the + * nominal size of the array. See the figure below. + * + * If a fill value is defined, each chunk will be filled with the fill value. Chunks must be allocated + * when data is written, but they may be allocated when the file is created, as the file expands, or + * when data is written. + * + * For serial I/O, by default chunks are allocated incrementally, as data is written to the chunk. For + * a sparse dataset, chunks are allocated only for the parts of the dataset that are written. In this + * case, if the dataset is extended, no storage is allocated. + * + * For parallel I/O, by default chunks are allocated when the dataset is created or extended with fill + * values written to the chunk. + * + * In either case, the default can be changed using fill value properties. For example, using serial + * I/O, the properties can select to allocate chunks when the dataset is created. + * + * + * + * + * + *
+ * \image html Dsets_fig10.gif "A two dimensional array stored in chunks" + *
+ * + *

Changing Dataset Dimensions

+ * #H5Dset_extent is used to change the current dimensions of the dataset within the limits of the + * dataspace. Each dimension can be extended up to its maximum or unlimited. Extending the + * dataspace may or may not allocate space in the file and may or may not write fill values, if they + * are defined. See the example code below. + * + * The dimensions of the dataset can also be reduced. If the sizes specified are smaller than the + * dataset’s current dimension sizes, #H5Dset_extent will reduce the dataset’s dimension sizes to the + * specified values. It is the user’s responsibility to ensure that valuable data is not lost; + * #H5Dset_extent does not check. + * + * Using #H5Dset_extent to increase the size of a dataset + * \code + * hid_t file_id, dataset_id; + * herr_t status; + * size_t newdims[2]; + * + * // Open an existing file. + * file_id = H5Fopen("dset.h5", H5F_ACC_RDWR, H5P_DEFAULT); + * + * // Open an existing dataset. + * dataset_id = H5Dopen(file_id, "/dset", H5P_DEFAULT); + * + * // Example: dataset is 2 x 3, each dimension is UNLIMITED + * // extend to 2 x 7 + * newdims[0] = 2; + * newdims[1] = 7; + * status = H5Dset_extent(dataset_id, newdims); + * + * // dataset is now 2 x 7 + * + * status = H5Dclose(dataset_id); + * \endcode + * + * \subsubsection subsubsec_dataset_allocation_store Storage Allocation in the File: Early, Incremental, Late + * The HDF5 Library implements several strategies for when storage is allocated if and when it is + * filled with fill values for elements not yet written by the user. Different strategies are + * recommended for different storage layouts and file drivers. In particular, a parallel program + * needs storage allocated during a collective call (for example, create or extend), while serial + * programs may benefit from delaying the allocation until the data is written. + * + * Two file creation properties control when to allocate space, when to write the fill value, and the + * actual fill value to write. + * + *

When to Allocate Space

+ * The table below shows the options for when data is allocated in the file. Early allocation is done + * during the dataset create call. Certain file drivers (especially MPI-I/O and MPI-POSIX) require + * space to be allocated when a dataset is created, so all processors will have the correct view of the + * data. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
File storage allocation options
StrategyDescription
EarlyAllocate storage for the dataset immediately when the dataset is created.
LateDefer allocating space for storing the dataset until the dataset is written.
IncrementalDefer allocating space for storing each chunk until the chunk is written.
DefaultUse the strategy (Early, Late, or Incremental) for the storage method and + * access method. This is the recommended strategy.
+ * + * Late allocation is done at the time of the first write to dataset. Space for the whole dataset is + * allocated at the first write. + * + * Incremental allocation (chunks only) is done at the time of the first write to the chunk. Chunks + * that have never been written are not allocated in the file. In a sparsely populated dataset, this + * option allocates chunks only where data is actually written. + * + * The “Default†property selects the option recommended as appropriate for the storage method + * and access method. The defaults are shown in the table below. Note that Early allocation is + * recommended for all Parallel I/O, while other options are recommended as the default for serial + * I/O cases. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Default storage options
Storage TypeSerial I/OParallel I/O
ContiguousLateEarly
ChunkedIncrementalEarly
CompactEarlyEarly
+ * + *

When to Write the Fill Value

+ * The second property is when to write the fill value. The possible values are “Never†and + * “Allocationâ€. The table below shows these options. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
When to write fill values
WhenDescription
NeverFill value will never be written.
AllocationFill value is written when space is allocated. (Default for chunked and contiguous + * data storage.)
+ * + *

What Fill Value to Write

+ * The third property is the fill value to write. The table below shows the values. By default, the + * data is filled with zeros. The application may choose no fill value (Undefined). In this case, + * uninitialized data may have random values. The application may define a fill value of an + * appropriate type. For more information, @see @ref subsec_datatype_fill. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Fill values to write
What to WriteDescription
DefaultBy default, the library fills allocated space with zeros.
UndefinedAllocated space is filled with random values.
User-definedThe application specifies the fill value.
+ * + * Together these three properties control the library’s behavior. The table below summarizes the + * possibilities during the dataset create-write-close cycle. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Storage allocation and fill summary
When to allocate spaceWhen to write fill valueWhat fill value to writeLibrary create-write-close behavior
EarlyNever-Library allocates space when dataset is created, but never writes a fill value to dataset. A read + * of unwritten data returns undefined values.
LateNever-Library allocates space when dataset is written to, but never writes a fill value to the dataset. A + * read of unwritten data returns undefined values.
IncrementalNever-Library allocates space when a dataset or chunk (whichever is the smallest unit of space) + * is written to, but it never writes a fill value to a dataset or a chunk. A read of unwritten data + * returns undefined values.
-AllocationUndefinedError on creating the dataset. The dataset is not created.
EarlyAllocationDefault or User-definedAllocate space for the dataset when the dataset is created. Write the fill value (default or + * user-defined) to the entire dataset when the dataset is created.
LateAllocationDefault or User-defineAllocate space for the dataset when the application first writes data values to the dataset. + * Write the fill value to the entire dataset before writing application data values.
IncrementalAllocationDefault or User-defineAllocate space for the dataset when the application first writes data values to the dataset or + * chunk (whichever is the smallest unit of space). Write the fill value to the entire dataset + * or chunk before writing application data values.
+ * + * During the #H5Dread function call, the library behavior depends on whether space has been + * allocated, whether the fill value has been written to storage, how the fill value is defined, and + * when to write the fill value. The table below summarizes the different behaviors. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
H5Dread summary
Is space allocated in the file?What is the fill value?When to write the fill value?Library read behavior
NoUndefinedanytimeError. Cannot create this dataset.
NoDefault or User-defineanytimeFill the memory buffer with the fill value.
YesUndefinedanytimeReturn data from storage (dataset). Trash is possible if the application has not written data + * to the portion of the dataset being read.
YesDefault or User-defineNeverReturn data from storage (dataset). Trash is possible if the application has not written data + * to the portion of the dataset being read.
YesDefault or User-defineAllocationReturn data from storage (dataset).
+ * + * There are two cases to consider depending on whether the space in the file has been allocated + * before the read or not. When space has not yet been allocated and if a fill value is defined, the + * memory buffer will be filled with the fill values and returned. In other words, no data has been + * read from the disk. If space has been allocated, the values are returned from the stored data. The + * unwritten elements will be filled according to the fill value. + * + * \subsubsection subsubsec_dataset_allocation_delete Deleting a Dataset from a File and Reclaiming Space + * HDF5 does not at this time provide an easy mechanism to remove a dataset from a file or to + * reclaim the storage space occupied by a deleted object. + * + * Removing a dataset and reclaiming the space it used can be done with the #H5Ldelete function + * and the h5repack utility program. With the H5Ldelete function, links to a dataset can be removed + * from the file structure. After all the links have been removed, the dataset becomes inaccessible to + * any application and is effectively removed from the file. The way to recover the space occupied + * by an unlinked dataset is to write all of the objects of the file into a new file. Any unlinked object + * is inaccessible to the application and will not be included in the new file. Writing objects to a + * new file can be done with a custom program or with the h5repack utility program. + * + * For more information, @see @ref sec_group + * + * \subsubsection subsubsec_dataset_allocation_release Releasing Memory Resources + * The system resources required for HDF5 objects such as datasets, datatypes, and dataspaces + * should be released once access to the object is no longer needed. This is accomplished via the + * appropriate close function. This is not unique to datasets but a general requirement when + * working with the HDF5 Library; failure to close objects will result in resource leaks. + * + * In the case where a dataset is created or data has been transferred, there are several objects that + * must be closed. These objects include datasets, datatypes, dataspaces, and property lists. + * + * The application program must free any memory variables and buffers it allocates. When + * accessing data from the file, the amount of memory required can be determined by calculating + * the size of the memory datatype and the number of elements in the memory selection. + * + * Variable-length data are organized in two or more areas of memory. For more information, + * \see \ref h4_vlen_datatype "Variable-length Datatypes". + * + * When writing data, the application creates an array of + * vl_info_t which contains pointers to the elements. The elements might be, for example, strings. + * In the file, the variable-length data is stored in two parts: a heap with the variable-length values + * of the data elements and an array of vl_info_t elements. When the data is read, the amount of + * memory required for the heap can be determined with the #H5Dvlen_get_buf_size call. + * + * The data transfer property may be used to set a custom memory manager for allocating variable- + * length data for a #H5Dread. This is set with the #H5Pset_vlen_mem_manager call. + * To free the memory for variable-length data, it is necessary to visit each element, free the + * variable-length data, and reset the element. The application must free the memory it has + * allocated. For memory allocated by the HDF5 Library during a read, the #H5Dvlen_reclaim + * function can be used to perform this operation. + * + * \subsubsection subsubsec_dataset_allocation_ext External Storage Properties + * The external storage format allows data to be stored across a set of non-HDF5 files. A set of + * segments (offsets and sizes) in one or more files is defined as an external file list, or EFL, and + * the contiguous logical addresses of the data storage are mapped onto these segments. Currently, + * only the #H5D_CONTIGUOUS storage format allows external storage. External storage is + * enabled by a dataset creation property. The table below shows the API. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
External storage API
FunctionDescription
#H5Pset_externalThis function adds a new segment to the end of the external file list of the specified dataset + * creation property list. The segment begins a byte offset of file name and continues for size + * bytes. The space represented by this segment is adjacent to the space already represented by + * the external file list. The last segment in a file list may have the size #H5F_UNLIMITED, in + * which case the external file may be of unlimited size and no more files can be added to the + * external files list.
#H5Pget_external_countCalling this function returns the number of segments in an external file list. If the dataset + * creation property list has no external data, then zero is returned.
#H5Pget_externalThis is the counterpart for the #H5Pset_external function. Given a dataset creation + * property list and a zero-based index into that list, the file name, byte offset, and segment + * size are returned through non-null arguments. At most name_size characters are copied into + * the name argument which is not null terminated if the file name is longer than the + * supplied name buffer (this is similar to strncpy()).
+ * + * The figure below shows an example of how a contiguous, one-dimensional dataset is partitioned + * into three parts and each of those parts is stored in a segment of an external file. The top + * rectangle represents the logical address space of the dataset while the bottom rectangle represents + * an external file. + * + * + * + * + * + *
+ * \image html Dsets_fig11.gif "External file storage" + *
+ * + * The example below shows code that defines the external storage for the example. Note that the + * segments are defined in order of the logical addresses they represent, not their order within the + * external file. It would also have been possible to put the segments in separate files. Care should + * be taken when setting up segments in a single file since the library does not automatically check + * for segments that overlap. + * + * External storage + * \code + * plist = H5Pcreate (H5P_DATASET_CREATE); + * H5Pset_external (plist, "velocity.data", 3000, 1000); + * H5Pset_external (plist, "velocity.data", 0, 2500); + * H5Pset_external (plist, "velocity.data", 4500, 1500); + * \endcode + * + * The figure below shows an example of how a contiguous, two-dimensional dataset is partitioned + * into three parts and each of those parts is stored in a separate external file. The top rectangle + * represents the logical address space of the dataset while the bottom rectangles represent external + * files. + * + * + * + * + * + *
+ * \image html Dsets_fig12.gif "Partitioning a 2-D dataset for external storage" + *
+ * + * The example below shows code for the partitioning described above. In this example, the library + * maps the multi-dimensional array onto a linear address space as defined by the HDF5 format + * specification, and then maps that address space into the segments defined in the external file list. + * + * Partitioning a 2-D dataset for external storage + * \code + * plist = H5Pcreate (H5P_DATASET_CREATE); + * H5Pset_external (plist, "scan1.data", 0, 24); + * H5Pset_external (plist, "scan2.data", 0, 24); + * H5Pset_external (plist, "scan3.data", 0, 16); + * \endcode + * + * The segments of an external file can exist beyond the end of the (external) file. The library reads + * that part of a segment as zeros. When writing to a segment that exists beyond the end of a file, + * the external file is automatically extended. Using this feature, one can create a segment (or set of + * segments) which is larger than the current size of the dataset. This allows the dataset to be + * extended at a future time (provided the dataspace also allows the extension). + * + * All referenced external data files must exist before performing raw data I/O on the dataset. This + * is normally not a problem since those files are being managed directly by the application or + * indirectly through some other library. However, if the file is transferred from its original context, + * care must be taken to assure that all the external files are accessible in the new location. + * + * \subsection subsec_dataset_filters Using HDF5 Filters + * This section describes in detail how to use the n-bit, scale-offset filters and szip filters. + * + * \subsubsection subsubsec_dataset_filters_nbit Using the Nâ€bit Filter + * N-bit data has n significant bits, where n may not correspond to a precise number of bytes. On + * the other hand, computing systems and applications universally, or nearly so, run most efficiently + * when manipulating data as whole bytes or multiple bytes. + * + * Consider the case of 12-bit integer data. In memory, that data will be handled in at least 2 bytes, + * or 16 bits, and on some platforms in 4 or even 8 bytes. The size of such a dataset can be + * significantly reduced when written to disk if the unused bits are stripped out. + * + * The n-bit filter is provided for this purpose, packing n-bit data on output by stripping off all + * unused bits and unpacking on input, restoring the extra bits required by the computational + * processor. + * + *

N-bit Datatype

+ * An n-bit datatype is a datatype of n significant bits. Unless it is packed, an n-bit datatype is + * presented as an n-bit bitfield within a larger-sized value. For example, a 12-bit datatype might be + * presented as a 12-bit field in a 16-bit, or 2-byte, value. + * + * Currently, the datatype classes of n-bit datatype or n-bit field of a compound datatype or an array + * datatype are limited to integer or floating-point. + * + * The HDF5 user can create an n-bit datatype through a series of function calls. For example, the + * following calls create a 16-bit datatype that is stored in a 32-bit value with a 4-bit offset: + * \code + * hid_t nbit_datatype = H5Tcopy(H5T_STD_I32LE); + * H5Tset_precision(nbit_datatype, 16); + * H5Tset_offset(nbit_datatype, 4); + * \endcode + * + * In memory, one value of the above example n-bit datatype would be stored on a little-endian + * machine as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
byte 3byte 2byte 1byte 0
???????? ????SPPP PPPPPPPP PPPP????
+ * Note: Key: S - sign bit, E - exponent bit, M - mantissa bit, ? - padding bit. Sign bit is + * included in signed integer datatype precision. + *
+ * + *

N-bit Filter

+ * When data of an n-bit datatype is stored on disk using the n-bit filter, the filter packs the data by + * stripping off the padding bits; only the significant bits are retained and stored. The values on disk + * will appear as follows: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
1st value2nd valuenth value
SPPPPPPP PPPPPPPPSPPPPPPP PPPPPPPP...
+ * Note: Key: S - sign bit, E - exponent bit, M - mantissa bit, ? - padding bit. Sign bit is + * included in signed integer datatype precision. + *
+ * + *

How Does the N-bit Filter Work?

+ * The n-bit filter always compresses and decompresses according to dataset properties supplied by + * the HDF5 library in the datatype, dataspace, or dataset creation property list. + * + * The dataset datatype refers to how data is stored in an HDF5 file while the memory datatype + * refers to how data is stored in memory. The HDF5 library will do datatype conversion when + * writing data in memory to the dataset or reading data from the dataset to memory if the memory + * datatype differs from the dataset datatype. Datatype conversion is performed by HDF5 library + * before n-bit compression and after n-bit decompression. + * + * The following sub-sections examine the common cases: + * \li N-bit integer conversions + * \li N-bit floating-point conversions + * + *

N-bit Integer Conversions

+ * Integer data with a dataset of integer datatype of less than full precision and a memory datatype + * of #H5T_NATIVE_INT, provides the simplest application of the n-bit filter. + * + * The precision of #H5T_NATIVE_INT is 8 multiplied by sizeof(int). This value, the size of an + * int in bytes, differs from platform to platform; we assume a value of 4 for the following + * illustration. We further assume the memory byte order to be little-endian. + * + * In memory, therefore, the precision of #H5T_NATIVE_INT is 32 and the offset is 0. One value of + * #H5T_NATIVE_INT is laid out in memory as follows: + * + * + * + * + *
+ * \image html Dsets_NbitInteger1.gif "H5T_NATIVE_INT in memory"
+ * Note: Key: S - sign bit, E - exponent bit, M - mantissa bit, ? - padding bit. Sign bit is + * included in signed integer datatype precision. + *
+ * + * Suppose the dataset datatype has a precision of 16 and an offset of 4. After HDF5 converts + * values from the memory datatype to the dataset datatype, it passes something like the following + * to the n-bit filter for compression: + * + * + * + * + *
+ * \image html Dsets_NbitInteger2.gif "Passed to the n-bit filter"
+ * Note: Key: S - sign bit, E - exponent bit, M - mantissa bit, ? - padding bit. Sign bit is + * included in signed integer datatype precision. + *
+ * + * Notice that only the specified 16 bits (15 significant bits and the sign bit) are retained in the + * conversion. All other significant bits of the memory datatype are discarded because the dataset + * datatype calls for only 16 bits of precision. After n-bit compression, none of these discarded bits, + * known as padding bits will be stored on disk. + * + *

N-bit Floating-point Conversions

+ * Things get more complicated in the case of a floating-point dataset datatype class. This sub- + * section provides an example that illustrates the conversion from a memory datatype of + * #H5T_NATIVE_FLOAT to a dataset datatype of class floating-point. + * + * As before, let the #H5T_NATIVE_FLOAT be 4 bytes long, and let the memory byte order be + * little-endian. Per the IEEE standard, one value of #H5T_NATIVE_FLOAT is laid out in memory + * as follows: + * + * + * + * + *
+ * \image html Dsets_NbitFloating1.gif "H5T_NATIVE_FLOAT in memory"
+ * Note: Key: S - sign bit, E - exponent bit, M - mantissa bit, ? - padding bit. Sign bit is + * included in floating-point datatype precision. + *
+ * + * Suppose the dataset datatype has a precision of 20, offset of 7, mantissa size of 13, mantissa + * position of 7, exponent size of 6, exponent position of 20, and sign position of 26. For more + * information, @see @ref subsubsec_datatype_program_define. + * + * After HDF5 converts values from the memory datatype to the dataset datatype, it passes + * something like the following to the n-bit filter for compression: + * + * + * + * + *
+ * \image html Dsets_NbitFloating2.gif "Passed to the n-bit filter"
+ * Note: Key: S - sign bit, E - exponent bit, M - mantissa bit, ? - padding bit. Sign bit is + * included in floating-point datatype precision. + *
+ * + * The sign bit and truncated mantissa bits are not changed during datatype conversion by the + * HDF5 library. On the other hand, the conversion of the 8-bit exponent to a 6-bit exponent is a + * little tricky: + * + * The bias for the new exponent in the n-bit datatype is: + * + * 2(n-1)-1 + * + * + * The following formula is used for this exponent conversion:
+ * + * exp8 - (2(8-1) -1) = exp6 - (2(6-1)-1) = actual exponent value + *
+ * where exp8 is the stored decimal value as represented by the 8-bit exponent, and exp6 is the + * stored decimal value as represented by the 6-bit exponent. + * + * In this example, caution must be taken to ensure that, after conversion, the actual exponent value + * is within the range that can be represented by a 6-bit exponent. For example, an 8-bit exponent + * can represent values from -127 to 128 while a 6-bit exponent can represent values only from -31 + * to 32. + * + *

N-bit Filter Behavior

+ * The n-bit filter was designed to treat the incoming data byte by byte at the lowest level. The + * purpose was to make the n-bit filter as generic as possible so that no pointer cast related to the + * datatype is needed. + * + * Bitwise operations are employed for packing and unpacking at the byte level. + * + * Recursive function calls are used to treat compound and array datatypes. + * + *

N-bit Compression

+ * The main idea of n-bit compression is to use a loop to compress each data element in a chunk. + * Depending on the datatype of each element, the n-bit filter will call one of four functions. Each + * of these functions performs one of the following tasks: + * \li Compress a data element of a no-op datatype + * \li Compress a data element of an atomic datatype + * \li Compress a data element of a compound datatype + * \li Compress a data element of an array datatype + * + * No-op datatypes: The n-bit filter does not actually compress no-op datatypes. Rather, it copies + * the data buffer of the no-op datatype from the non-compressed buffer to the proper location in + * the compressed buffer; the compressed buffer has no holes. The term “compress†is used here + * simply to distinguish this function from the function that performs the reverse operation during + * decompression. + * + * Atomic datatypes: The n-bit filter will find the bytes where significant bits are located and try to + * compress these bytes, one byte at a time, using a loop. At this level, the filter needs the following + * information: + *
  • The byte offset of the beginning of the current data element with respect to the + * beginning of the input data buffer
  • + *
  • Datatype size, precision, offset, and byte order
+ * + * The n-bit filter compresses from the most significant byte containing significant bits to the least + * significant byte. For big-endian data, therefore, the loop index progresses from smaller to larger + * while for little-endian, the loop index progresses from larger to smaller. + * + * In the extreme case of when the n-bit datatype has full precision, this function copies the content + * of the entire non-compressed datatype to the compressed output buffer. + * + * Compound datatypes: The n-bit filter will compress each data member of the compound + * datatype. If the member datatype is of an integer or floating-point datatype, the n-bit filter will + * call the function described above. If the member datatype is of a no-op datatype, the filter will + * call the function described above. If the member datatype is of a compound datatype, the filter + * will make a recursive call to itself. If the member datatype is of an array datatype, the filter will + * call the function described below. + * + * Array datatypes: The n-bit filter will use a loop to compress each array element in the array. If + * the base datatype of array element is of an integer or floating-point datatype, the n-bit filter will + * call the function described above. If the base datatype is of a no-op datatype, the filter will call + * the function described above. If the base datatype is of a compound datatype, the filter will call + * the function described above. If the member datatype is of an array datatype, the filter will make + * a recursive call of itself. + * + *

N-bit Decompression

+ * The n-bit decompression algorithm is very similar to n-bit compression. The only difference is + * that at the byte level, compression packs out all padding bits and stores only significant bits into + * a continuous buffer (unsigned char) while decompression unpacks significant bits and inserts + * padding bits (zeros) at the proper positions to recover the data bytes as they existed before + * compression. + * + *

Storing N-bit Parameters to Array cd_value[]

+ * All of the information, or parameters, required by the n-bit filter are gathered and stored in the + * array cd_values[] by the private function H5Z__set_local_nbit and are passed to another private + * function, H5Z__filter_nbit, by the HDF5 Library. + * These parameters are as follows: + * \li Parameters related to the datatype + * \li The number of elements within the chunk + * \li A flag indicating whether compression is needed + * + * The first and second parameters can be obtained using the HDF5 dataspace and datatype + * interface calls. + * + * A compound datatype can have members of array or compound datatype. An array datatype’s + * base datatype can be a complex compound datatype. Recursive calls are required to set + * parameters for these complex situations. + * + * Before setting the parameters, the number of parameters should be calculated to dynamically + * allocate the array cd_values[], which will be passed to the HDF5 Library. This also requires + * recursive calls. + * + * For an atomic datatype (integer or floating-point), parameters that will be stored include the + * datatype’s size, endianness, precision, and offset. + * + * For a no-op datatype, only the size is required. + * + * For a compound datatype, parameters that will be stored include the datatype’s total size and + * number of members. For each member, its member offset needs to be stored. Other parameters + * for members will depend on the respective datatype class. + * + * For an array datatype, the total size parameter should be stored. Other parameters for the array’s + * base type depend on the base type’s datatype class. + * + * Further, to correctly retrieve the parameter for use of n-bit compression or decompression later, + * parameters for distinguishing between datatype classes should be stored. + * + *

Implementation

+ * Three filter callback functions were written for the n-bit filter: + * \li H5Z__can_apply_nbit + * \li H5Z__set_local_nbit + * \li H5Z__filter_nbit + * + * These functions are called internally by the HDF5 library. A number of utility functions were + * written for the function H5Z__set_local_nbit. Compression and decompression functions were + * written and are called by function H5Z__filter_nbit. All these functions are included in the file + * H5Znbit.c. + * + * The public function #H5Pset_nbit is called by the application to set up the use of the n-bit filter. + * This function is included in the file H5Pdcpl.c. The application does not need to supply any + * parameters. + * + *

How N-bit Parameters are Stored

+ * A scheme of storing parameters required by the n-bit filter in the array cd_values[] was + * developed utilizing recursive function calls. + * + * Four private utility functions were written for storing the parameters associated with atomic + * (integer or floating-point), no-op, array, and compound datatypes: + * \li H5Z__set_parms_atomic + * \li H5Z__set_parms_array + * \li H5Z__set_parms_nooptype + * \li H5Z__set_parms_compound + * + * The scheme is briefly described below. + * + * First, assign a numeric code for datatype class atomic (integer or float), no-op, array, and + * compound datatype. The code is stored before other datatype related parameters are stored. + * + * The first three parameters of cd_values[] are reserved for: + * \li 1. The number of valid entries in the array cd_values[] + * \li 2. A flag indicating whether compression is needed + * \li 3. The number of elements in the chunk + * + * Throughout the balance of this explanation, i represents the index of cd_values[]. + * In the function H5Z__set_local_nbit: + *
  • 1. i = 2
  • + *
  • 2. Get the number of elements in the chunk and store in cd_value[i]; increment i
  • + *
  • 3. Get the class of the datatype: + *
    • For an integer or floating-point datatype, call H5Z__set_parms_atomic
    • + *
    • For an array datatype, call H5Z__set_parms_array
    • + *
    • For a compound datatype, call H5Z__set_parms_compound
    • + *
    • For none of the above, call H5Z__set_parms_noopdatatype
  • + *
  • 4. Store i in cd_value[0] and flag in cd_values[1]
+ * + * In the function H5Z__set_parms_atomic: + * \li 1. Store the assigned numeric code for the atomic datatype in cd_value[i]; increment i + * \li 2. Get the size of the atomic datatype and store in cd_value[i]; increment i + * \li 3. Get the order of the atomic datatype and store in cd_value[i]; increment i + * \li 4. Get the precision of the atomic datatype and store in cd_value[i]; increment i + * \li 5. Get the offset of the atomic datatype and store in cd_value[i]; increment i + * \li 6. Determine the need to do compression at this point + * + * In the function H5Z__set_parms_nooptype: + * \li 1. Store the assigned numeric code for the no-op datatype in cd_value[i]; increment i + * \li 2. Get the size of the no-op datatype and store in cd_value[i]; increment i + * + * In the function H5Z__set_parms_array: + *
  • 1. Store the assigned numeric code for the array datatype in cd_value[i]; increment i
  • + *
  • 2. Get the size of the array datatype and store in cd_value[i]; increment i
  • + *
  • 3. Get the class of the array’s base datatype. + *
    • For an integer or floating-point datatype, call H5Z__set_parms_atomic
    • + *
    • For an array datatype, call H5Z__set_parms_array
    • + *
    • For a compound datatype, call H5Z__set_parms_compound
    • + *
    • If none of the above, call H5Z__set_parms_noopdatatype
+ * + * In the function H5Z__set_parms_compound: + *
  • 1. Store the assigned numeric code for the compound datatype in cd_value[i]; increment i
  • + *
  • 2. Get the size of the compound datatype and store in cd_value[i]; increment i
  • + *
  • 3. Get the number of members and store in cd_values[i]; increment i
  • + *
  • 4. For each member + *
    • Get the member offset and store in cd_values[i]; increment i
    • + *
    • Get the class of the member datatype
    • + *
    • For an integer or floating-point datatype, call H5Z__set_parms_atomic
    • + *
    • For an array datatype, call H5Z__set_parms_array
    • + *
    • For a compound datatype, call H5Z__set_parms_compound
    • + *
    • If none of the above, call H5Z__set_parms_noopdatatype
+ * + *

N-bit Compression and Decompression Functions

+ * The n-bit compression and decompression functions above are called by the private HDF5 + * function H5Z__filter_nbit. The compress and decompress functions retrieve the n-bit parameters + * from cd_values[] as it was passed by H5Z__filter_nbit. Parameters are retrieved in exactly the + * same order in which they are stored and lower-level compression and decompression functions + * for different datatype classes are called. + * + * N-bit compression is not implemented in place. Due to the difficulty of calculating actual output + * buffer size after compression, the same space as that of the input buffer is allocated for the output + * buffer as passed to the compression function. However, the size of the output buffer passed by + * reference to the compression function will be changed (smaller) after the compression is + * complete. + * + *

Usage Examples

+ * + * The following code example illustrates the use of the n-bit filter for writing and reading n-bit + * integer data. + * + * N-bit compression for integer data + * \code + * #include "hdf5.h" + * #include "stdlib.h" + * #include "math.h" + * + * #define H5FILE_NAME "nbit_test_int.h5" + * #define DATASET_NAME "nbit_int" + * #define NX 200 + * #define NY 300 + * #define CH_NX 10 + * #define CH_NY 15 + * + * int main(void) + * { + * hid_t file, dataspace, dataset, datatype, mem_datatype, dset_create_props; + * hsize_t dims[2], chunk_size[2]; + * int orig_data[NX][NY]; + * int new_data[NX][NY]; + * int i, j; + * size_t precision, offset; + * + * // Define dataset datatype (integer), and set precision, offset + * datatype = H5Tcopy(H5T_NATIVE_INT); + * precision = 17; // precision includes sign bit + * if(H5Tset_precision(datatype,precision) < 0) { + * printf("Error: fail to set precision\n"); + * return -1; + * } + * offset = 4; + * if(H5Tset_offset(datatype,offset) < 0) { + * printf("Error: fail to set offset\n"); + * return -1; + * } + * + * // Copy to memory datatype + * mem_datatype = H5Tcopy(datatype); + * + * // Set order of dataset datatype + * if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) { + * printf("Error: fail to set endianness\n"); + * return -1; + * } + * + * // Initialize data buffer with random data within correct + * // range corresponding to the memory datatype's precision + * // and offset. + * for (i = 0; i < NX; i++) + * for (j = 0; j < NY; j++) + * orig_data[i][j] = rand() % (int)pow(2, precision-1) << offset; + * + * // Describe the size of the array. + * dims[0] = NX; + * dims[1] = NY; + * if((dataspace = H5Screate_simple (2, dims, NULL)) < 0) { + * printf("Error: fail to create dataspace\n"); + * return -1; + * } + * + * // Create a new file using read/write access, default file + * // creation properties, and default file access properties. + * if((file = H5Fcreate (H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + * printf("Error: fail to create file\n"); + * return -1; + * } + * + * // Set the dataset creation property list to specify that + * // the raw data is to be partitioned into 10 x 15 element + * // chunks and that each chunk is to be compressed. + * chunk_size[0] = CH_NX; + * chunk_size[1] = CH_NY; + * if((dset_create_props = H5Pcreate (H5P_DATASET_CREATE)) < 0) { + * printf("Error: fail to create dataset property\n"); + * return -1; + * } + * if(H5Pset_chunk (dset_create_props, 2, chunk_size) < 0) { + * printf("Error: fail to set chunk\n"); + * return -1; + * } + * + * // Set parameters for n-bit compression; check the description + * // of the H5Pset_nbit function in the HDF5 Reference Manual + * // for more information. + * if(H5Pset_nbit (dset_create_props) < 0) { + * printf("Error: fail to set nbit filter\n"); + * return -1; + * } + * + * // Create a new dataset within the file. The datatype + * // and dataspace describe the data on disk, which may + * // be different from the format used in the application's + * // memory. + * if((dataset = H5Dcreate(file, DATASET_NAME, datatype, dataspace, + * H5P_DEFAULT, dset_create_props, H5P_DEFAULT)) < 0) { + * printf("Error: fail to create dataset\n"); + * return -1; + * } + * + * // Write the array to the file. The datatype and dataspace + * // describe the format of the data in the 'orig_data' buffer. + * // The raw data is translated to the format required on disk, + * // as defined above. We use default raw data transfer + * // properties. + * if(H5Dwrite (dataset, mem_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) { + * printf("Error: fail to write to dataset\n"); + * return -1; + * } + * H5Dclose (dataset); + * + * if((dataset = H5Dopen(file, DATASET_NAME, H5P_DEFAULT)) < 0) { + * printf("Error: fail to open dataset\n"); + * return -1; + * } + * + * // Read the array. This is similar to writing data, + * // except the data flows in the opposite direction. + * // Note: Decompression is automatic. + * if(H5Dread (dataset, mem_datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) { + * printf("Error: fail to read from dataset\n"); + * return -1; + * } + * + * H5Tclose (datatype); + * H5Tclose (mem_datatype); + * H5Dclose (dataset); + * H5Sclose (dataspace); + * H5Pclose (dset_create_props); + * H5Fclose (file); + * + * return 0; + * } + * \endcode + * + * The following code example illustrates the use of the n-bit filter for writing and reading n-bit + * floating-point data. + * + * N-bit compression for floating-point data + * \code + * #include "hdf5.h" + * + * #define H5FILE_NAME "nbit_test_float.h5" + * #define DATASET_NAME "nbit_float" + * #define NX 2 + * #define NY 5 + * #define CH_NX 2 + * #define CH_NY 5 + * + * int main(void) + * { + * hid_t file, dataspace, dataset, datatype, dset_create_props; + * hsize_t dims[2], chunk_size[2]; + * + * // orig_data[] are initialized to be within the range that + * // can be represented by dataset datatype (no precision + * // loss during datatype conversion) + * // + * float orig_data[NX][NY] = {{188384.00, 19.103516,-1.0831790e9, -84.242188, 5.2045898}, + * {-49140.000, 2350.2500, -3.2110596e-1, 6.4998865e-5, -0.0000000}}; + * float new_data[NX][NY]; + * size_t precision, offset; + * + * // Define single-precision floating-point type for dataset + * //--------------------------------------------------------------- + * // size=4 byte, precision=20 bits, offset=7 bits, + * // mantissa size=13 bits, mantissa position=7, + * // exponent size=6 bits, exponent position=20, + * // exponent bias=31. + * // It can be illustrated in little-endian order as: + * // (S - sign bit, E - exponent bit, M - mantissa bit, ? - padding bit) + * // + * // 3 2 1 0 + * // ?????SEE EEEEMMMM MMMMMMMM M??????? + * // + * // To create a new floating-point type, the following + * // properties must be set in the order of + * // set fields -> set offset -> set precision -> set size. + * // All these properties must be set before the type can + * // function. Other properties can be set anytime. Derived + * // type size cannot be expanded bigger than original size + * // but can be decreased. There should be no holes + * // among the significant bits. Exponent bias usually + * // is set 2^(n-1)-1, where n is the exponent size. + * //--------------------------------------------------------------- + * datatype = H5Tcopy(H5T_IEEE_F32BE); + * if(H5Tset_fields(datatype, 26, 20, 6, 7, 13) < 0) { + * printf("Error: fail to set fields\n"); + * return -1; + * } + * offset = 7; + * if(H5Tset_offset(datatype,offset) < 0) { + * printf("Error: fail to set offset\n"); + * return -1; + * } + * precision = 20; + * if(H5Tset_precision(datatype,precision) < 0) { + * printf("Error: fail to set precision\n"); + * return -1; + * } + * if(H5Tset_size(datatype, 4) < 0) { + * printf("Error: fail to set size\n"); + * return -1; + * } + * if(H5Tset_ebias(datatype, 31) < 0) { + * printf("Error: fail to set exponent bias\n"); + * return -1; + * } + * + * // Describe the size of the array. + * dims[0] = NX; + * dims[1] = NY; + * if((dataspace = H5Screate_simple (2, dims, NULL)) < 0) { + * printf("Error: fail to create dataspace\n"); + * return -1; + * } + * + * // Create a new file using read/write access, default file + * // creation properties, and default file access properties. + * if((file = H5Fcreate (H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + * printf("Error: fail to create file\n"); + * return -1; + * } + * + * // Set the dataset creation property list to specify that + * // the raw data is to be partitioned into 2 x 5 element + * // chunks and that each chunk is to be compressed. + * chunk_size[0] = CH_NX; + * chunk_size[1] = CH_NY; + * if((dset_create_props = H5Pcreate (H5P_DATASET_CREATE)) < 0) { + * printf("Error: fail to create dataset property\n"); + * return -1; + * } + * if(H5Pset_chunk (dset_create_props, 2, chunk_size) < 0) { + * printf("Error: fail to set chunk\n"); + * return -1; + * } + * + * // Set parameters for n-bit compression; check the description + * // of the H5Pset_nbit function in the HDF5 Reference Manual + * // for more information. + * if(H5Pset_nbit (dset_create_props) < 0) { + * printf("Error: fail to set nbit filter\n"); + * return -1; + * } + * + * // Create a new dataset within the file. The datatype + * // and dataspace describe the data on disk, which may + * // be different from the format used in the application's memory. + * if((dataset = H5Dcreate(file, DATASET_NAME, datatype, dataspace, H5P_DEFAULT, + * dset_create_plists, H5P_DEFAULT)) < 0) { + * printf("Error: fail to create dataset\n"); + * return -1; + * } + * + * // Write the array to the file. The datatype and dataspace + * // describe the format of the data in the 'orig_data' buffer. + * // The raw data is translated to the format required on disk, + * // as defined above. We use default raw data transfer properties. + * if(H5Dwrite (dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) { + * printf("Error: fail to write to dataset\n"); + * return -1; + * } + * H5Dclose (dataset); + * if((dataset = H5Dopen(file, DATASET_NAME, H5P_DEFAULT))<0) { + * printf("Error: fail to open dataset\n"); + * return -1; + * } + * + * // Read the array. This is similar to writing data, + * // except the data flows in the opposite direction. + * // Note: Decompression is automatic. + * if(H5Dread (dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) { + * printf("Error: fail to read from dataset\n"); + * return -1; + * } + * H5Tclose (datatype); + * H5Dclose (dataset); + * H5Sclose (dataspace); + * H5Pclose (dset_create_props); + * H5Fclose (file); + * + * return 0 + * } + * \endcode + * + *

Limitations

+ * Because the array cd_values[] has to fit into an object header message of 64K, the n-bit filter has + * an upper limit on the number of n-bit parameters that can be stored in it. To be conservative, a + * maximum of 4K is allowed for the number of parameters. + * + * The n-bit filter currently only compresses n-bit datatypes or fields derived from integer or + * floating-point datatypes. The n-bit filter assumes padding bits of zero. This may not be true since + * the HDF5 user can set padding bit to be zero, one, or leave the background alone. However, it is + * expected the n-bit filter will be modified to adjust to such situations. + * + * The n-bit filter does not have a way to handle the situation where the fill value of a dataset is + * defined and the fill value is not of an n-bit datatype although the dataset datatype is. + * + * \subsubsection subsubsec_dataset_filters_scale Using the Scaleâ€offset Filter + * Generally speaking, scale-offset compression performs a scale and/or offset operation on each + * data value and truncates the resulting value to a minimum number of bits (minimum-bits) before + * storing it. + * + * The current scale-offset filter supports integer and floating-point datatypes only. For the floating- + * point datatype, float and double are supported, but long double is not supported. + * + * Integer data compression uses a straight-forward algorithm. Floating-point data compression + * adopts the GRiB data packing mechanism which offers two alternate methods: a fixed minimum- + * bits method, and a variable minimum-bits method. Currently, only the variable minimum-bits + * method is implemented. + * + * Like other I/O filters supported by the HDF5 library, applications using the scale-offset filter + * must store data with chunked storage. + * + * Integer type: The minimum-bits of integer data can be determined by the filter. For example, if + * the maximum value of data to be compressed is 7065 and the minimum value is 2970. Then the + * “span†of dataset values is equal to (max-min+1), which is 4676. If no fill value is defined for the + * dataset, the minimum-bits is: ceiling(log2(span)) = 12. With fill value set, the minimum-bits is: + * ceiling(log2(span+1)) = 13. + * + * HDF5 users can also set the minimum-bits. However, if the user gives a minimum-bits that is + * less than that calculated by the filter, the compression will be lossy. + * + * Floating-point type: The basic idea of the scale-offset filter for the floating-point type is to + * transform the data by some kind of scaling to integer data, and then to follow the procedure of + * the scale-offset filter for the integer type to do the data compression. Due to the data + * transformation from floating-point to integer, the scale-offset filter is lossy in nature. + * + * Two methods of scaling the floating-point data are used: the so-called D-scaling and E-scaling. + * D-scaling is more straightforward and easy to understand. For HDF5 1.8 release, only the + * D-scaling method had been implemented. + * + *

Design

+ * Before the filter does any real work, it needs to gather some information from the HDF5 Library + * through API calls. The parameters the filter needs are: + * \li The minimum-bits of the data value + * \li The number of data elements in the chunk + * \li The datatype class, size, sign (only for integer type), byte order, and fill value if defined + * + * Size and sign are needed to determine what kind of pointer cast to use when retrieving values + * from the data buffer. + * + * The pipeline of the filter can be divided into four parts: (1)pre-compression; (2)compression; + * (3)decompression; (4)post-decompression. + * + * Depending on whether a fill value is defined or not, the filter will handle pre-compression and + * post-decompression differently. + * + * The scale-offset filter only needs the memory byte order, size of datatype, and minimum-bits for + * compression and decompression. + * + * Since decompression has no access to the original data, the minimum-bits and the minimum + * value need to be stored with the compressed data for decompression and post-decompression. + * + *

Integer Type

+ * Pre-compression: During pre-compression minimum-bits is calculated if it is not set by the user. + * For more information on how minimum-bits are calculated, @see @ref subsubsec_dataset_filters_nbit. + * + * If the fill value is defined, finding the maximum and minimum values should ignore the data + * element whose value is equal to the fill value. + * + * If no fill value is defined, the value of each data element is subtracted by the minimum value + * during this stage. + * + * If the fill value is defined, the fill value is assigned to the maximum value. In this way minimum- + * bits can represent a data element whose value is equal to the fill value and subtracts the + * minimum value from a data element whose value is not equal to the fill value. + * + * The fill value (if defined), the number of elements in a chunk, the class of the datatype, the size + * of the datatype, the memory order of the datatype, and other similar elements will be stored in + * the HDF5 object header for the post-decompression usage. + * + * After pre-compression, all values are non-negative and are within the range that can be stored by + * minimum-bits. + * + * Compression: All modified data values after pre-compression are packed together into the + * compressed data buffer. The number of bits for each data value decreases from the number of + * bits of integer (32 for most platforms) to minimum-bits. The value of minimum-bits and the + * minimum value are added to the data buffer and the whole buffer is sent back to the library. In + * this way, the number of bits for each modified value is no more than the size of minimum-bits. + * + * Decompression: In this stage, the number of bits for each data value is resumed from minimum- + * bits to the number of bits of integer. + * + * Post-decompression: For the post-decompression stage, the filter does the opposite of what it + * does during pre-compression except that it does not calculate the minimum-bits or the minimum + * value. These values were saved during compression and can be retrieved through the resumed + * data buffer. If no fill value is defined, the filter adds the minimum value back to each data + * element. + * + * If the fill value is defined, the filter assigns the fill value to the data element whose value is equal + * to the maximum value that minimum-bits can represent and adds the minimum value back to + * each data element whose value is not equal to the maximum value that minimum-bits can + * represent. + * + * @anchor h4_float_datatype

Floating-point Type

+ * The filter will do data transformation from floating-point type to integer type and then handle the + * data by using the procedure for handling the integer data inside the filter. Insignificant bits of + * floating-point data will be cut off during data transformation, so this filter is a lossy compression + * method. + * + * There are two scaling methods: D-scaling and E-scaling. The HDF5 1.8 release only supports D- + * scaling. D-scaling is short for decimal scaling. E-scaling should be similar conceptually. In order + * to transform data from floating-point to integer, a scale factor is introduced. The minimum value + * will be calculated. Each data element value will subtract the minimum value. The modified data + * will be multiplied by 10 (Decimal) to the power of scale_factor, and only the integer part will be + * kept and manipulated through the routines for the integer type of the filter during pre- + * compression and compression. Integer data will be divided by 10 to the power of scale_factor to + * transform back to floating-point data during decompression and post-decompression. Each data + * element value will then add the minimum value, and the floating-point data are resumed. + * However, the resumed data will lose some insignificant bits compared with the original value. + * + * For example, the following floating-point data are manipulated by the filter, and the D-scaling + * factor is 2. + * {104.561, 99.459, 100.545, 105.644} + * + * The minimum value is 99.459, each data element subtracts 99.459, the modified data is + * {5.102, 0, 1.086, 6.185} + * + * Since the D-scaling factor is 2, all floating-point data will be multiplied by 10^2 with this result: + * {510.2, 0, 108.6, 618.5} + * + * The digit after decimal point will be rounded off, and then the set looks like: + * {510, 0, 109, 619} + * + * After decompression, each value will be divided by 10^2 and will be added to the offset 99.459. + * The floating-point data becomes + * {104.559, 99.459, 100.549, 105.649} + * + * The relative error for each value should be no more than 5* (10^(D-scaling factor +1)). + * D-scaling sometimes is also referred as a variable minimum-bits method since for different datasets + * the minimum-bits to represent the same decimal precision will vary. The data value is modified + * to 2 to power of scale_factor for E-scaling. E-scaling is also called fixed-bits method since for + * different datasets the minimum-bits will always be fixed to the scale factor of E-scaling. + * Currently, HDF5 ONLY supports the D-scaling (variable minimum-bits) method. + * + *

Implementation

+ * The scale-offset filter implementation was written and included in the file H5Zscaleoffset.c. + * Function #H5Pset_scaleoffset was written and included in the file “H5Pdcpl.câ€. The HDF5 user + * can supply minimum-bits by calling function #H5Pset_scaleoffset. + * + * The scale-offset filter was implemented based on the design outlined in this section. However, + * the following factors need to be considered: + *
  1. + * The filter needs the appropriate cast pointer whenever it needs to retrieve data values. + *
  2. + *
  3. + * The HDF5 Library passes to the filter the to-be-compressed data in the format of the dataset + * datatype, and the filter passes back the decompressed data in the same format. If a fill value is + * defined, it is also in dataset datatype format. For example, if the byte order of the dataset data- + * type is different from that of the memory datatype of the platform, compression or decompression performs + * an endianness conversion of data buffer. Moreover, it should be aware that + * memory byte order can be different during compression and decompression. + *
  4. + *
  5. + * The difference of endianness and datatype between file and memory should be considered + * when saving and retrieval of minimum-bits, minimum value, and fill value. + *
  6. + * If the user sets the minimum-bits to full precision of the datatype, no operation is needed at + * the filter side. If the full precision is a result of calculation by the filter, then the minimum-bits + * needs to be saved for decompression but no compression or decompression is needed (only a + * copy of the input buffer is needed).
  7. + *
  8. + * If by calculation of the filter, the minimum-bits is equal to zero, special handling is needed. + * Since it means all values are the same, no compression or decompression is needed. But the + * minimum-bits and minimum value still need to be saved during compression.
  9. + *
  10. + * For floating-point data, the minimum value of the dataset should be calculated at first. Each + * data element value will then subtract the minimum value to obtain the “offset†data. The offset + * data will then follow the steps outlined above in the discussion of floating-point types to do data + * transformation to integer and rounding. For more information, @see @ref h4_float_datatype. + *
+ * + *

Usage Examples

+ * The following code example illustrates the use of the scale-offset filter for writing and reading + * integer data. + * + * Scale-offset compression integer data + * \code + * #include "hdf5.h" + * #include "stdlib.h" + * + * #define H5FILE_NAME "scaleoffset_test_int.h5" + * #define DATASET_NAME "scaleoffset_int" + * #define NX 200 + * #define NY 300 + * #define CH_NX 10 + * #define CH_NY 15 + * int main(void) + * { + * hid_t file, dataspace, dataset, datatype, dset_create_props; + * hsize_t dims[2], chunk_size[2]; + * int orig_data[NX][NY]; + * int new_data[NX][NY]; + * int i, j, fill_val; + * + * // Define dataset datatype + * datatype = H5Tcopy(H5T_NATIVE_INT); + * + * // Initialize data buffer + * for (i=0; i < NX; i++) + * for (j=0; j < NY; j++) + * orig_data[i][j] = rand() % 10000; + * + * // Describe the size of the array. + * dims[0] = NX; + * dims[1] = NY; + * if((dataspace = H5Screate_simple (2, dims, NULL)) < 0) { + * printf("Error: fail to create dataspace\n"); + * return -1; + * } + * + * // Create a new file using read/write access, default file + * // creation properties, and default file access properties. + * if((file = H5Fcreate (H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + * printf("Error: fail to create file\n"); + * return -1; + * } + * + * // Set the dataset creation property list to specify that + * // the raw data is to be partitioned into 10 x 15 element + * // chunks and that each chunk is to be compressed. + * chunk_size[0] = CH_NX; + * chunk_size[1] = CH_NY; + * if((dset_create_props = H5Pcreate (H5P_DATASET_CREATE)) < 0) { + * printf("Error: fail to create dataset property\n"); + * return -1; + * } + * if(H5Pset_chunk (dset_create_props, 2, chunk_size) < 0) { + * printf("Error: fail to set chunk\n"); + * return -1; + * } + * + * // Set the fill value of dataset + * fill_val = 10000; + * if (H5Pset_fill_value(dset_create_props, H5T_NATIVE_INT, &fill_val)<0) { + * printf("Error: can not set fill value for dataset\n"); + * return -1; + * } + * + * // Set parameters for scale-offset compression. Check the + * // description of the H5Pset_scaleoffset function in the + * // HDF5 Reference Manual for more information. + * if(H5Pset_scaleoffset (dset_create_props, H5Z_SO_INT, H5Z_SO_INT_MINIMUMBITS_DEFAULT) < 0) { + * printf("Error: fail to set scaleoffset filter\n"); + * return -1; + * } + * + * // Create a new dataset within the file. The datatype + * // and dataspace describe the data on disk, which may + * // or may not be different from the format used in the + * // application's memory. The link creation and + * // dataset access property list parameters are passed + * // with default values. + * if((dataset = H5Dcreate (file, DATASET_NAME, datatype, dataspace, H5P_DEFAULT, + * dset_create_props, H5P_DEFAULT)) < 0) { + * printf("Error: fail to create dataset\n"); + * return -1; + * } + * + * // Write the array to the file. The datatype and dataspace + * // describe the format of the data in the 'orig_data' buffer. + * // We use default raw data transfer properties. + * if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) { + * printf("Error: fail to write to dataset\n"); + * return -1; + * } + * + * H5Dclose (dataset); + * + * if((dataset = H5Dopen(file, DATASET_NAME, H5P_DEFAULT)) < 0) { + * printf("Error: fail to open dataset\n"); + * return -1; + * } + * + * // Read the array. This is similar to writing data, + * // except the data flows in the opposite direction. + * // Note: Decompression is automatic. + * if(H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) { + * printf("Error: fail to read from dataset\n"); + * return -1; + * } + * + * H5Tclose (datatype); + * H5Dclose (dataset); + * H5Sclose (dataspace); + * H5Pclose (dset_create_props); + * H5Fclose (file); + * + * return 0; + * } + * \endcode + * + * The following code example illustrates the use of the scale-offset filter (set for variable + * minimum-bits method) for writing and reading floating-point data. + * + * Scale-offset compression floating-point data + * \code + * #include "hdf5.h" + * #include "stdlib.h" + * + * #define H5FILE_NAME "scaleoffset_test_float_Dscale.h5" + * #define DATASET_NAME "scaleoffset_float_Dscale" + * #define NX 200 + * #define NY 300 + * #define CH_NX 10 + * #define CH_NY 15 + * + * int main(void) + * { + * hid_t file, dataspace, dataset, datatype, dset_create_props; + * hsize_t dims[2], chunk_size[2]; + * float orig_data[NX][NY]; + * float new_data[NX][NY]; + * float fill_val; + * int i, j; + * + * // Define dataset datatype + * datatype = H5Tcopy(H5T_NATIVE_FLOAT); + * + * // Initialize data buffer + * for (i=0; i < NX; i++) + * for (j=0; j < NY; j++) + * orig_data[i][j] = (rand() % 10000) / 1000.0; + * + * // Describe the size of the array. + * dims[0] = NX; + * dims[1] = NY; + * if((dataspace = H5Screate_simple (2, dims, NULL)) < 0) { + * printf("Error: fail to create dataspace\n"); + * return -1; + * } + * + * // Create a new file using read/write access, default file + * // creation properties, and default file access properties. + * if((file = H5Fcreate (H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + * printf("Error: fail to create file\n"); + * return -1; + * } + * + * // Set the dataset creation property list to specify that + * // the raw data is to be partitioned into 10 x 15 element + * // chunks and that each chunk is to be compressed. + * chunk_size[0] = CH_NX; + * chunk_size[1] = CH_NY; + * if((dset_create_props = H5Pcreate (H5P_DATASET_CREATE)) < 0) { + * printf("Error: fail to create dataset property\n"); + * return -1; + * } + * if(H5Pset_chunk (dset_create_props, 2, chunk_size) < 0) { + * printf("Error: fail to set chunk\n"); + * return -1; + * } + * + * // Set the fill value of dataset + * fill_val = 10000.0; + * if (H5Pset_fill_value(dset_create_props, H5T_NATIVE_FLOAT, &fill_val) < 0) { + * printf("Error: can not set fill value for dataset\n"); + * return -1; + * } + * + * // Set parameters for scale-offset compression; use variable + * // minimum-bits method, set decimal scale factor to 3. Check + * // the description of the H5Pset_scaleoffset function in the + * // HDF5 Reference Manual for more information. + * if(H5Pset_scaleoffset (dset_create_props, H5Z_SO_FLOAT_DSCALE, 3) < 0) { + * printf("Error: fail to set scaleoffset filter\n"); + * return -1; + * } + * + * // Create a new dataset within the file. The datatype + * // and dataspace describe the data on disk, which may + * // or may not be different from the format used in the + * // application's memory. + * if((dataset = H5Dcreate (file, DATASET_NAME, datatype, dataspace, H5P_DEFAULT, + * dset_create_props, H5P_DEFAULT)) < 0) { + * printf("Error: fail to create dataset\n"); + * return -1; + * } + * + * // Write the array to the file. The datatype and dataspace + * // describe the format of the data in the 'orig_data' buffer. + * // We use default raw data transfer properties. + * if(H5Dwrite (dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig_data) < 0) { + * printf("Error: fail to write to dataset\n"); + * return -1; + * } + * + * H5Dclose (dataset); + * + * if((dataset = H5Dopen(file, DATASET_NAME, H5P_DEFAULT)) < 0) { + * printf("Error: fail to open dataset\n"); + * return -1; + * } + * + * // Read the array. This is similar to writing data, + * // except the data flows in the opposite direction. + * // Note: Decompression is automatic. + * if(H5Dread (dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, new_data) < 0) { + * printf("Error: fail to read from dataset\n"); + * return -1; + * } + * + * H5Tclose (datatype); + * H5Dclose (dataset); + * H5Sclose (dataspace); + * H5Pclose (dset_create_props); + * H5Fclose (file); + * + * return 0; + * } + * \endcode + * + *

Limitations

+ * For floating-point data handling, there are some algorithmic limitations to the GRiB data packing + * mechanism: + *
  1. + * Both the E-scaling and D-scaling methods are lossy compression + *
  2. + *
  3. + * For the D-scaling method, since data values have been rounded to integer values (positive) + * before truncating to the minimum-bits, their range is limited by the maximum value that can be + * represented by the corresponding unsigned integer type (the same size as that of the floating- + * point type) + *
+ * + *

Suggestions

+ * The following are some suggestions for using the filter for floating-point data: + *
  1. + * It is better to convert the units of data so that the units are within certain common range (for + * example, 1200m to 1.2km) + *
  2. + *
  3. + * If data values to be compressed are very near to zero, it is strongly recommended that the + * user sets the fill value away from zero (for example, a large positive number); if the user does + * nothing, the HDF5 library will set the fill value to zero, and this may cause undesirable + * compression results + *
  4. + *
  5. + * Users are not encouraged to use a very large decimal scale factor (for example, 100) for the + * D-scaling method; this can cause the filter not to ignore the fill value when finding maximum + * and minimum values, and they will get a much larger minimum-bits (poor compression) + *
+ * + * \subsubsection subsubsec_dataset_filters_szip Using the Szip Filter + * See The HDF Group website for further information regarding the Szip filter. + * + * Previous Chapter \ref sec_group - Next Chapter \ref sec_datatype + * + */ + +/** + * \defgroup H5D Datasets (H5D) * * Use the functions in this module to manage HDF5 datasets, including the * transfer of data between memory and disk and the description of dataset @@ -44,18 +2703,18 @@ * CreateRead * * - * \snippet H5D_examples.c create + * \snippet{lineno} H5D_examples.c create * * - * \snippet H5D_examples.c read + * \snippet{lineno} H5D_examples.c read * * UpdateDelete * * - * \snippet H5D_examples.c update + * \snippet{lineno} H5D_examples.c update * * - * \snippet H5D_examples.c delete + * \snippet{lineno} H5D_examples.c delete * * * diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 752c144f623..db4fd625087 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -36,6 +35,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ @@ -81,9 +81,54 @@ /* Macros to represent the regularity of the selection for multiple chunk IO case. */ #define H5D_CHUNK_SELECT_REG 1 +/* + * Threshold value for redistributing shared filtered chunks + * on all MPI ranks, or just MPI rank 0 + */ +#define H5D_CHUNK_REDISTRIBUTE_THRES ((size_t)((25 * H5_MB) / sizeof(H5D_chunk_redistribute_info_t))) + +/* + * Initial allocation size for the arrays that hold + * buffers for chunk modification data that is sent + * to other ranks and the MPI_Request objects for + * those send operations + */ +#define H5D_CHUNK_NUM_SEND_MSGS_INIT 64 + +/* + * Define a tag value for the MPI messages sent/received for + * chunk modification data + */ +#define H5D_CHUNK_MOD_DATA_TAG 64 + +/* + * Macro to initialize a H5D_chk_idx_info_t + * structure, given a pointer to a H5D_io_info_t + * structure + */ +#define H5D_MPIO_INIT_CHUNK_IDX_INFO(index_info, io_info_ptr) \ + do { \ + index_info.f = (io_info_ptr)->dset->oloc.file; \ + index_info.pline = &((io_info_ptr)->dset->shared->dcpl_cache.pline); \ + index_info.layout = &((io_info_ptr)->dset->shared->layout.u.chunk); \ + index_info.storage = &((io_info_ptr)->dset->shared->layout.storage.u.chunk); \ + } while (0) + +/* + * Macro to initialize a H5D_chunk_ud_t structure + * given a pointer to a H5D_chk_idx_info_t structure + */ +#define H5D_MPIO_INIT_CHUNK_UD_INFO(chunk_ud, index_info_ptr) \ + do { \ + HDmemset(&chunk_ud, 0, sizeof(H5D_chunk_ud_t)); \ + chunk_ud.common.layout = (index_info_ptr)->layout; \ + chunk_ud.common.storage = (index_info_ptr)->storage; \ + } while (0) + /******************/ /* Local Typedefs */ /******************/ + /* Combine chunk address and chunk info into a struct for better performance. */ typedef struct H5D_chunk_addr_info_t { haddr_t chunk_addr; @@ -99,167 +144,237 @@ typedef enum H5D_mpio_no_rank0_bcast_cause_t { H5D_MPIO_RANK0_GREATER_THAN_2GB = 0x08 } H5D_mpio_no_rank0_bcast_cause_t; +/* + * Information necessary for re-allocating file space for a chunk + * during a parallel write of a chunked dataset with filters + * applied. + */ +typedef struct H5D_chunk_alloc_info_t { + H5F_block_t chunk_current; + H5F_block_t chunk_new; + hsize_t chunk_idx; +} H5D_chunk_alloc_info_t; + +/* + * Information for a chunk pertaining to the dataset's chunk + * index entry for the chunk + */ +typedef struct H5D_chunk_index_info_t { + hsize_t chunk_idx; + unsigned filter_mask; + hbool_t need_insert; +} H5D_chunk_index_info_t; + /* * Information about a single chunk when performing collective filtered I/O. All * of the fields of one of these structs are initialized at the start of collective - * filtered I/O in the function H5D__construct_filtered_io_info_list(). - * - * This struct's fields are as follows: - * - * index - The "Index" of the chunk in the dataset. The index of a chunk is used during - * the collective re-insertion of chunks into the chunk index after the collective - * I/O has been performed. + * filtered I/O in the function H5D__mpio_collective_filtered_chunk_io_setup(). This + * struct's fields are as follows: * - * scaled - The scaled coordinates of the chunk in the dataset's file dataspace. The - * coordinates are used in both the collective re-allocation of space in the file - * and the collective re-insertion of chunks into the chunk index after the collective - * I/O has been performed. + * index_info - A structure containing the information needed when collectively + * re-inserting the chunk into the dataset's chunk index. The structure + * is distributed to all ranks during the re-insertion operation. Its fields + * are as follows: * - * full_overwrite - A flag which determines whether or not a chunk needs to be read from the - * file when being updated. If a chunk is being fully overwritten (the entire - * extent is selected in its file dataspace), then it is not necessary to - * read the chunk from the file. However, if the chunk is not being fully - * overwritten, it has to be read from the file in order to update the chunk - * without trashing the parts of the chunk that are not selected. + * chunk_idx - The index of the chunk in the dataset's chunk index. * - * num_writers - The total number of processors writing to this chunk. This field is used - * when the new owner of a chunk is receiving messages, which contain selections in - * the chunk and data to update the chunk with, from other processors which have this - * chunk selected in the I/O operation. The new owner must know how many processors it - * should expect messages from so that it can post an equal number of receive calls. + * filter_mask - A bit-mask that indicates which filters are to be applied to the + * chunk. Each filter in a chunk's filter pipeline has a bit position + * that can be masked to disable that particular filter for the chunk. + * This filter mask is saved alongside the chunk in the file. * - * io_size - The total size of I/O to this chunk. This field is an accumulation of the size of - * I/O to the chunk from each processor which has the chunk selected and is used to - * determine the value for the previous full_overwrite flag. + * need_insert - A flag which determines whether or not a chunk needs to be re-inserted into + * the chunk index after the write operation. * - * buf - A pointer which serves the dual purpose of holding either the chunk data which is to be - * written to the file or the chunk data which has been read from the file. + * chunk_info - A pointer to the chunk's H5D_chunk_info_t structure, which contains useful + * information like the dataspaces containing the selection in the chunk. * - * chunk_states - In the case of dataset writes only, this struct is used to track a chunk's size and - * address in the file before and after the filtering operation has occurred. + * chunk_current - The address in the file and size of this chunk before the filtering + * operation. When reading a chunk from the file, this field is used to + * read the correct amount of bytes. It is also used when redistributing + * shared chunks among MPI ranks and as a parameter to the chunk file + * space reallocation function. * - * Its fields are as follows: + * chunk_new - The address in the file and size of this chunk after the filtering + * operation. This field is relevant when collectively re-allocating space + * in the file for all of the chunks written to in the I/O operation, as + * their sizes may have changed after their data has been filtered. * - * chunk_current - The address in the file and size of this chunk before the filtering - * operation. When reading a chunk from the file, this field is used to - * read the correct amount of bytes. It is also used when redistributing - * shared chunks among processors and as a parameter to the chunk file - * space reallocation function. + * need_read - A flag which determines whether or not a chunk needs to be read from the + * file. During writes, if a chunk is being fully overwritten (the entire extent + * is selected in its file dataspace), then it is not necessary to read the chunk + * from the file. However, if the chunk is not being fully overwritten, it has to + * be read from the file in order to update the chunk without trashing the parts + * of the chunk that are not selected. During reads, this field should generally + * be true, but may be false if the chunk isn't allocated, for example. * - * new_chunk - The address in the file and size of this chunk after the filtering - * operation. This field is relevant when collectively re-allocating space - * in the file for all of the chunks written to in the I/O operation, as - * their sizes may have changed after their data has been filtered. + * skip_filter_pline - A flag which determines whether to skip calls to the filter pipeline + * for this chunk. This flag is mostly useful for correct handling of + * partial edge chunks when the "don't filter partial edge chunks" flag + * is set on the dataset's DCPL. * - * owners - In the case of dataset writes only, this struct is used to manage which single processor - * will ultimately write data out to the chunk. It allows the other processors to act according - * to the decision and send their selection in the chunk, as well as the data they wish - * to update the chunk with, to the processor which is writing to the chunk. + * io_size - The total size of I/O to this chunk. This field is an accumulation of the size of + * I/O to the chunk from each MPI rank which has the chunk selected and is used to + * determine the value for the previous `full_overwrite` flag. * - * Its fields are as follows: + * chunk_buf_size - The size in bytes of the data buffer allocated for the chunk * - * original_owner - The processor which originally had this chunk selected at the beginning of - * the collective filtered I/O operation. This field is currently used when - * redistributing shared chunks among processors. + * orig_owner - The MPI rank which originally had this chunk selected at the beginning of + * the collective filtered I/O operation. This field is currently used when + * redistributing shared chunks among MPI ranks. * - * new_owner - The processor which has been selected to perform the write to this chunk. + * new_owner - The MPI rank which has been selected to perform the modifications to this chunk. * - * async_info - In the case of dataset writes only, this struct is used by the owning processor of the - * chunk in order to manage the MPI send and receive calls made between it and all of - * the other processors which have this chunk selected in the I/O operation. + * num_writers - The total number of MPI ranks writing to this chunk. This field is used when + * the new owner of a chunk is receiving messages from other MPI ranks that + * contain their selections in the chunk and the data to update the chunk with. + * The new owner must know how many MPI ranks it should expect messages from so + * that it can post an equal number of receive calls. * - * Its fields are as follows: + * buf - A pointer which serves the dual purpose of holding either the chunk data which is to be + * written to the file or the chunk data which has been read from the file. * - * receive_requests_array - An array containing one MPI_Request for each of the - * asynchronous MPI receive calls the owning processor of this - * chunk makes to another processor in order to receive that - * processor's chunk modification data and selection in the chunk. + * hh - A handle for hash tables provided by the uthash.h header * - * receive_buffer_array - An array of buffers into which the owning processor of this chunk - * will store chunk modification data and the selection in the chunk - * received from another processor. - * - * num_receive_requests - The number of entries in the receive_request_array and - * receive_buffer_array fields. */ typedef struct H5D_filtered_collective_io_info_t { - hsize_t index; - hsize_t scaled[H5O_LAYOUT_NDIMS]; - hbool_t full_overwrite; - size_t num_writers; - size_t io_size; - void * buf; - - struct { - H5F_block_t chunk_current; - H5F_block_t new_chunk; - } chunk_states; - - struct { - int original_owner; - int new_owner; - } owners; - - struct { - MPI_Request * receive_requests_array; - unsigned char **receive_buffer_array; - int num_receive_requests; - } async_info; + H5D_chunk_index_info_t index_info; + + H5D_chunk_info_t *chunk_info; + H5F_block_t chunk_current; + H5F_block_t chunk_new; + hbool_t need_read; + hbool_t skip_filter_pline; + size_t io_size; + size_t chunk_buf_size; + int orig_owner; + int new_owner; + int num_writers; + void *buf; + + UT_hash_handle hh; } H5D_filtered_collective_io_info_t; +/* + * Information necessary for redistributing shared chunks during + * a parallel write of a chunked dataset with filters applied. + */ +typedef struct H5D_chunk_redistribute_info_t { + H5F_block_t chunk_block; + hsize_t chunk_idx; + int orig_owner; + int new_owner; + int num_writers; +} H5D_chunk_redistribute_info_t; + +/* + * Information used when re-inserting a chunk into a dataset's + * chunk index during a parallel write of a chunked dataset with + * filters applied. + */ +typedef struct H5D_chunk_insert_info_t { + H5F_block_t chunk_block; + H5D_chunk_index_info_t index_info; +} H5D_chunk_insert_info_t; + /********************/ /* Local Prototypes */ /********************/ static herr_t H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); static herr_t H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm); -static herr_t H5D__multi_chunk_filtered_collective_io(H5D_io_info_t * io_info, - const H5D_type_info_t *type_info, H5D_chunk_map_t *fm); + H5D_chunk_map_t *fm, int mpi_rank, int mpi_size); +static herr_t H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, H5D_chunk_map_t *fm, + int mpi_rank, int mpi_size); static herr_t H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm, int sum_chunk); + H5D_chunk_map_t *fm, int sum_chunk, int mpi_rank, int mpi_size); static herr_t H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm); + H5D_chunk_map_t *fm, int mpi_rank, int mpi_size); static herr_t H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5S_t *file_space, const H5S_t *mem_space); + H5S_t *file_space, H5S_t *mem_space); static herr_t H5D__final_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, MPI_Datatype mpi_file_type, MPI_Datatype mpi_buf_type); static herr_t H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, - H5D_chunk_addr_info_t chunk_addr_info_array[], int many_chunk_opt); + H5D_chunk_addr_info_t chunk_addr_info_array[], int many_chunk_opt, int mpi_rank, + int mpi_size); static herr_t H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assign_io_mode[], - haddr_t chunk_addr[]); + haddr_t chunk_addr[], int mpi_rank, int mpi_size); static herr_t H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, int *sum_chunkf); -static herr_t H5D__construct_filtered_io_info_list(const H5D_io_info_t * io_info, - const H5D_type_info_t * type_info, - const H5D_chunk_map_t * fm, - H5D_filtered_collective_io_info_t **chunk_list, - size_t * num_entries); -#if MPI_VERSION >= 3 -static herr_t H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t * io_info, - const H5D_type_info_t * type_info, - const H5D_chunk_map_t * fm, - H5D_filtered_collective_io_info_t *local_chunk_array, - size_t *local_chunk_array_num_entries); -#endif -static herr_t H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, - size_t array_entry_size, void **gathered_array, - size_t *gathered_array_num_entries, hbool_t allgather, int root, - MPI_Comm comm, int (*sort_func)(const void *, const void *)); -static herr_t H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chunk_list, - size_t num_entries, MPI_Datatype *new_mem_type, - hbool_t *mem_type_derived, MPI_Datatype *new_file_type, - hbool_t *file_type_derived); -static herr_t H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk_entry, - const H5D_io_info_t * io_info, - const H5D_type_info_t * type_info, - const H5D_chunk_map_t * fm); +static herr_t H5D__mpio_collective_filtered_chunk_io_setup(const H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, + const H5D_chunk_map_t *fm, + H5D_filtered_collective_io_info_t **chunk_list, + size_t *num_entries, int mpi_rank); +static herr_t H5D__mpio_redistribute_shared_chunks(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, + const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, + int mpi_rank, int mpi_size, + size_t **rank_chunks_assigned_map); +static herr_t H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chunk_list, + size_t *num_chunks_assigned_map, + hbool_t all_ranks_involved, + const H5D_io_info_t *io_info, + const H5D_chunk_map_t *fm, int mpi_rank, int mpi_size); +static herr_t H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk_list, + size_t *chunk_list_num_entries, H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, int mpi_rank, + int mpi_size, + H5D_filtered_collective_io_info_t **chunk_hash_table, + unsigned char ***chunk_msg_bufs, + int *chunk_msg_bufs_len); +static herr_t H5D__mpio_collective_filtered_chunk_common_io(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, + const H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, int mpi_size); +static herr_t H5D__mpio_collective_filtered_chunk_read(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, + const H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, int mpi_rank, + int mpi_size); +static herr_t H5D__mpio_collective_filtered_chunk_update(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, + H5D_filtered_collective_io_info_t *chunk_hash_table, + unsigned char **chunk_msg_bufs, + int chunk_msg_bufs_len, const H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, int mpi_rank, + int mpi_size); +static herr_t H5D__mpio_collective_filtered_chunk_reallocate(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, + size_t *num_chunks_assigned_map, + H5D_io_info_t *io_info, + H5D_chk_idx_info_t *idx_info, int mpi_rank, + int mpi_size); +static herr_t H5D__mpio_collective_filtered_chunk_reinsert(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, + size_t *num_chunks_assigned_map, + H5D_io_info_t *io_info, + H5D_chk_idx_info_t *idx_info, int mpi_rank, + int mpi_size); +static herr_t H5D__mpio_get_chunk_redistribute_info_types(MPI_Datatype *contig_type, + hbool_t *contig_type_derived, + MPI_Datatype *resized_type, + hbool_t *resized_type_derived); +static herr_t H5D__mpio_get_chunk_alloc_info_types(MPI_Datatype *contig_type, hbool_t *contig_type_derived, + MPI_Datatype *resized_type, hbool_t *resized_type_derived); +static herr_t H5D__mpio_get_chunk_insert_info_types(MPI_Datatype *contig_type, hbool_t *contig_type_derived, + MPI_Datatype *resized_type, + hbool_t *resized_type_derived); +static herr_t H5D__mpio_collective_filtered_io_type(H5D_filtered_collective_io_info_t *chunk_list, + size_t num_entries, H5D_io_op_type_t op_type, + MPI_Datatype *new_mem_type, hbool_t *mem_type_derived, + MPI_Datatype *new_file_type, hbool_t *file_type_derived); static int H5D__cmp_chunk_addr(const void *chunk_addr_info1, const void *chunk_addr_info2); static int H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_info_entry1, const void *filtered_collective_io_info_entry2); -#if MPI_VERSION >= 3 -static int H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective_io_info_entry1, - const void *filtered_collective_io_info_entry2); +static int H5D__cmp_chunk_redistribute_info(const void *entry1, const void *entry2); +static int H5D__cmp_chunk_redistribute_info_orig_owner(const void *entry1, const void *entry2); + +#ifdef H5Dmpio_DEBUG +static herr_t H5D__mpio_debug_init(void); +static herr_t H5D__mpio_dump_collective_filtered_chunk_list(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, int mpi_rank); #endif /*********************/ @@ -270,6 +385,188 @@ static int H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered /* Local Variables */ /*******************/ +/* Declare extern free list to manage the H5S_sel_iter_t struct */ +H5FL_EXTERN(H5S_sel_iter_t); + +#ifdef H5Dmpio_DEBUG + +/* Flags to control debug actions in this file. + * (Meant to be indexed by characters) + * + * These flags can be set with either (or both) the environment variable + * "H5D_mpio_Debug" set to a string containing one or more characters + * (flags) or by setting them as a string value for the + * "H5D_mpio_debug_key" MPI Info key. + * + * Supported characters in 'H5D_mpio_Debug' string: + * 't' trace function entry and exit + * 'f' log to file rather than debugging stream + * 'm' show (rough) memory usage statistics + * 'c' show critical timing information + * + * To only show output from a particular MPI rank, specify its rank + * number as a character, e.g.: + * + * '0' only show output from rank 0 + * + * To only show output from a particular range (up to 8 ranks supported + * between 0-9) of MPI ranks, specify the start and end ranks separated + * by a hyphen, e.g.: + * + * '0-7' only show output from ranks 0 through 7 + * + */ +static int H5D_mpio_debug_flags_s[256]; +static int H5D_mpio_debug_rank_s[8] = {-1, -1, -1, -1, -1, -1, -1, -1}; +static hbool_t H5D_mpio_debug_inited = FALSE; +static const char *const trace_in_pre = "-> "; +static const char *const trace_out_pre = "<- "; +static int debug_indent = 0; +static FILE *debug_stream = NULL; + +/* Determine if this rank should output debugging info */ +#define H5D_MPIO_DEBUG_THIS_RANK(rank) \ + (H5D_mpio_debug_rank_s[0] < 0 || rank == H5D_mpio_debug_rank_s[0] || rank == H5D_mpio_debug_rank_s[1] || \ + rank == H5D_mpio_debug_rank_s[2] || rank == H5D_mpio_debug_rank_s[3] || \ + rank == H5D_mpio_debug_rank_s[4] || rank == H5D_mpio_debug_rank_s[5] || \ + rank == H5D_mpio_debug_rank_s[6] || rank == H5D_mpio_debug_rank_s[7]) + +/* Print some debugging string */ +#define H5D_MPIO_DEBUG(rank, string) \ + do { \ + if (debug_stream && H5D_MPIO_DEBUG_THIS_RANK(rank)) { \ + HDfprintf(debug_stream, "%*s(Rank %d) " string "\n", debug_indent, "", rank); \ + fflush(debug_stream); \ + } \ + } while (0) + +/* Print some debugging string with printf-style arguments */ +#define H5D_MPIO_DEBUG_VA(rank, string, ...) \ + do { \ + if (debug_stream && H5D_MPIO_DEBUG_THIS_RANK(rank)) { \ + HDfprintf(debug_stream, "%*s(Rank %d) " string "\n", debug_indent, "", rank, __VA_ARGS__); \ + fflush(debug_stream); \ + } \ + } while (0) + +#define H5D_MPIO_TRACE_ENTER(rank) \ + do { \ + hbool_t trace_flag = H5D_mpio_debug_flags_s[(int)'t']; \ + \ + if (trace_flag) { \ + H5D_MPIO_DEBUG_VA(rank, "%s%s", trace_in_pre, __func__); \ + debug_indent += (int)strlen(trace_in_pre); \ + } \ + } while (0) + +#define H5D_MPIO_TRACE_EXIT(rank) \ + do { \ + hbool_t trace_flag = H5D_mpio_debug_flags_s[(int)'t']; \ + \ + if (trace_flag) { \ + debug_indent -= (int)strlen(trace_out_pre); \ + H5D_MPIO_DEBUG_VA(rank, "%s%s", trace_out_pre, __func__); \ + } \ + } while (0) + +#define H5D_MPIO_TIME_START(rank, op_name) \ + { \ + hbool_t time_flag = H5D_mpio_debug_flags_s[(int)'c']; \ + double start_time = 0.0, end_time = 0.0; \ + const char *const op = op_name; \ + \ + if (time_flag) { \ + start_time = MPI_Wtime(); \ + } + +#define H5D_MPIO_TIME_STOP(rank) \ + if (time_flag) { \ + end_time = MPI_Wtime(); \ + H5D_MPIO_DEBUG_VA(rank, "'%s' took %f seconds", op, (end_time - start_time)); \ + } \ + } + +/*--------------------------------------------------------------------------- + * Function: H5D__mpio_parse_debug_str + * + * Purpose: Parse a string for H5Dmpio-related debugging flags + * + * Returns: N/A + * + *--------------------------------------------------------------------------- + */ +static void +H5D__mpio_parse_debug_str(const char *s) +{ + FUNC_ENTER_STATIC_NOERR + + HDassert(s); + + while (*s) { + int c = (int)(*s); + + if (c >= (int)'0' && c <= (int)'9') { + hbool_t range = FALSE; + + if (*(s + 1) && *(s + 2)) + range = (int)*(s + 1) == '-' && (int)*(s + 2) >= (int)'0' && (int)*(s + 2) <= (int)'9'; + + if (range) { + int start_rank = c - (int)'0'; + int end_rank = (int)*(s + 2) - '0'; + int num_ranks = end_rank - start_rank + 1; + int i; + + if (num_ranks > 8) { + end_rank = start_rank + 7; + num_ranks = 8; + } + + for (i = 0; i < num_ranks; i++) + H5D_mpio_debug_rank_s[i] = start_rank++; + + s += 3; + } + else + H5D_mpio_debug_rank_s[0] = c - (int)'0'; + } + else + H5D_mpio_debug_flags_s[c]++; + + s++; + } + + FUNC_LEAVE_NOAPI_VOID +} + +static herr_t +H5D__mpio_debug_init(void) +{ + const char *debug_str; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC_NOERR + + HDassert(!H5D_mpio_debug_inited); + + /* Clear the debug flag buffer */ + HDmemset(H5D_mpio_debug_flags_s, 0, sizeof(H5D_mpio_debug_flags_s)); + + /* Retrieve and parse the H5Dmpio debug string */ + debug_str = HDgetenv("H5D_mpio_Debug"); + if (debug_str) + H5D__mpio_parse_debug_str(debug_str); + + if (H5DEBUG(D)) + debug_stream = H5DEBUG(D); + + H5D_mpio_debug_inited = TRUE; + + FUNC_LEAVE_NOAPI(ret_value) +} + +#endif + /*------------------------------------------------------------------------- * Function: H5D__mpio_opt_possible * @@ -344,14 +641,9 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, co * use collective IO will defer until each chunk IO is reached. */ -#if MPI_VERSION < 3 - /* - * Don't allow parallel writes to filtered datasets if the MPI version - * is less than 3. The functions needed (MPI_Mprobe and MPI_Imrecv) will - * not be available. - */ - if (io_info->op_type == H5D_IO_OP_WRITE && io_info->dset->shared->layout.type == H5D_CHUNKED && - io_info->dset->shared->dcpl_cache.pline.nused > 0) +#ifndef H5_HAVE_PARALLEL_FILTERED_WRITES + /* Don't allow writes to filtered datasets if the functionality is disabled */ + if (io_info->op_type == H5D_IO_OP_WRITE && io_info->dset->shared->dcpl_cache.pline.nused > 0) local_cause[0] |= H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED; #endif @@ -362,7 +654,7 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, co /* Check to see if the process is reading the entire dataset */ if (H5S_GET_SELECT_TYPE(file_space) != H5S_SEL_ALL) local_cause[1] |= H5D_MPIO_RANK0_NOT_H5S_ALL; - /* Only perform this optimization for contigous datasets, currently */ + /* Only perform this optimization for contiguous datasets, currently */ else if (H5D_CONTIGUOUS != io_info->dset->shared->layout.type) /* Flag to do a MPI_Bcast of the data from one proc instead of * having all the processes involved in the collective I/O. @@ -433,6 +725,150 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, co FUNC_LEAVE_NOAPI(ret_value) } /* H5D__mpio_opt_possible() */ +/*------------------------------------------------------------------------- + * Function: H5D__mpio_get_no_coll_cause_strings + * + * Purpose: When collective I/O is broken internally, it can be useful + * for users to see a representative string for the reason(s) + * why it was broken. This routine inspects the current + * "cause" flags from the API context and prints strings into + * the caller's buffers for the local and global reasons that + * collective I/O was broken. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5D__mpio_get_no_coll_cause_strings(char *local_cause, size_t local_cause_len, char *global_cause, + size_t global_cause_len) +{ + uint32_t local_no_coll_cause; + uint32_t global_no_coll_cause; + size_t local_cause_bytes_written = 0; + size_t global_cause_bytes_written = 0; + int nbits; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE + + HDassert((local_cause && local_cause_len > 0) || (global_cause && global_cause_len > 0)); + + /* + * Use compile-time assertion so this routine is updated + * when any new "no collective cause" values are added + */ + HDcompile_assert(H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE == (H5D_mpio_no_collective_cause_t)256); + + /* Initialize output buffers */ + if (local_cause) + *local_cause = '\0'; + if (global_cause) + *global_cause = '\0'; + + /* Retrieve the local and global cause flags from the API context */ + if (H5CX_get_mpio_local_no_coll_cause(&local_no_coll_cause) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "unable to get local no collective cause value") + if (H5CX_get_mpio_global_no_coll_cause(&global_no_coll_cause) < 0) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "unable to get global no collective cause value") + + /* + * Append each of the "reason for breaking collective I/O" + * error messages to the local and global cause string buffers + */ + nbits = 8 * sizeof(local_no_coll_cause); + for (int bit_pos = 0; bit_pos < nbits; bit_pos++) { + H5D_mpio_no_collective_cause_t cur_cause; + const char *cause_str; + size_t buf_space_left; + + cur_cause = (H5D_mpio_no_collective_cause_t)(1 << bit_pos); + if (cur_cause == H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE) + break; + + switch (cur_cause) { + case H5D_MPIO_SET_INDEPENDENT: + cause_str = "independent I/O was requested"; + break; + case H5D_MPIO_DATATYPE_CONVERSION: + cause_str = "datatype conversions were required"; + break; + case H5D_MPIO_DATA_TRANSFORMS: + cause_str = "data transforms needed to be applied"; + break; + case H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED: + cause_str = "optimized MPI types flag wasn't set"; + break; + case H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES: + cause_str = "one of the dataspaces was neither simple nor scalar"; + break; + case H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET: + cause_str = "dataset was not contiguous or chunked"; + break; + case H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED: + cause_str = "parallel writes to filtered datasets are disabled"; + break; + case H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE: + cause_str = "an error occurred while checking if collective I/O was possible"; + break; + case H5D_MPIO_COLLECTIVE: + case H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE: + default: + HDassert(0 && "invalid no collective cause reason"); + break; + } + + /* + * Determine if the local reasons for breaking collective I/O + * included the current cause + */ + if (local_cause && (cur_cause & local_no_coll_cause)) { + buf_space_left = local_cause_len - local_cause_bytes_written; + + /* + * Check if there were any previous error messages included. If + * so, prepend a semicolon to separate the messages. + */ + if (buf_space_left && local_cause_bytes_written) { + HDstrncat(local_cause, "; ", buf_space_left); + local_cause_bytes_written += MIN(buf_space_left, 2); + buf_space_left -= MIN(buf_space_left, 2); + } + + if (buf_space_left) { + HDstrncat(local_cause, cause_str, buf_space_left); + local_cause_bytes_written += MIN(buf_space_left, HDstrlen(cause_str)); + } + } + + /* + * Determine if the global reasons for breaking collective I/O + * included the current cause + */ + if (global_cause && (cur_cause & global_no_coll_cause)) { + buf_space_left = global_cause_len - global_cause_bytes_written; + + /* + * Check if there were any previous error messages included. If + * so, prepend a semicolon to separate the messages. + */ + if (buf_space_left && global_cause_bytes_written) { + HDstrncat(global_cause, "; ", buf_space_left); + global_cause_bytes_written += MIN(buf_space_left, 2); + buf_space_left -= MIN(buf_space_left, 2); + } + + if (buf_space_left) { + HDstrncat(global_cause, cause_str, buf_space_left); + global_cause_bytes_written += MIN(buf_space_left, HDstrlen(cause_str)); + } + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_get_no_coll_cause_strings() */ + /*------------------------------------------------------------------------- * Function: H5D__mpio_select_read * @@ -446,8 +882,8 @@ H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, co */ herr_t H5D__mpio_select_read(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *type_info, - hsize_t mpi_buf_count, const H5S_t H5_ATTR_UNUSED *file_space, - const H5S_t H5_ATTR_UNUSED *mem_space) + hsize_t mpi_buf_count, H5S_t H5_ATTR_UNUSED *file_space, + H5S_t H5_ATTR_UNUSED *mem_space) { const H5D_contig_storage_t *store_contig = &(io_info->store->contig); /* Contiguous storage info for this I/O operation */ @@ -477,8 +913,8 @@ H5D__mpio_select_read(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATT */ herr_t H5D__mpio_select_write(const H5D_io_info_t *io_info, const H5D_type_info_t H5_ATTR_UNUSED *type_info, - hsize_t mpi_buf_count, const H5S_t H5_ATTR_UNUSED *file_space, - const H5S_t H5_ATTR_UNUSED *mem_space) + hsize_t mpi_buf_count, H5S_t H5_ATTR_UNUSED *file_space, + H5S_t H5_ATTR_UNUSED *mem_space) { const H5D_contig_storage_t *store_contig = &(io_info->store->contig); /* Contiguous storage info for this I/O operation */ @@ -496,145 +932,6 @@ H5D__mpio_select_write(const H5D_io_info_t *io_info, const H5D_type_info_t H5_AT FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__mpio_select_write() */ -/*------------------------------------------------------------------------- - * Function: H5D__mpio_array_gatherv - * - * Purpose: Given an array, specified in local_array, by each processor - * calling this function, collects each array into a single - * array which is then either gathered to the processor - * specified by root, when allgather is false, or is - * distributed back to all processors when allgather is true. - * - * The number of entries in the array contributed by an - * individual processor and the size of each entry should be - * specified in local_array_num_entries and array_entry_size, - * respectively. - * - * The MPI communicator to use should be specified for comm. - * - * If the sort_func argument is supplied, the array is sorted - * before the function returns. - * - * Note: if allgather is specified as true, root is ignored. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Jordan Henderson - * Sunday, April 9th, 2017 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5D__mpio_array_gatherv(void *local_array, size_t local_array_num_entries, size_t array_entry_size, - void **_gathered_array, size_t *_gathered_array_num_entries, hbool_t allgather, - int root, MPI_Comm comm, int (*sort_func)(const void *, const void *)) -{ - size_t gathered_array_num_entries = 0; /* The size of the newly-constructed array */ - void * gathered_array = NULL; /* The newly-constructed array returned to the caller */ - int *receive_counts_array = NULL; /* Array containing number of entries each processor is contributing */ - int *displacements_array = - NULL; /* Array of displacements where each processor places its data in the final array */ - int mpi_code, mpi_rank, mpi_size; - int sendcount; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_STATIC - - HDassert(_gathered_array); - HDassert(_gathered_array_num_entries); - - MPI_Comm_size(comm, &mpi_size); - MPI_Comm_rank(comm, &mpi_rank); - - /* Determine the size of the end result array by collecting the number - * of entries contributed by each processor into a single total. - */ - if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&local_array_num_entries, &gathered_array_num_entries, 1, - MPI_INT, MPI_SUM, comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) - - /* If 0 entries resulted from the collective operation, no processor is contributing anything and there is - * nothing to do */ - if (gathered_array_num_entries > 0) { - /* - * If gathering to all processors, all processors need to allocate space for the resulting array, as - * well as the receive counts and displacements arrays for the collective MPI_Allgatherv call. - * Otherwise, only the root processor needs to allocate the space for an MPI_Gatherv call. - */ - if (allgather || (mpi_rank == root)) { - if (NULL == (gathered_array = H5MM_malloc(gathered_array_num_entries * array_entry_size))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate gathered array") - - if (NULL == (receive_counts_array = (int *)H5MM_malloc((size_t)mpi_size * sizeof(int)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate receive counts array") - - if (NULL == (displacements_array = (int *)H5MM_malloc((size_t)mpi_size * sizeof(int)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate receive displacements array") - } /* end if */ - - /* - * If gathering to all processors, inform each processor of how many entries each other processor is - * contributing to the resulting array by collecting the counts into each processor's "receive counts" - * array. Otherwise, inform only the root processor of how many entries each other processor is - * contributing. - */ - if (allgather) { - if (MPI_SUCCESS != (mpi_code = MPI_Allgather(&local_array_num_entries, 1, MPI_INT, - receive_counts_array, 1, MPI_INT, comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Allgather failed", mpi_code) - } /* end if */ - else { - if (MPI_SUCCESS != (mpi_code = MPI_Gather(&local_array_num_entries, 1, MPI_INT, - receive_counts_array, 1, MPI_INT, root, comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Gather failed", mpi_code) - } /* end else */ - - if (allgather || (mpi_rank == root)) { - size_t i; - - /* Multiply each receive count by the size of the array entry, since the data is sent as bytes. */ - for (i = 0; i < (size_t)mpi_size; i++) - H5_CHECKED_ASSIGN(receive_counts_array[i], int, - (size_t)receive_counts_array[i] * array_entry_size, size_t); - - /* Set receive buffer offsets for the collective MPI_Allgatherv/MPI_Gatherv call. */ - displacements_array[0] = 0; - for (i = 1; i < (size_t)mpi_size; i++) - displacements_array[i] = displacements_array[i - 1] + receive_counts_array[i - 1]; - } /* end if */ - - /* As the data is sent as bytes, calculate the true sendcount for the data. */ - H5_CHECKED_ASSIGN(sendcount, int, local_array_num_entries *array_entry_size, size_t); - - if (allgather) { - if (MPI_SUCCESS != - (mpi_code = MPI_Allgatherv(local_array, sendcount, MPI_BYTE, gathered_array, - receive_counts_array, displacements_array, MPI_BYTE, comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Allgatherv failed", mpi_code) - } /* end if */ - else { - if (MPI_SUCCESS != - (mpi_code = MPI_Gatherv(local_array, sendcount, MPI_BYTE, gathered_array, - receive_counts_array, displacements_array, MPI_BYTE, root, comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Gatherv failed", mpi_code) - } /* end else */ - - if (sort_func && (allgather || (mpi_rank == root))) - HDqsort(gathered_array, gathered_array_num_entries, array_entry_size, sort_func); - } /* end if */ - - *_gathered_array = gathered_array; - *_gathered_array_num_entries = gathered_array_num_entries; - -done: - if (receive_counts_array) - H5MM_free(receive_counts_array); - if (displacements_array) - H5MM_free(displacements_array); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__mpio_array_gatherv() */ - /*------------------------------------------------------------------------- * Function: H5D__mpio_get_sum_chunk * @@ -687,7 +984,7 @@ H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, */ herr_t H5D__contig_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t *file_space, const H5S_t *mem_space, + hsize_t H5_ATTR_UNUSED nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { H5D_mpio_actual_io_mode_t actual_io_mode = H5D_MPIO_CONTIGUOUS_COLLECTIVE; @@ -726,7 +1023,7 @@ H5D__contig_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_ */ herr_t H5D__contig_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - hsize_t H5_ATTR_UNUSED nelmts, const H5S_t *file_space, const H5S_t *mem_space, + hsize_t H5_ATTR_UNUSED nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t H5_ATTR_UNUSED *fm) { H5D_mpio_actual_io_mode_t actual_io_mode = H5D_MPIO_CONTIGUOUS_COLLECTIVE; @@ -790,11 +1087,17 @@ static herr_t H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm) { H5FD_mpio_chunk_opt_t chunk_opt_mode; - int io_option = H5D_MULTI_CHUNK_IO_MORE_OPT; - int sum_chunk = -1; +#ifdef H5Dmpio_DEBUG + hbool_t log_file_flag = FALSE; + FILE *debug_log_file = NULL; +#endif #ifdef H5_HAVE_INSTRUMENTED_LIBRARY htri_t temp_not_link_io = FALSE; #endif + int io_option = H5D_MULTI_CHUNK_IO_MORE_OPT; + int sum_chunk = -1; + int mpi_rank; + int mpi_size; herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -805,9 +1108,35 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HDassert(type_info); HDassert(fm); - /* Disable collective metadata reads for chunked dataset I/O operations - * in order to prevent potential hangs */ - H5CX_set_coll_metadata_read(FALSE); + /* Obtain the current rank of the process and the number of ranks */ + if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) + HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain MPI rank") + if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) + HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain MPI size") + +#ifdef H5Dmpio_DEBUG + /* Initialize file-level debugging if not initialized */ + if (!H5D_mpio_debug_inited && H5D__mpio_debug_init() < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize H5Dmpio debugging") + + /* Open file for debugging if necessary */ + log_file_flag = H5D_mpio_debug_flags_s[(int)'f']; + if (log_file_flag) { + char debug_log_filename[1024]; + time_t time_now; + + HDsnprintf(debug_log_filename, 1024, "H5Dmpio_debug.rank%d", mpi_rank); + + if (NULL == (debug_log_file = HDfopen(debug_log_filename, "a"))) + HGOTO_ERROR(H5E_IO, H5E_OPENERROR, FAIL, "couldn't open debugging log file") + + /* Print a short header for this I/O operation */ + time_now = time(NULL); + HDfprintf(debug_log_file, "##### %s", asctime(localtime(&time_now))); + + debug_stream = debug_log_file; + } +#endif /* Check the optional property list for the collective chunk IO optimization option */ if (H5CX_get_mpio_chunk_opt_mode(&chunk_opt_mode) < 0) @@ -821,13 +1150,10 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf /* via default path. branch by num threshold */ else { unsigned one_link_chunk_io_threshold; /* Threshold to use single collective I/O for all chunks */ - int mpi_size; /* Number of processes in MPI job */ if (H5D__mpio_get_sum_chunk(io_info, fm, &sum_chunk) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSWAP, FAIL, "unable to obtain the total chunk number of all processes"); - if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") /* Get the chunk optimization option threshold */ if (H5CX_get_mpio_chunk_opt_num(&one_link_chunk_io_threshold) < 0) @@ -873,41 +1199,41 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf case H5D_ONE_LINK_CHUNK_IO_MORE_OPT: /* Check if there are any filters in the pipeline */ if (io_info->dset->shared->dcpl_cache.pline.nused > 0) { - /* For now, Multi-chunk IO must be forced for parallel filtered read, - * so that data can be unfiltered as it is received. There is significant - * complexity in unfiltering the data when it is read all at once into a - * single buffer. - */ - if (io_info->op_type == H5D_IO_OP_READ) { - if (H5D__multi_chunk_filtered_collective_io(io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, - "couldn't finish optimized multiple filtered chunk MPI-IO") - } /* end if */ - else if (H5D__link_chunk_filtered_collective_io(io_info, type_info, fm) < 0) + if (H5D__link_chunk_filtered_collective_io(io_info, type_info, fm, mpi_rank, mpi_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish filtered linked chunk MPI-IO") } /* end if */ else /* Perform unfiltered link chunk collective IO */ - if (H5D__link_chunk_collective_io(io_info, type_info, fm, sum_chunk) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish linked chunk MPI-IO") + if (H5D__link_chunk_collective_io(io_info, type_info, fm, sum_chunk, mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish linked chunk MPI-IO") break; case H5D_MULTI_CHUNK_IO: /* direct request to do multi-chunk IO */ default: /* multiple chunk IO via threshold */ /* Check if there are any filters in the pipeline */ if (io_info->dset->shared->dcpl_cache.pline.nused > 0) { - if (H5D__multi_chunk_filtered_collective_io(io_info, type_info, fm) < 0) + if (H5D__multi_chunk_filtered_collective_io(io_info, type_info, fm, mpi_rank, mpi_size) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple filtered chunk MPI-IO") } /* end if */ else /* Perform unfiltered multi chunk collective IO */ - if (H5D__multi_chunk_collective_io(io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple chunk MPI-IO") + if (H5D__multi_chunk_collective_io(io_info, type_info, fm, mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish optimized multiple chunk MPI-IO") break; } /* end switch */ done: +#ifdef H5Dmpio_DEBUG + /* Close debugging log file */ + if (debug_log_file) { + HDfprintf(debug_log_file, "##############\n\n"); + if (EOF == HDfclose(debug_log_file)) + HDONE_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "couldn't close debugging log file") + debug_stream = H5DEBUG(D); + } +#endif + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_collective_io */ @@ -926,8 +1252,8 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf */ herr_t H5D__chunk_collective_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) + hsize_t H5_ATTR_UNUSED nelmts, H5S_t H5_ATTR_UNUSED *file_space, + H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t *fm) { herr_t ret_value = SUCCEED; /* Return value */ @@ -956,8 +1282,8 @@ H5D__chunk_collective_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_i */ herr_t H5D__chunk_collective_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) + hsize_t H5_ATTR_UNUSED nelmts, H5S_t H5_ATTR_UNUSED *file_space, + H5S_t H5_ATTR_UNUSED *mem_space, H5D_chunk_map_t *fm) { herr_t ret_value = SUCCEED; /* Return value */ @@ -990,25 +1316,25 @@ H5D__chunk_collective_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_ */ static herr_t H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm, - int sum_chunk) + int sum_chunk, int mpi_rank, int mpi_size) { H5D_chunk_addr_info_t *chunk_addr_info_array = NULL; - MPI_Datatype chunk_final_mtype; /* Final memory MPI datatype for all chunks with seletion */ + MPI_Datatype chunk_final_mtype; /* Final memory MPI datatype for all chunks with selection */ hbool_t chunk_final_mtype_is_derived = FALSE; - MPI_Datatype chunk_final_ftype; /* Final file MPI datatype for all chunks with seletion */ + MPI_Datatype chunk_final_ftype; /* Final file MPI datatype for all chunks with selection */ hbool_t chunk_final_ftype_is_derived = FALSE; H5D_storage_t ctg_store; /* Storage info for "fake" contiguous dataset */ size_t total_chunks; - MPI_Datatype * chunk_mtype = NULL; - MPI_Datatype * chunk_ftype = NULL; - MPI_Aint * chunk_disp_array = NULL; - MPI_Aint * chunk_mem_disp_array = NULL; - hbool_t * chunk_mft_is_derived_array = + MPI_Datatype *chunk_mtype = NULL; + MPI_Datatype *chunk_ftype = NULL; + MPI_Aint *chunk_disp_array = NULL; + MPI_Aint *chunk_mem_disp_array = NULL; + hbool_t *chunk_mft_is_derived_array = NULL; /* Flags to indicate each chunk's MPI file datatype is derived */ hbool_t *chunk_mbt_is_derived_array = NULL; /* Flags to indicate each chunk's MPI memory datatype is derived */ - int * chunk_mpi_file_counts = NULL; /* Count of MPI file datatype for each chunk */ - int * chunk_mpi_mem_counts = NULL; /* Count of MPI memory datatype for each chunk */ + int *chunk_mpi_file_counts = NULL; /* Count of MPI file datatype for each chunk */ + int *chunk_mpi_mem_counts = NULL; /* Count of MPI memory datatype for each chunk */ int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; @@ -1037,8 +1363,8 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ */ if (total_chunks == 1) { H5SL_node_t *chunk_node; /* Pointer to chunk node for selection */ - H5S_t * fspace; /* Dataspace describing chunk & selection in it */ - H5S_t * mspace; /* Dataspace describing selection in memory corresponding to this chunk */ + H5S_t *fspace; /* Dataspace describing chunk & selection in it */ + H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ /* Check for this process having selection in this chunk */ chunk_node = H5SL_first(fm->sel_chunks); @@ -1071,9 +1397,8 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ /* Set up the base storage address for this chunk */ io_info->store = &ctg_store; -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before inter_collective_io for total chunk = 1 \n"); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG(mpi_rank, "before inter_collective_io for total chunk = 1"); #endif /* Perform I/O */ @@ -1089,9 +1414,8 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ num_chunk = H5SL_count(fm->sel_chunks); H5_CHECK_OVERFLOW(num_chunk, size_t, int); -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "total_chunks = %zu, num_chunk = %zu\n", total_chunks, num_chunk); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG_VA(mpi_rank, "total_chunks = %zu, num_chunk = %zu", total_chunks, num_chunk); #endif /* Set up MPI datatype for chunks selected */ @@ -1122,18 +1446,17 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file is derived datatype flags buffer") -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before sorting the chunk address \n"); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG(mpi_rank, "before sorting chunk addresses"); #endif + /* Sort the chunk address */ - if (H5D__sort_chunk(io_info, fm, chunk_addr_info_array, sum_chunk) < 0) + if (H5D__sort_chunk(io_info, fm, chunk_addr_info_array, sum_chunk, mpi_rank, mpi_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSWAP, FAIL, "unable to sort chunk address") ctg_store.contig.dset_addr = chunk_addr_info_array[0].chunk_addr; -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "after sorting the chunk address \n"); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG(mpi_rank, "after sorting chunk addresses"); #endif /* Obtain MPI derived datatype from all individual chunks */ @@ -1238,9 +1561,9 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ /* No chunks selected for this process */ mpi_buf_count = (hsize_t)0; } /* end else */ -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before coming to final collective IO\n"); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG(mpi_rank, "before coming to final collective I/O"); #endif /* Set up the base storage address for this chunk */ @@ -1253,11 +1576,11 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ } /* end else */ done: -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before freeing memory inside H5D_link_collective_io ret_value = %d\n", - ret_value); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG_VA(mpi_rank, "before freeing memory inside H5D_link_collective_io ret_value = %d", + ret_value); #endif + /* Release resources */ if (chunk_addr_info_array) H5MM_xfree(chunk_addr_info_array); @@ -1290,68 +1613,89 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ /*------------------------------------------------------------------------- * Function: H5D__link_chunk_filtered_collective_io * - * Purpose: Routine for one collective IO with one MPI derived datatype - * to link with all filtered chunks - * - * 1. Construct a list of selected chunks in the collective IO - * operation - * A. If any chunk is being written to by more than 1 - * process, the process writing to the chunk which - * currently has the least amount of chunks assigned - * to it becomes the new owner (in the case of ties, - * the lowest MPI rank becomes the new owner) - * 2. If the operation is a write operation - * A. Loop through each chunk in the operation - * I. If this is not a full overwrite of the chunk - * a) Read the chunk from file and pass the chunk - * through the filter pipeline in reverse order - * (Unfilter the chunk) + * Purpose: Performs collective I/O on filtered chunks by creating a + * single MPI derived datatype to link with all filtered + * chunks. The general algorithm is as follows: + * + * 1. Construct a list of selected chunks in the collective + * I/O operation + * 2. If the operation is a read operation + * A. Ensure that the list of chunks is sorted in + * monotonically non-decreasing order of chunk offset + * in the file + * B. Participate in a collective read of chunks from + * the file + * C. Loop through each selected chunk, unfiltering it and + * scattering the data to the application's read buffer + * 3. If the operation is a write operation + * A. Redistribute any chunks being written by more than 1 + * MPI rank, such that the chunk is only owned by 1 MPI + * rank. The rank writing to the chunk which currently + * has the least amount of chunks assigned to it becomes + * the new owner (in the case of ties, the lowest MPI + * rank becomes the new owner) + * B. Participate in a collective read of chunks from the + * file + * C. Loop through each chunk selected in the operation + * and for each chunk: + * I. If we actually read the chunk from the file (if + * a chunk is being fully overwritten, we skip + * reading it), pass the chunk through the filter + * pipeline in reverse order (unfilter the chunk) * II. Update the chunk data with the modifications from - * the owning process + * the owning MPI rank * III. Receive any modification data from other - * processes and update the chunk data with these + * ranks and update the chunk data with those * modifications * IV. Filter the chunk - * B. Contribute the modified chunks to an array gathered - * by all processes which contains the new sizes of - * every chunk modified in the collective IO operation - * C. All processes collectively re-allocate each chunk - * from the gathered array with their new sizes after - * the filter operation - * D. If this process has any chunks selected in the IO - * operation, create an MPI derived type for memory and - * file to write out the process' selected chunks to the - * file - * E. Perform the collective write - * F. All processes collectively re-insert each modified + * D. Contribute the modified chunks to an array gathered + * by all ranks which contains information for + * re-allocating space in the file for every chunk + * modified. Then, each rank collectively re-allocates + * each chunk from the gathered array with their new + * sizes after the filter operation + * E. Proceed with the collective write operation for all + * the modified chunks + * F. Contribute the modified chunks to an array gathered + * by all ranks which contains information for + * re-inserting every chunk modified into the chunk + * index. Then, each rank collectively re-inserts each * chunk from the gathered array into the chunk index * + * TODO: Note that steps D. and F. here are both collective + * operations that partially share data from the + * H5D_filtered_collective_io_info_t structure. To + * try to conserve on memory a bit, the distributed + * arrays these operations create are discarded after + * each operation is performed. If memory consumption + * here proves to not be an issue, the necessary data + * for both operations could be combined into a single + * structure so that only one collective MPI operation + * is needed to carry out both operations, rather than + * two. * * Return: Non-negative on success/Negative on failure * - * Programmer: Jordan Henderson - * Friday, Nov. 4th, 2016 - * *------------------------------------------------------------------------- */ static herr_t H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm) + H5D_chunk_map_t *fm, int mpi_rank, int mpi_size) { - H5D_filtered_collective_io_info_t *chunk_list = NULL; /* The list of chunks being read/written */ - H5D_filtered_collective_io_info_t *collective_chunk_list = - NULL; /* The list of chunks used during collective operations */ - H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ - MPI_Datatype mem_type = MPI_BYTE; - MPI_Datatype file_type = MPI_BYTE; - hbool_t mem_type_is_derived = FALSE; - hbool_t file_type_is_derived = FALSE; - size_t chunk_list_num_entries; - size_t collective_chunk_list_num_entries; - size_t * num_chunks_selected_array = NULL; /* Array of number of chunks selected on each process */ - size_t i; /* Local index variable */ - int mpi_rank, mpi_size, mpi_code; - herr_t ret_value = SUCCEED; + H5D_filtered_collective_io_info_t *chunk_list = NULL; /* The list of chunks being read/written */ + H5D_filtered_collective_io_info_t *chunk_hash_table = NULL; + unsigned char **chunk_msg_bufs = NULL; + H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ + MPI_Datatype mem_type = MPI_BYTE; + MPI_Datatype file_type = MPI_BYTE; + hbool_t mem_type_is_derived = FALSE; + hbool_t file_type_is_derived = FALSE; + size_t *rank_chunks_assigned_map = NULL; + size_t chunk_list_num_entries; + size_t i; + int chunk_msg_bufs_len = 0; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1359,11 +1703,12 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in HDassert(type_info); HDassert(fm); - /* Obtain the current rank of the process and the number of processes */ - if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi rank") - if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_DEBUG_VA(mpi_rank, "Performing Linked-chunk I/O (%s) with MPI Comm size of %d", + io_info->op_type == H5D_IO_OP_WRITE ? "write" : "read", mpi_size); + H5D_MPIO_TIME_START(mpi_rank, "Linked-chunk I/O"); +#endif /* Set the actual-chunk-opt-mode property. */ H5CX_set_mpio_actual_chunk_opt(H5D_MPIO_LINK_CHUNK); @@ -1374,123 +1719,127 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in H5CX_set_mpio_actual_io_mode(H5D_MPIO_CHUNK_COLLECTIVE); /* Build a list of selected chunks in the collective io operation */ - if (H5D__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < - 0) + if (H5D__mpio_collective_filtered_chunk_io_setup(io_info, type_info, fm, &chunk_list, + &chunk_list_num_entries, mpi_rank) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't construct filtered I/O info list") - if (io_info->op_type == H5D_IO_OP_WRITE) { /* Filtered collective write */ + if (io_info->op_type == H5D_IO_OP_READ) { /* Filtered collective read */ + if (H5D__mpio_collective_filtered_chunk_read(chunk_list, chunk_list_num_entries, io_info, type_info, + mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't read filtered chunks") + } + else { /* Filtered collective write */ H5D_chk_idx_info_t index_info; - H5D_chunk_ud_t udata; hsize_t mpi_buf_count; - /* Construct chunked index info */ - index_info.f = io_info->dset->oloc.file; - index_info.pline = &(io_info->dset->shared->dcpl_cache.pline); - index_info.layout = &(io_info->dset->shared->layout.u.chunk); - index_info.storage = &(io_info->dset->shared->layout.storage.u.chunk); - - /* Set up chunk information for insertion to chunk index */ - udata.common.layout = index_info.layout; - udata.common.storage = index_info.storage; - udata.filter_mask = 0; - - /* Iterate through all the chunks in the collective write operation, - * updating each chunk with the data modifications from other processes, - * then re-filtering the chunk. - */ - for (i = 0; i < chunk_list_num_entries; i++) - if (mpi_rank == chunk_list[i].owners.new_owner) - if (H5D__filtered_collective_chunk_entry_io(&chunk_list[i], io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't process chunk entry") - - /* Gather the new chunk sizes to all processes for a collective reallocation - * of the chunks in the file. + H5D_MPIO_INIT_CHUNK_IDX_INFO(index_info, io_info); + + if (mpi_size > 1) { + /* Redistribute shared chunks being written to */ + if (H5D__mpio_redistribute_shared_chunks(chunk_list, chunk_list_num_entries, io_info, fm, + mpi_rank, mpi_size, &rank_chunks_assigned_map) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to redistribute shared chunks") + + /* Send any chunk modification messages for chunks this rank no longer owns */ + if (H5D__mpio_share_chunk_modification_data(chunk_list, &chunk_list_num_entries, io_info, + type_info, mpi_rank, mpi_size, &chunk_hash_table, + &chunk_msg_bufs, &chunk_msg_bufs_len) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, + "unable to send chunk modification data between MPI ranks") + + /* Make sure the local chunk list was updated correctly */ + HDassert(chunk_list_num_entries == rank_chunks_assigned_map[mpi_rank]); + } + + /* Proceed to update all the chunks this rank owns with its own + * modification data and data from other ranks, before re-filtering + * the chunks. As chunk reads are done collectively here, all ranks + * must participate. */ - if (H5D__mpio_array_gatherv(chunk_list, chunk_list_num_entries, - sizeof(H5D_filtered_collective_io_info_t), - (void **)&collective_chunk_list, &collective_chunk_list_num_entries, true, - 0, io_info->comm, NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, "couldn't gather new chunk sizes") - - /* Collectively re-allocate the modified chunks (from each process) in the file */ - for (i = 0; i < collective_chunk_list_num_entries; i++) { - hbool_t insert; - - if (H5D__chunk_file_alloc(&index_info, &collective_chunk_list[i].chunk_states.chunk_current, - &collective_chunk_list[i].chunk_states.new_chunk, &insert, - collective_chunk_list[i].scaled) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") - } /* end for */ - - if (NULL == (num_chunks_selected_array = (size_t *)H5MM_malloc((size_t)mpi_size * sizeof(size_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate num chunks selected array") - - if (MPI_SUCCESS != - (mpi_code = MPI_Allgather(&chunk_list_num_entries, 1, MPI_UNSIGNED_LONG_LONG, - num_chunks_selected_array, 1, MPI_UNSIGNED_LONG_LONG, io_info->comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Allgather failed", mpi_code) - - /* If this process has any chunks selected, create a MPI type for collectively - * writing out the chunks to file. Otherwise, the process contributes to the + if (H5D__mpio_collective_filtered_chunk_update(chunk_list, chunk_list_num_entries, chunk_hash_table, + chunk_msg_bufs, chunk_msg_bufs_len, io_info, type_info, + mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't update modified chunks") + + /* Free up resources used by chunk hash table now that we're done updating chunks */ + HASH_CLEAR(hh, chunk_hash_table); + + /* All ranks now collectively re-allocate file space for all chunks */ + if (H5D__mpio_collective_filtered_chunk_reallocate(chunk_list, chunk_list_num_entries, + rank_chunks_assigned_map, io_info, &index_info, + mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, + "couldn't collectively re-allocate file space for chunks") + + /* If this rank has any chunks selected, create a MPI type for collectively + * writing out the chunks to file. Otherwise, the rank contributes to the * collective write with a none type. */ - if (chunk_list_num_entries) { - size_t offset; - - /* During the collective re-allocation of chunks in the file, the record for each - * chunk is only updated in the collective array, not in the local copy of chunks on each - * process. However, each process needs the updated chunk records so that they can create - * a MPI type for the collective write that will write to the chunk's possible new locations - * in the file instead of the old ones. This ugly hack seems to be the best solution to - * copy the information back to the local array and avoid having to modify the collective - * write type function in an ugly way so that it will accept the collective array instead - * of the local array. This works correctly because the array gather function guarantees - * that the chunk data in the collective array is ordered in blocks by rank. - */ - for (i = 0, offset = 0; i < (size_t)mpi_rank; i++) - offset += num_chunks_selected_array[i]; - - H5MM_memcpy(chunk_list, &collective_chunk_list[offset], - num_chunks_selected_array[mpi_rank] * sizeof(H5D_filtered_collective_io_info_t)); + if (H5D__mpio_collective_filtered_io_type(chunk_list, chunk_list_num_entries, io_info->op_type, + &mem_type, &mem_type_is_derived, &file_type, + &file_type_is_derived) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "couldn't create MPI type for writing filtered chunks") - /* Create single MPI type encompassing each selection in the dataspace */ - if (H5D__mpio_filtered_collective_write_type(chunk_list, chunk_list_num_entries, &mem_type, - &mem_type_is_derived, &file_type, - &file_type_is_derived) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "couldn't create MPI link chunk I/O type") + mpi_buf_count = (file_type_is_derived || mem_type_is_derived) ? 1 : 0; - /* Override the write buffer to point to the address of the first - * chunk data buffer + /* Setup contig storage info for I/O operation */ + if (chunk_list_num_entries) { + /* + * Override the write buffer to point to the first + * chunk's data buffer */ io_info->u.wbuf = chunk_list[0].buf; - } /* end if */ - /* We have a single, complicated MPI datatype for both memory & file */ - mpi_buf_count = (mem_type_is_derived && file_type_is_derived) ? (hsize_t)1 : (hsize_t)0; - - /* Set up the base storage address for this operation */ - ctg_store.contig.dset_addr = 0; /* Write address must be set to address 0 */ - io_info->store = &ctg_store; + /* + * Setup the base storage address for this operation + * to be the first chunk's file address + */ + ctg_store.contig.dset_addr = chunk_list[0].chunk_new.offset; + } + else + ctg_store.contig.dset_addr = 0; /* Perform I/O */ + io_info->store = &ctg_store; if (H5D__final_collective_io(io_info, type_info, mpi_buf_count, file_type, mem_type) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish MPI-IO") + /* Free up resources in anticipation of following collective operation */ + for (i = 0; i < chunk_list_num_entries; i++) { + if (chunk_list[i].buf) { + H5MM_free(chunk_list[i].buf); + chunk_list[i].buf = NULL; + } + } + /* Participate in the collective re-insertion of all chunks modified - * in this iteration into the chunk index + * into the chunk index */ - for (i = 0; i < collective_chunk_list_num_entries; i++) { - udata.chunk_block = collective_chunk_list[i].chunk_states.new_chunk; - udata.common.scaled = collective_chunk_list[i].scaled; - udata.chunk_idx = collective_chunk_list[i].index; - - if ((index_info.storage->ops->insert)(&index_info, &udata, io_info->dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk address into index") - } /* end for */ - } /* end if */ + if (H5D__mpio_collective_filtered_chunk_reinsert(chunk_list, chunk_list_num_entries, + rank_chunks_assigned_map, io_info, &index_info, + mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, + "couldn't collectively re-insert modified chunks into chunk index") + } done: - /* Free resources used by a process which had some selection */ + /* Free the MPI buf and file types, if they were derived */ + if (mem_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + if (file_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + + if (chunk_msg_bufs) { + for (i = 0; i < (size_t)chunk_msg_bufs_len; i++) + H5MM_free(chunk_msg_bufs[i]); + + H5MM_free(chunk_msg_bufs); + } + + HASH_CLEAR(hh, chunk_hash_table); + + /* Free resources used by a rank which had some selection */ if (chunk_list) { for (i = 0; i < chunk_list_num_entries; i++) if (chunk_list[i].buf) @@ -1499,16 +1848,13 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in H5MM_free(chunk_list); } /* end if */ - if (num_chunks_selected_array) - H5MM_free(num_chunks_selected_array); - if (collective_chunk_list) - H5MM_free(collective_chunk_list); + if (rank_chunks_assigned_map) + H5MM_free(rank_chunks_assigned_map); - /* Free the MPI buf and file types, if they were derived */ - if (mem_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) - HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - if (file_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) - HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__link_chunk_filtered_collective_io() */ @@ -1531,24 +1877,22 @@ H5D__link_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_in *------------------------------------------------------------------------- */ static herr_t -H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm) +H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5D_chunk_map_t *fm, + int mpi_rank, int mpi_size) { H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ H5D_io_info_t cpt_io_info; /* Compact I/O info object */ H5D_storage_t cpt_store; /* Chunk storage information as compact dataset */ hbool_t cpt_dirty; /* Temporary placeholder for compact storage "dirty" flag */ - uint8_t * chunk_io_option = NULL; - haddr_t * chunk_addr = NULL; + uint8_t *chunk_io_option = NULL; + haddr_t *chunk_addr = NULL; H5D_storage_t store; /* union of EFL and chunk pointer in file space */ H5FD_mpio_collective_opt_t last_coll_opt_mode = H5FD_MPIO_COLLECTIVE_IO; /* Last parallel transfer with independent IO or collective IO with this mode */ - size_t total_chunk; /* Total # of chunks in dataset */ -#ifdef H5Dmpio_DEBUG - int mpi_rank; -#endif - size_t u; /* Local index variable */ + size_t total_chunk; /* Total # of chunks in dataset */ + size_t u; /* Local index variable */ H5D_mpio_actual_io_mode_t actual_io_mode = H5D_MPIO_NO_COLLECTIVE; /* Local variable for tracking the I/O mode used. */ herr_t ret_value = SUCCEED; @@ -1558,10 +1902,6 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty /* Set the actual chunk opt mode property */ H5CX_set_mpio_actual_chunk_opt(H5D_MPIO_MULTI_CHUNK); -#ifdef H5Dmpio_DEBUG - mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file); -#endif - /* Retrieve total # of chunks in dataset */ H5_CHECKED_ASSIGN(total_chunk, size_t, fm->layout->u.chunk.nchunks, hsize_t); HDassert(total_chunk != 0); @@ -1569,13 +1909,13 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty /* Allocate memories */ chunk_io_option = (uint8_t *)H5MM_calloc(total_chunk); chunk_addr = (haddr_t *)H5MM_calloc(total_chunk * sizeof(haddr_t)); -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "total_chunk %zu\n", total_chunk); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG_VA(mpi_rank, "total_chunk %zu", total_chunk); #endif /* Obtain IO option for each chunk */ - if (H5D__obtain_mpio_mode(io_info, fm, chunk_io_option, chunk_addr) < 0) + if (H5D__obtain_mpio_mode(io_info, fm, chunk_io_option, chunk_addr, mpi_rank, mpi_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTRECV, FAIL, "unable to obtain MPIO mode") /* Set up contiguous I/O info object */ @@ -1600,12 +1940,11 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty /* Loop over _all_ the chunks */ for (u = 0; u < total_chunk; u++) { H5D_chunk_info_t *chunk_info; /* Chunk info for current chunk */ - H5S_t * fspace; /* Dataspace describing chunk & selection in it */ - H5S_t * mspace; /* Dataspace describing selection in memory corresponding to this chunk */ + H5S_t *fspace; /* Dataspace describing chunk & selection in it */ + H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "mpi_rank = %d, chunk index = %zu\n", mpi_rank, u); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG_VA(mpi_rank, "mpi_rank = %d, chunk index = %zu", mpi_rank, u); #endif /* Get the chunk info for this chunk, if there are elements selected */ chunk_info = fm->select_chunk[u]; @@ -1623,10 +1962,9 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty * needs to contribute MPI NONE TYPE. */ if (chunk_io_option[u] == H5D_CHUNK_IO_MODE_COL) { -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "inside collective chunk IO mpi_rank = %d, chunk index = %zu\n", - mpi_rank, u); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG_VA(mpi_rank, "inside collective chunk IO mpi_rank = %d, chunk index = %zu", + mpi_rank, u); #endif /* Set the file & memory dataspaces */ @@ -1662,10 +2000,9 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish shared collective MPI-IO") } /* end if */ else { /* possible independent IO for this chunk */ -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "inside independent IO mpi_rank = %d, chunk index = %zu\n", mpi_rank, - u); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG_VA(mpi_rank, "inside independent IO mpi_rank = %d, chunk index = %zu", mpi_rank, + u); #endif HDassert(chunk_io_option[u] == 0); @@ -1695,9 +2032,8 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty /* Perform the I/O */ if (H5D__inter_collective_io(&ctg_io_info, type_info, fspace, mspace) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish shared collective MPI-IO") -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "after inter collective IO\n"); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG(mpi_rank, "after inter collective IO"); #endif } /* end else */ } /* end for */ @@ -1717,80 +2053,101 @@ H5D__multi_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *ty /*------------------------------------------------------------------------- * Function: H5D__multi_chunk_filtered_collective_io * - * Purpose: To do filtered collective IO iteratively to save on memory. - * While link_chunk_filtered_collective_io will construct and - * work on a list of all of the chunks selected in the IO - * operation at once, this function works iteratively on a set - * of chunks at a time; at most one chunk per rank per - * iteration. - * - * 1. Construct a list of selected chunks in the collective IO - * operation - * A. If any chunk is being written to by more than 1 - * process, the process writing to the chunk which - * currently has the least amount of chunks assigned - * to it becomes the new owner (in the case of ties, - * the lowest MPI rank becomes the new owner) - * 2. If the operation is a read operation - * A. Loop through each chunk in the operation - * I. Read the chunk from the file - * II. Unfilter the chunk - * III. Scatter the read chunk data to the user's buffer - * 3. If the operation is a write operation - * A. Loop through each chunk in the operation - * I. If this is not a full overwrite of the chunk - * a) Read the chunk from file and pass the chunk - * through the filter pipeline in reverse order - * (Unfilter the chunk) - * II. Update the chunk data with the modifications from - * the owning process - * III. Receive any modification data from other - * processes and update the chunk data with these - * modifications - * IV. Filter the chunk - * V. Contribute the chunk to an array gathered by - * all processes which contains every chunk - * modified in this iteration (up to one chunk - * per process, some processes may not have a - * selection/may have less chunks to work on than - * other processes) - * VI. All processes collectively re-allocate each - * chunk from the gathered array with their new - * sizes after the filter operation - * VII. Proceed with the collective write operation - * for the chunks modified on this iteration - * VIII. All processes collectively re-insert each - * chunk from the gathered array into the chunk - * index + * Purpose: Performs collective I/O on filtered chunks iteratively to + * save on memory and potentially get better performance + * depending on the average number of chunks per rank. While + * linked-chunk I/O will construct and work on a list of all + * of the chunks selected in the I/O operation at once, this + * function works iteratively on a set of chunks at a time; at + * most one chunk per rank per iteration. The general + * algorithm is as follows: + * + * 1. Construct a list of selected chunks in the collective + * I/O operation + * 2. If the operation is a read operation, loop an amount of + * times equal to the maximum number of chunks selected on + * any particular rank and on each iteration: + * A. Participate in a collective read of chunks from + * the file (ranks that run out of chunks still need + * to participate) + * B. Unfilter the chunk that was read (if any) + * C. Scatter the read chunk's data to the application's + * read buffer + * 3. If the operation is a write operation, redistribute any + * chunks being written to by more than 1 MPI rank, such + * that the chunk is only owned by 1 MPI rank. The rank + * writing to the chunk which currently has the least + * amount of chunks assigned to it becomes the new owner + * (in the case of ties, the lowest MPI rank becomes the + * new owner). Then, loop an amount of times equal to the + * maximum number of chunks selected on any particular + * rank and on each iteration: + * A. Participate in a collective read of chunks from + * the file (ranks that run out of chunks still need + * to participate) + * I. If we actually read a chunk from the file (if + * a chunk is being fully overwritten, we skip + * reading it), pass the chunk through the filter + * pipeline in reverse order (unfilter the chunk) + * B. Update the chunk data with the modifications from + * the owning rank + * C. Receive any modification data from other ranks and + * update the chunk data with those modifications + * D. Filter the chunk + * E. Contribute the chunk to an array gathered by + * all ranks which contains information for + * re-allocating space in the file for every chunk + * modified in this iteration (up to one chunk per + * rank; some ranks may not have a selection/may have + * less chunks to work on than other ranks). Then, + * each rank collectively re-allocates each chunk + * from the gathered array with their new sizes + * after the filter operation + * F. Proceed with the collective write operation + * for the chunks modified on this iteration + * G. Contribute the chunk to an array gathered by + * all ranks which contains information for + * re-inserting every chunk modified on this + * iteration into the chunk index. Then, each rank + * collectively re-inserts each chunk from the + * gathered array into the chunk index + * + * TODO: Note that steps E. and G. here are both collective + * operations that partially share data from the + * H5D_filtered_collective_io_info_t structure. To + * try to conserve on memory a bit, the distributed + * arrays these operations create are discarded after + * each operation is performed. If memory consumption + * here proves to not be an issue, the necessary data + * for both operations could be combined into a single + * structure so that only one collective MPI operation + * is needed to carry out both operations, rather than + * two. * * Return: Non-negative on success/Negative on failure * - * Programmer: Jordan Henderson - * Friday, Dec. 2nd, 2016 - * *------------------------------------------------------------------------- */ static herr_t H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - H5D_chunk_map_t *fm) + H5D_chunk_map_t *fm, int mpi_rank, int mpi_size) { - H5D_filtered_collective_io_info_t *chunk_list = NULL; /* The list of chunks being read/written */ - H5D_filtered_collective_io_info_t *collective_chunk_list = - NULL; /* The list of chunks used during collective operations */ - H5D_storage_t store; /* union of EFL and chunk pointer in file space */ - H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ - H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ - MPI_Datatype *file_type_array = NULL; - MPI_Datatype *mem_type_array = NULL; - hbool_t * file_type_is_derived_array = NULL; - hbool_t * mem_type_is_derived_array = NULL; - hbool_t * has_chunk_selected_array = - NULL; /* Array of whether or not each process is contributing a chunk to each iteration */ - size_t chunk_list_num_entries; - size_t collective_chunk_list_num_entries; - size_t i, j; /* Local index variable */ - int mpi_rank, mpi_size, mpi_code; - herr_t ret_value = SUCCEED; + H5D_filtered_collective_io_info_t *chunk_list = NULL; /* The list of chunks being read/written */ + H5D_filtered_collective_io_info_t *chunk_hash_table = NULL; + unsigned char **chunk_msg_bufs = NULL; + H5D_io_info_t ctg_io_info; /* Contiguous I/O info object */ + H5D_storage_t ctg_store; /* Chunk storage information as contiguous dataset */ + MPI_Datatype mem_type = MPI_BYTE; + MPI_Datatype file_type = MPI_BYTE; + hbool_t mem_type_is_derived = FALSE; + hbool_t file_type_is_derived = FALSE; + hbool_t have_chunk_to_process; + size_t chunk_list_num_entries; + size_t i; + size_t max_num_chunks; + int chunk_msg_bufs_len = 0; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1798,11 +2155,12 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i HDassert(type_info); HDassert(fm); - /* Obtain the current rank of the process and the number of processes */ - if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi rank") - if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_DEBUG_VA(mpi_rank, "Performing Multi-chunk I/O (%s) with MPI Comm size of %d", + io_info->op_type == H5D_IO_OP_WRITE ? "write" : "read", mpi_size); + H5D_MPIO_TIME_START(mpi_rank, "Multi-chunk I/O"); +#endif /* Set the actual chunk opt mode property */ H5CX_set_mpio_actual_chunk_opt(H5D_MPIO_MULTI_CHUNK); @@ -1813,10 +2171,19 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i H5CX_set_mpio_actual_io_mode(H5D_MPIO_CHUNK_COLLECTIVE); /* Build a list of selected chunks in the collective IO operation */ - if (H5D__construct_filtered_io_info_list(io_info, type_info, fm, &chunk_list, &chunk_list_num_entries) < - 0) + if (H5D__mpio_collective_filtered_chunk_io_setup(io_info, type_info, fm, &chunk_list, + &chunk_list_num_entries, mpi_rank) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't construct filtered I/O info list") + /* Retrieve the maximum number of chunks selected for any rank */ + if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&chunk_list_num_entries, &max_num_chunks, 1, + MPI_UNSIGNED_LONG_LONG, MPI_MAX, io_info->comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) + + /* If no one has anything selected at all, end the operation */ + if (0 == max_num_chunks) + HGOTO_DONE(SUCCEED); + /* Set up contiguous I/O info object */ H5MM_memcpy(&ctg_io_info, io_info, sizeof(ctg_io_info)); ctg_io_info.store = &ctg_store; @@ -1824,190 +2191,147 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i /* Initialize temporary contiguous storage info */ ctg_store.contig.dset_size = (hsize_t)io_info->dset->shared->layout.u.chunk.size; - ctg_store.contig.dset_addr = 0; - - /* Set dataset storage for I/O info */ - io_info->store = &store; if (io_info->op_type == H5D_IO_OP_READ) { /* Filtered collective read */ - for (i = 0; i < chunk_list_num_entries; i++) - if (H5D__filtered_collective_chunk_entry_io(&chunk_list[i], io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't process chunk entry") - } /* end if */ + for (i = 0; i < max_num_chunks; i++) { + /* Check if this rank has a chunk to work on for this iteration */ + have_chunk_to_process = (i < chunk_list_num_entries); + + if (H5D__mpio_collective_filtered_chunk_read(have_chunk_to_process ? &chunk_list[i] : NULL, + have_chunk_to_process ? 1 : 0, io_info, type_info, + mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't read filtered chunks") + + if (have_chunk_to_process && chunk_list[i].buf) { + H5MM_free(chunk_list[i].buf); + chunk_list[i].buf = NULL; + } + } + } else { /* Filtered collective write */ H5D_chk_idx_info_t index_info; - H5D_chunk_ud_t udata; - size_t max_num_chunks; hsize_t mpi_buf_count; /* Construct chunked index info */ - index_info.f = io_info->dset->oloc.file; - index_info.pline = &(io_info->dset->shared->dcpl_cache.pline); - index_info.layout = &(io_info->dset->shared->layout.u.chunk); - index_info.storage = &(io_info->dset->shared->layout.storage.u.chunk); - - /* Set up chunk information for insertion to chunk index */ - udata.common.layout = index_info.layout; - udata.common.storage = index_info.storage; - udata.filter_mask = 0; - - /* Retrieve the maximum number of chunks being written among all processes */ - if (MPI_SUCCESS != (mpi_code = MPI_Allreduce(&chunk_list_num_entries, &max_num_chunks, 1, - MPI_UNSIGNED_LONG_LONG, MPI_MAX, io_info->comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Allreduce failed", mpi_code) - - /* If no one is writing anything at all, end the operation */ - if (!(max_num_chunks > 0)) - HGOTO_DONE(SUCCEED); - - /* Allocate arrays for storing MPI file and mem types and whether or not the - * types were derived. - */ - if (NULL == (file_type_array = (MPI_Datatype *)H5MM_malloc(max_num_chunks * sizeof(MPI_Datatype)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file type array") - - if (NULL == (file_type_is_derived_array = (hbool_t *)H5MM_calloc(max_num_chunks * sizeof(hbool_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file type is derived array") - - if (NULL == (mem_type_array = (MPI_Datatype *)H5MM_malloc(max_num_chunks * sizeof(MPI_Datatype)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate mem type array") - - if (NULL == (mem_type_is_derived_array = (hbool_t *)H5MM_calloc(max_num_chunks * sizeof(hbool_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate mem type is derived array") - - /* Iterate over the max number of chunks among all processes, as this process could - * have no chunks left to work on, but it still needs to participate in the collective - * re-allocation and re-insertion of chunks modified by other processes. + H5D_MPIO_INIT_CHUNK_IDX_INFO(index_info, io_info); + + if (mpi_size > 1) { + /* Redistribute shared chunks being written to */ + if (H5D__mpio_redistribute_shared_chunks(chunk_list, chunk_list_num_entries, io_info, fm, + mpi_rank, mpi_size, NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to redistribute shared chunks") + + /* Send any chunk modification messages for chunks this rank no longer owns */ + if (H5D__mpio_share_chunk_modification_data(chunk_list, &chunk_list_num_entries, io_info, + type_info, mpi_rank, mpi_size, &chunk_hash_table, + &chunk_msg_bufs, &chunk_msg_bufs_len) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, + "unable to send chunk modification data between MPI ranks") + } + + /* Iterate over the max number of chunks among all ranks, as this rank could + * have no chunks left to work on, but it still needs to participate in the + * collective re-allocation and re-insertion of chunks modified by other ranks. */ for (i = 0; i < max_num_chunks; i++) { - /* Check if this process has a chunk to work on for this iteration */ - hbool_t have_chunk_to_process = - (i < chunk_list_num_entries) && (mpi_rank == chunk_list[i].owners.new_owner); + /* Check if this rank has a chunk to work on for this iteration */ + have_chunk_to_process = (i < chunk_list_num_entries) && (mpi_rank == chunk_list[i].new_owner); - if (have_chunk_to_process) - if (H5D__filtered_collective_chunk_entry_io(&chunk_list[i], io_info, type_info, fm) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't process chunk entry") - - /* Gather the new chunk sizes to all processes for a collective re-allocation - * of the chunks in the file + /* Proceed to update the chunk this rank owns (if any left) with its + * own modification data and data from other ranks, before re-filtering + * the chunks. As chunk reads are done collectively here, all ranks + * must participate. */ - if (H5D__mpio_array_gatherv(&chunk_list[i], have_chunk_to_process ? 1 : 0, - sizeof(H5D_filtered_collective_io_info_t), - (void **)&collective_chunk_list, &collective_chunk_list_num_entries, - true, 0, io_info->comm, NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, "couldn't gather new chunk sizes") - - /* Participate in the collective re-allocation of all chunks modified - * in this iteration. + if (H5D__mpio_collective_filtered_chunk_update(have_chunk_to_process ? &chunk_list[i] : NULL, + have_chunk_to_process ? 1 : 0, chunk_hash_table, + chunk_msg_bufs, chunk_msg_bufs_len, io_info, + type_info, mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't update modified chunks") + + /* All ranks now collectively re-allocate file space for all chunks */ + if (H5D__mpio_collective_filtered_chunk_reallocate(have_chunk_to_process ? &chunk_list[i] : NULL, + have_chunk_to_process ? 1 : 0, NULL, io_info, + &index_info, mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, + "couldn't collectively re-allocate file space for chunks") + + /* + * If this rank has a chunk to work on, create a MPI type + * for writing out the chunk. Otherwise, the rank will + * use MPI_BYTE for the file and memory type and specify + * a count of 0. */ - for (j = 0; j < collective_chunk_list_num_entries; j++) { - hbool_t insert = FALSE; - - if (H5D__chunk_file_alloc(&index_info, &collective_chunk_list[j].chunk_states.chunk_current, - &collective_chunk_list[j].chunk_states.new_chunk, &insert, - chunk_list[j].scaled) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") - } /* end for */ - - if (NULL == - (has_chunk_selected_array = (hbool_t *)H5MM_malloc((size_t)mpi_size * sizeof(hbool_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate num chunks selected array") + if (H5D__mpio_collective_filtered_io_type( + have_chunk_to_process ? &chunk_list[i] : NULL, have_chunk_to_process ? 1 : 0, + io_info->op_type, &mem_type, &mem_type_is_derived, &file_type, &file_type_is_derived) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "couldn't create MPI type for writing filtered chunks") - if (MPI_SUCCESS != - (mpi_code = MPI_Allgather(&have_chunk_to_process, 1, MPI_C_BOOL, has_chunk_selected_array, 1, - MPI_C_BOOL, io_info->comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Allgather failed", mpi_code) + mpi_buf_count = (file_type_is_derived || mem_type_is_derived) ? 1 : 0; - /* If this process has a chunk to work on, create a MPI type for the - * memory and file for writing out the chunk - */ + /* Override the write buffer to point to the chunk data buffer */ if (have_chunk_to_process) { - size_t offset; - int mpi_type_count; - - for (j = 0, offset = 0; j < (size_t)mpi_rank; j++) - offset += has_chunk_selected_array[j]; - - /* Collect the new chunk info back to the local copy, since only the record in the - * collective array gets updated by the chunk re-allocation */ - H5MM_memcpy(&chunk_list[i].chunk_states.new_chunk, - &collective_chunk_list[offset].chunk_states.new_chunk, - sizeof(chunk_list[i].chunk_states.new_chunk)); - - H5_CHECKED_ASSIGN(mpi_type_count, int, chunk_list[i].chunk_states.new_chunk.length, hsize_t); - - /* Create MPI memory type for writing to chunk */ - if (MPI_SUCCESS != - (mpi_code = MPI_Type_contiguous(mpi_type_count, MPI_BYTE, &mem_type_array[i]))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&mem_type_array[i]))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - mem_type_is_derived_array[i] = TRUE; - - /* Create MPI file type for writing to chunk */ - if (MPI_SUCCESS != - (mpi_code = MPI_Type_contiguous(mpi_type_count, MPI_BYTE, &file_type_array[i]))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(&file_type_array[i]))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - file_type_is_derived_array[i] = TRUE; - - mpi_buf_count = 1; - - /* Set up the base storage address for this operation */ - ctg_store.contig.dset_addr = chunk_list[i].chunk_states.new_chunk.offset; - - /* Override the write buffer to point to the address of the - * chunk data buffer + /* + * Override the write buffer to point to the + * chunk's data buffer */ ctg_io_info.u.wbuf = chunk_list[i].buf; - } /* end if */ - else { - mem_type_array[i] = file_type_array[i] = MPI_BYTE; - mpi_buf_count = 0; - } /* end else */ + + /* + * Setup the base storage address for this + * operation to be the chunk's file address + */ + ctg_store.contig.dset_addr = chunk_list[i].chunk_new.offset; + } + else + ctg_store.contig.dset_addr = 0; /* Perform the I/O */ - if (H5D__final_collective_io(&ctg_io_info, type_info, mpi_buf_count, file_type_array[i], - mem_type_array[i]) < 0) + if (H5D__final_collective_io(&ctg_io_info, type_info, mpi_buf_count, file_type, mem_type) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't finish MPI-IO") + /* Free up resources in anticipation of following collective operation */ + if (have_chunk_to_process && chunk_list[i].buf) { + H5MM_free(chunk_list[i].buf); + chunk_list[i].buf = NULL; + } + /* Participate in the collective re-insertion of all chunks modified * in this iteration into the chunk index */ - for (j = 0; j < collective_chunk_list_num_entries; j++) { - udata.chunk_block = collective_chunk_list[j].chunk_states.new_chunk; - udata.common.scaled = collective_chunk_list[j].scaled; - udata.chunk_idx = collective_chunk_list[j].index; - - if ((index_info.storage->ops->insert)(&index_info, &udata, io_info->dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, - "unable to insert chunk address into index") - } /* end for */ + if (H5D__mpio_collective_filtered_chunk_reinsert(have_chunk_to_process ? &chunk_list[i] : NULL, + have_chunk_to_process ? 1 : 0, NULL, io_info, + &index_info, mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, + "couldn't collectively re-insert modified chunks into chunk index") + + /* Free the MPI types, if they were derived */ + if (mem_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + mem_type_is_derived = FALSE; + if (file_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + file_type_is_derived = FALSE; + } /* end for */ + } - if (collective_chunk_list) { - H5MM_free(collective_chunk_list); - collective_chunk_list = NULL; - } /* end if */ - if (has_chunk_selected_array) { - H5MM_free(has_chunk_selected_array); - has_chunk_selected_array = NULL; - } /* end if */ - } /* end for */ +done: + /* Free the MPI buf and file types, if they were derived */ + if (mem_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + if (file_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - /* Free the MPI file and memory types, if they were derived */ - for (i = 0; i < max_num_chunks; i++) { - if (file_type_is_derived_array[i]) - if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type_array[i]))) - HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + if (chunk_msg_bufs) { + for (i = 0; i < (size_t)chunk_msg_bufs_len; i++) + H5MM_free(chunk_msg_bufs[i]); - if (mem_type_is_derived_array[i]) - if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type_array[i]))) - HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) - } /* end for */ - } /* end else */ + H5MM_free(chunk_msg_bufs); + } -done: + HASH_CLEAR(hh, chunk_hash_table); + + /* Free resources used by a rank which had some selection */ if (chunk_list) { for (i = 0; i < chunk_list_num_entries; i++) if (chunk_list[i].buf) @@ -2016,16 +2340,10 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i H5MM_free(chunk_list); } /* end if */ - if (collective_chunk_list) - H5MM_free(collective_chunk_list); - if (file_type_array) - H5MM_free(file_type_array); - if (mem_type_array) - H5MM_free(mem_type_array); - if (file_type_is_derived_array) - H5MM_free(file_type_is_derived_array); - if (mem_type_is_derived_array) - H5MM_free(mem_type_is_derived_array); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__multi_chunk_filtered_collective_io() */ @@ -2044,18 +2362,29 @@ H5D__multi_chunk_filtered_collective_io(H5D_io_info_t *io_info, const H5D_type_i *------------------------------------------------------------------------- */ static herr_t -H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, const H5S_t *file_space, - const H5S_t *mem_space) +H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5S_t *file_space, + H5S_t *mem_space) { int mpi_buf_count; /* # of MPI types */ hbool_t mbt_is_derived = FALSE; hbool_t mft_is_derived = FALSE; MPI_Datatype mpi_file_type, mpi_buf_type; - int mpi_code; /* MPI return code */ - herr_t ret_value = SUCCEED; /* return value */ + int mpi_code; /* MPI return code */ +#ifdef H5Dmpio_DEBUG + int mpi_rank; +#endif + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC +#ifdef H5Dmpio_DEBUG + mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file); + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Inter collective I/O"); + if (mpi_rank < 0) + HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain MPI rank") +#endif + if ((file_space != NULL) && (mem_space != NULL)) { int mpi_file_count; /* Number of file "objects" to transfer */ hsize_t *permute_map = NULL; /* array that holds the mapping from the old, @@ -2114,9 +2443,8 @@ H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf mft_is_derived = FALSE; } /* end else */ -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before final collective IO \n"); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG(mpi_rank, "before final collective I/O"); #endif /* Perform final collective I/O operation */ @@ -2130,9 +2458,10 @@ H5D__inter_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf if (mft_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mpi_file_type))) HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before leaving inter_collective_io ret_value = %d\n", ret_value); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_DEBUG_VA(mpi_rank, "before leaving inter_collective_io ret_value = %d", ret_value); + H5D_MPIO_TRACE_EXIT(mpi_rank); #endif FUNC_LEAVE_NOAPI(ret_value) @@ -2154,10 +2483,21 @@ static herr_t H5D__final_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t mpi_buf_count, MPI_Datatype mpi_file_type, MPI_Datatype mpi_buf_type) { +#ifdef H5Dmpio_DEBUG + int mpi_rank; +#endif herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC +#ifdef H5Dmpio_DEBUG + mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file); + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Final collective I/O"); + if (mpi_rank < 0) + HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain MPI rank") +#endif + /* Pass buf type, file type to the file driver. */ if (H5CX_set_mpi_coll_datatypes(mpi_buf_type, mpi_file_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O collective I/O datatypes") @@ -2172,10 +2512,12 @@ H5D__final_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf } /* end else */ done: -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "ret_value before leaving final_collective_io=%d\n", ret_value); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_DEBUG_VA(mpi_rank, "ret_value before leaving final_collective_io=%d", ret_value); + H5D_MPIO_TRACE_EXIT(mpi_rank); #endif + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__final_collective_io */ @@ -2217,62 +2559,149 @@ H5D__cmp_chunk_addr(const void *chunk_addr_info1, const void *chunk_addr_info2) * * Return: -1, 0, 1 * - * Programmer: Jordan Henderson - * Wednesday, Nov. 30th, 2016 - * *------------------------------------------------------------------------- */ static int H5D__cmp_filtered_collective_io_info_entry(const void *filtered_collective_io_info_entry1, const void *filtered_collective_io_info_entry2) { - haddr_t addr1 = HADDR_UNDEF, addr2 = HADDR_UNDEF; + const H5D_filtered_collective_io_info_t *entry1; + const H5D_filtered_collective_io_info_t *entry2; + haddr_t addr1 = HADDR_UNDEF; + haddr_t addr2 = HADDR_UNDEF; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - addr1 = ((const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry1) - ->chunk_states.new_chunk.offset; - addr2 = ((const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry2) - ->chunk_states.new_chunk.offset; + entry1 = (const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry1; + entry2 = (const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry2; - FUNC_LEAVE_NOAPI(H5F_addr_cmp(addr1, addr2)) -} /* end H5D__cmp_filtered_collective_io_info_entry() */ + addr1 = entry1->chunk_new.offset; + addr2 = entry2->chunk_new.offset; -#if MPI_VERSION >= 3 + /* + * If both chunk addresses are defined, H5F_addr_cmp is safe to use. + * Otherwise, if both addresses aren't defined, compared chunk + * entries based on their chunk index. Finally, if only one chunk + * address is defined, return the appropriate value based on which + * is defined. + */ + if (H5F_addr_defined(addr1) && H5F_addr_defined(addr2)) { + ret_value = H5F_addr_cmp(addr1, addr2); + } + else if (!H5F_addr_defined(addr1) && !H5F_addr_defined(addr2)) { + hsize_t chunk_idx1 = entry1->index_info.chunk_idx; + hsize_t chunk_idx2 = entry2->index_info.chunk_idx; + + ret_value = (chunk_idx1 > chunk_idx2) - (chunk_idx1 < chunk_idx2); + } + else + ret_value = H5F_addr_defined(addr1) ? 1 : -1; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__cmp_filtered_collective_io_info_entry() */ /*------------------------------------------------------------------------- - * Function: H5D__cmp_filtered_collective_io_info_entry_owner + * Function: H5D__cmp_chunk_redistribute_info * - * Purpose: Routine to compare filtered collective chunk io info - * entries's original owner fields + * Purpose: Routine to compare two H5D_chunk_redistribute_info_t + * structures * - * Description: Callback for qsort() to compare filtered collective chunk - * io info entries's original owner fields + * Description: Callback for qsort() to compare two + * H5D_chunk_redistribute_info_t structures + * + * Return: -1, 0, 1 + * + *------------------------------------------------------------------------- + */ +static int +H5D__cmp_chunk_redistribute_info(const void *_entry1, const void *_entry2) +{ + const H5D_chunk_redistribute_info_t *entry1; + const H5D_chunk_redistribute_info_t *entry2; + hsize_t chunk_index1; + hsize_t chunk_index2; + int ret_value = 0; + + FUNC_ENTER_STATIC_NOERR + + entry1 = (const H5D_chunk_redistribute_info_t *)_entry1; + entry2 = (const H5D_chunk_redistribute_info_t *)_entry2; + + chunk_index1 = entry1->chunk_idx; + chunk_index2 = entry2->chunk_idx; + + if (chunk_index1 == chunk_index2) { + int orig_owner1 = entry1->orig_owner; + int orig_owner2 = entry2->orig_owner; + + ret_value = (orig_owner1 > orig_owner2) - (orig_owner1 < orig_owner2); + } + else + ret_value = (chunk_index1 > chunk_index2) - (chunk_index1 < chunk_index2); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__cmp_chunk_redistribute_info() */ + +/*------------------------------------------------------------------------- + * Function: H5D__cmp_chunk_redistribute_info_orig_owner * - * Return: The difference between the two - * H5D_filtered_collective_io_info_t's original owner fields + * Purpose: Routine to compare the original owning MPI rank for two + * H5D_chunk_redistribute_info_t structures * - * Programmer: Jordan Henderson - * Monday, Apr. 10th, 2017 + * Description: Callback for qsort() to compare the original owning MPI + * rank for two H5D_chunk_redistribute_info_t + * structures + * + * Return: -1, 0, 1 * *------------------------------------------------------------------------- */ static int -H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective_io_info_entry1, - const void *filtered_collective_io_info_entry2) +H5D__cmp_chunk_redistribute_info_orig_owner(const void *_entry1, const void *_entry2) { - int owner1 = -1, owner2 = -1; + const H5D_chunk_redistribute_info_t *entry1; + const H5D_chunk_redistribute_info_t *entry2; + int owner1 = -1; + int owner2 = -1; + int ret_value = 0; FUNC_ENTER_STATIC_NOERR - owner1 = ((const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry1) - ->owners.original_owner; - owner2 = ((const H5D_filtered_collective_io_info_t *)filtered_collective_io_info_entry2) - ->owners.original_owner; + entry1 = (const H5D_chunk_redistribute_info_t *)_entry1; + entry2 = (const H5D_chunk_redistribute_info_t *)_entry2; - FUNC_LEAVE_NOAPI(owner1 - owner2) -} /* end H5D__cmp_filtered_collective_io_info_entry_owner() */ -#endif + owner1 = entry1->orig_owner; + owner2 = entry2->orig_owner; + + if (owner1 == owner2) { + haddr_t addr1 = entry1->chunk_block.offset; + haddr_t addr2 = entry2->chunk_block.offset; + + /* + * If both chunk addresses are defined, H5F_addr_cmp is safe to use. + * Otherwise, if both addresses aren't defined, compared chunk + * entries based on their chunk index. Finally, if only one chunk + * address is defined, return the appropriate value based on which + * is defined. + */ + if (H5F_addr_defined(addr1) && H5F_addr_defined(addr2)) { + ret_value = H5F_addr_cmp(addr1, addr2); + } + else if (!H5F_addr_defined(addr1) && !H5F_addr_defined(addr2)) { + hsize_t chunk_idx1 = entry1->chunk_idx; + hsize_t chunk_idx2 = entry2->chunk_idx; + + ret_value = (chunk_idx1 > chunk_idx2) - (chunk_idx1 < chunk_idx2); + } + else + ret_value = H5F_addr_defined(addr1) ? 1 : -1; + } + else + ret_value = (owner1 > owner2) - (owner1 < owner2); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__cmp_chunk_redistribute_info_orig_owner() */ /*------------------------------------------------------------------------- * Function: H5D__sort_chunk @@ -2301,26 +2730,24 @@ H5D__cmp_filtered_collective_io_info_entry_owner(const void *filtered_collective */ static herr_t H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, - H5D_chunk_addr_info_t chunk_addr_info_array[], int sum_chunk) + H5D_chunk_addr_info_t chunk_addr_info_array[], int sum_chunk, int mpi_rank, int mpi_size) { - H5SL_node_t * chunk_node; /* Current node in chunk skip list */ - H5D_chunk_info_t *chunk_info; /* Current chunking info. of this node. */ - haddr_t chunk_addr; /* Current chunking address of this node */ - haddr_t *total_chunk_addr_array = NULL; /* The array of chunk address for the total number of chunk */ - hbool_t do_sort = FALSE; /* Whether the addresses need to be sorted */ - int bsearch_coll_chunk_threshold; - int many_chunk_opt = H5D_OBTAIN_ONE_CHUNK_ADDR_IND; - int mpi_size; /* Number of MPI processes */ - int mpi_code; /* MPI return code */ - int i; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5SL_node_t *chunk_node; /* Current node in chunk skip list */ + H5D_chunk_info_t *chunk_info; /* Current chunking info. of this node. */ + haddr_t chunk_addr; /* Current chunking address of this node */ + haddr_t *total_chunk_addr_array = NULL; /* The array of chunk address for the total number of chunk */ + H5P_coll_md_read_flag_t md_reads_file_flag; + hbool_t md_reads_context_flag; + hbool_t restore_md_reads_state = FALSE; + hbool_t do_sort = FALSE; /* Whether the addresses need to be sorted */ + int bsearch_coll_chunk_threshold; + int many_chunk_opt = H5D_OBTAIN_ONE_CHUNK_ADDR_IND; + int mpi_code; /* MPI return code */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - /* Retrieve # of MPI processes */ - if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") - /* Calculate the actual threshold to obtain all chunk addresses collectively * The bigger this number is, the more possible the use of obtaining chunk * address collectively. @@ -2334,31 +2761,56 @@ H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, ((sum_chunk / mpi_size) >= H5D_ALL_CHUNK_ADDR_THRES_COL_NUM)) many_chunk_opt = H5D_OBTAIN_ALL_CHUNK_ADDR_COL; -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "many_chunk_opt= %d\n", many_chunk_opt); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG_VA(mpi_rank, "many_chunk_opt = %d", many_chunk_opt); #endif /* If we need to optimize the way to obtain the chunk address */ if (many_chunk_opt != H5D_OBTAIN_ONE_CHUNK_ADDR_IND) { - int mpi_rank; - -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "Coming inside H5D_OBTAIN_ALL_CHUNK_ADDR_COL\n"); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG(mpi_rank, "Coming inside H5D_OBTAIN_ALL_CHUNK_ADDR_COL"); #endif /* Allocate array for chunk addresses */ if (NULL == (total_chunk_addr_array = (haddr_t *)H5MM_malloc(sizeof(haddr_t) * (size_t)fm->layout->u.chunk.nchunks))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory chunk address array") - /* Retrieve all the chunk addresses with process 0 */ - if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi rank") - if (mpi_rank == 0) { - if (H5D__chunk_addrmap(io_info, total_chunk_addr_array) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") + herr_t result; + + /* + * If enabled, disable collective metadata reads here. + * Since the chunk address mapping is done on rank 0 + * only here, it will cause problems if collective + * metadata reads are enabled. + */ + if (H5F_get_coll_metadata_reads(io_info->dset->oloc.file)) { + md_reads_file_flag = H5P_FORCE_FALSE; + md_reads_context_flag = FALSE; + H5F_set_coll_metadata_reads(io_info->dset->oloc.file, &md_reads_file_flag, + &md_reads_context_flag); + restore_md_reads_state = TRUE; + } + + result = H5D__chunk_addrmap(io_info, total_chunk_addr_array); + + /* Ensure that we restore the old collective metadata reads state */ + if (restore_md_reads_state) { + H5F_set_coll_metadata_reads(io_info->dset->oloc.file, &md_reads_file_flag, + &md_reads_context_flag); + restore_md_reads_state = FALSE; + } + + if (result < 0) { + size_t u; + + /* Clear total chunk address array */ + for (u = 0; u < (size_t)fm->layout->u.chunk.nchunks; u++) + total_chunk_addr_array[u] = HADDR_UNDEF; + + /* Push error, but still participate in following MPI_Bcast */ + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") + } } /* end if */ /* Broadcasting the MPI_IO option info. and chunk address info. */ @@ -2402,10 +2854,10 @@ H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, chunk_node = H5SL_next(chunk_node); } /* end while */ -#ifdef H5D_DEBUG - if (H5DEBUG(D)) - HDfprintf(H5DEBUG(D), "before Qsort\n"); +#ifdef H5Dmpio_DEBUG + H5D_MPIO_DEBUG(mpi_rank, "before Qsort"); #endif + if (do_sort) { size_t num_chunks = H5SL_count(fm->sel_chunks); @@ -2413,6 +2865,10 @@ H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, } /* end if */ done: + /* Re-enable collective metadata reads if we disabled them */ + if (restore_md_reads_state) + H5F_set_coll_metadata_reads(io_info->dset->oloc.file, &md_reads_file_flag, &md_reads_context_flag); + if (total_chunk_addr_array) H5MM_xfree(total_chunk_addr_array); @@ -2429,7 +2885,7 @@ H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, * * 1) Each process provides two piece of information for all chunks having selection * a) chunk index - * b) wheather this chunk is regular(for MPI derived datatype not working case) + * b) whether this chunk is regular(for MPI derived datatype not working case) * * 2) Gather all the information to the root process * @@ -2458,22 +2914,24 @@ H5D__sort_chunk(H5D_io_info_t *io_info, const H5D_chunk_map_t *fm, */ static herr_t H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assign_io_mode[], - haddr_t chunk_addr[]) + haddr_t chunk_addr[], int mpi_rank, int mpi_size) { - size_t total_chunks; - unsigned percent_nproc_per_chunk, threshold_nproc_per_chunk; - uint8_t * io_mode_info = NULL; - uint8_t * recv_io_mode_info = NULL; - uint8_t * mergebuf = NULL; - uint8_t * tempbuf; - H5SL_node_t * chunk_node; - H5D_chunk_info_t *chunk_info; - int mpi_size, mpi_rank; - MPI_Comm comm; - int root; - size_t ic; - int mpi_code; - herr_t ret_value = SUCCEED; + size_t total_chunks; + unsigned percent_nproc_per_chunk, threshold_nproc_per_chunk; + uint8_t *io_mode_info = NULL; + uint8_t *recv_io_mode_info = NULL; + uint8_t *mergebuf = NULL; + uint8_t *tempbuf; + H5SL_node_t *chunk_node; + H5D_chunk_info_t *chunk_info; + H5P_coll_md_read_flag_t md_reads_file_flag; + hbool_t md_reads_context_flag; + hbool_t restore_md_reads_state = FALSE; + MPI_Comm comm; + int root; + size_t ic; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -2481,12 +2939,6 @@ H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assig root = 0; comm = io_info->comm; - /* Obtain the number of process and the current rank of the process */ - if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi rank") - if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") - /* Setup parameters */ H5_CHECKED_ASSIGN(total_chunks, size_t, fm->layout->u.chunk.nchunks, hsize_t); if (H5CX_get_mpio_chunk_opt_ratio(&percent_nproc_per_chunk) < 0) @@ -2533,6 +2985,20 @@ H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assig size_t nproc; unsigned *nproc_per_chunk; + /* + * If enabled, disable collective metadata reads here. + * Since the chunk address mapping is done on rank 0 + * only here, it will cause problems if collective + * metadata reads are enabled. + */ + if (H5F_get_coll_metadata_reads(io_info->dset->oloc.file)) { + md_reads_file_flag = H5P_FORCE_FALSE; + md_reads_context_flag = FALSE; + H5F_set_coll_metadata_reads(io_info->dset->oloc.file, &md_reads_file_flag, + &md_reads_context_flag); + restore_md_reads_state = TRUE; + } + /* pre-computing: calculate number of processes and regularity of the selection occupied in each chunk */ if (NULL == (nproc_per_chunk = (unsigned *)H5MM_calloc(total_chunks * sizeof(unsigned)))) @@ -2599,6 +3065,10 @@ H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assig #endif done: + /* Re-enable collective metadata reads if we disabled them */ + if (restore_md_reads_state) + H5F_set_coll_metadata_reads(io_info->dset->oloc.file, &md_reads_file_flag, &md_reads_context_flag); + if (io_mode_info) H5MM_free(io_mode_info); if (mergebuf) @@ -2612,34 +3082,32 @@ H5D__obtain_mpio_mode(H5D_io_info_t *io_info, H5D_chunk_map_t *fm, uint8_t assig } /* end H5D__obtain_mpio_mode() */ /*------------------------------------------------------------------------- - * Function: H5D__construct_filtered_io_info_list + * Function: H5D__mpio_collective_filtered_chunk_io_setup * * Purpose: Constructs a list of entries which contain the necessary * information for inter-process communication when performing * collective io on filtered chunks. This list is used by - * each process when performing I/O on locally selected chunks - * and also in operations that must be collectively done - * on every chunk, such as chunk re-allocation, insertion of - * chunks into the chunk index, etc. + * each MPI rank when performing I/O on locally selected + * chunks and also in operations that must be collectively + * done on every chunk, such as chunk re-allocation, insertion + * of chunks into the chunk index, etc. * * Return: Non-negative on success/Negative on failure * - * Programmer: Jordan Henderson - * Tuesday, January 10th, 2017 - * *------------------------------------------------------------------------- */ static herr_t -H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5D_chunk_map_t * fm, - H5D_filtered_collective_io_info_t **chunk_list, size_t *num_entries) +H5D__mpio_collective_filtered_chunk_io_setup(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + const H5D_chunk_map_t *fm, + H5D_filtered_collective_io_info_t **chunk_list, + size_t *num_entries, int mpi_rank) { - H5D_filtered_collective_io_info_t *local_info_array = - NULL; /* The list of initially selected chunks for this process */ - size_t num_chunks_selected; - size_t i; - int mpi_rank; - herr_t ret_value = SUCCEED; + H5D_filtered_collective_io_info_t *local_info_array = NULL; + H5D_chunk_ud_t udata; + hbool_t filter_partial_edge_chunks; + size_t num_chunks_selected; + size_t i; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -2649,19 +3117,23 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ HDassert(chunk_list); HDassert(num_entries); - if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi rank") +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Filtered Collective I/O Setup"); +#endif - /* Each process builds a local list of the chunks they have selected */ + /* Each rank builds a local list of the chunks they have selected */ if ((num_chunks_selected = H5SL_count(fm->sel_chunks))) { H5D_chunk_info_t *chunk_info; - H5D_chunk_ud_t udata; - H5SL_node_t * chunk_node; + H5SL_node_t *chunk_node; hsize_t select_npoints; - hssize_t chunk_npoints; + hbool_t need_sort = FALSE; - if (NULL == (local_info_array = (H5D_filtered_collective_io_info_t *)H5MM_malloc( - num_chunks_selected * sizeof(H5D_filtered_collective_io_info_t)))) + /* Determine whether partial edge chunks should be filtered */ + filter_partial_edge_chunks = !(io_info->dset->shared->layout.u.chunk.flags & + H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS); + + if (NULL == (local_info_array = H5MM_malloc(num_chunks_selected * sizeof(*local_info_array)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate local io info array buffer") chunk_node = H5SL_first(fm->sel_chunks); @@ -2672,735 +3144,2848 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ if (H5D__chunk_lookup(io_info->dset, chunk_info->scaled, &udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") - local_info_array[i].index = chunk_info->index; - local_info_array[i].chunk_states.chunk_current = local_info_array[i].chunk_states.new_chunk = - udata.chunk_block; - local_info_array[i].num_writers = 0; - local_info_array[i].owners.original_owner = local_info_array[i].owners.new_owner = mpi_rank; - local_info_array[i].buf = NULL; - - local_info_array[i].async_info.num_receive_requests = 0; - local_info_array[i].async_info.receive_buffer_array = NULL; - local_info_array[i].async_info.receive_requests_array = NULL; - - H5MM_memcpy(local_info_array[i].scaled, chunk_info->scaled, sizeof(chunk_info->scaled)); - - select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); - local_info_array[i].io_size = (size_t)select_npoints * type_info->src_type_size; - - /* Currently the full overwrite status of a chunk is only obtained on a per-process - * basis. This means that if the total selection in the chunk, as determined by the combination - * of selections of all of the processes interested in the chunk, covers the entire chunk, - * the performance optimization of not reading the chunk from the file is still valid, but - * is not applied in the current implementation. Something like an appropriately placed - * MPI_Allreduce or a running total of the number of chunk points selected during chunk - * redistribution should suffice for implementing this case - JTH. + /* Initialize rank-local chunk info */ + local_info_array[i].chunk_info = chunk_info; + local_info_array[i].chunk_buf_size = 0; + local_info_array[i].num_writers = 0; + local_info_array[i].orig_owner = mpi_rank; + local_info_array[i].new_owner = mpi_rank; + local_info_array[i].buf = NULL; + + select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); + local_info_array[i].io_size = (size_t)select_npoints * type_info->dst_type_size; + + /* + * Determine whether this chunk will need to be read from the file. If this is + * a read operation, the chunk will be read. If this is a write operation, we + * generally need to read a filtered chunk from the file before modifying it, + * unless the chunk is being fully overwritten. + * + * TODO: Currently the full overwrite status of a chunk is only obtained on a + * per-rank basis. This means that if the total selection in the chunk, as + * determined by the combination of selections of all of the ranks interested in + * the chunk, covers the entire chunk, the performance optimization of not reading + * the chunk from the file is still valid, but is not applied in the current + * implementation. + * + * To implement this case, a few approaches were considered: + * + * - Keep a running total (distributed to each rank) of the number of chunk + * elements selected during chunk redistribution and compare that to the total + * number of elements in the chunk once redistribution is finished + * + * - Process all incoming chunk messages before doing I/O (these are currently + * processed AFTER doing I/O), combine the owning rank's selection in a chunk + * with the selections received from other ranks and check to see whether that + * combined selection covers the entire chunk + * + * The first approach will be dangerous if the application performs an overlapping + * write to a chunk, as the number of selected elements can equal or exceed the + * number of elements in the chunk without the whole chunk selection being covered. + * While it might be considered erroneous for an application to do an overlapping + * write, we don't explicitly disallow it. + * + * The second approach contains a bit of complexity in that part of the chunk + * messages will be needed before doing I/O and part will be needed after doing I/O. + * Since modification data from chunk messages can't be applied until after any I/O + * is performed (otherwise, we'll overwrite any applied modification data), chunk + * messages are currently entirely processed after I/O. However, in order to determine + * if a chunk is being fully overwritten, we need the dataspace portion of the chunk + * messages before doing I/O. The naive way to do this is to process chunk messages + * twice, using just the relevant information from the message before and after I/O. + * The better way would be to avoid processing chunk messages twice by extracting (and + * keeping around) the dataspace portion of the message before I/O and processing the + * rest of the chunk message after I/O. Note that the dataspace portion of each chunk + * message is used to correctly apply chunk modification data from the message, so + * must be kept around both before and after I/O in this case. + */ + if (io_info->op_type == H5D_IO_OP_READ) + local_info_array[i].need_read = TRUE; + else { + local_info_array[i].need_read = + local_info_array[i].io_size < (size_t)io_info->dset->shared->layout.u.chunk.size; + } + + local_info_array[i].skip_filter_pline = FALSE; + if (!filter_partial_edge_chunks) { + /* + * If this is a partial edge chunk and the "don't filter partial edge + * chunks" flag is set, make sure not to apply filters to the chunk. + */ + if (H5D__chunk_is_partial_edge_chunk(io_info->dset->shared->ndims, + io_info->dset->shared->layout.u.chunk.dim, + chunk_info->scaled, io_info->dset->shared->curr_dims)) + local_info_array[i].skip_filter_pline = TRUE; + } + + /* Initialize the chunk's shared info */ + local_info_array[i].chunk_current = udata.chunk_block; + local_info_array[i].chunk_new = udata.chunk_block; + + /* + * Check if the list is not in ascending order of offset in the file + * or has unallocated chunks. In either case, the list should get + * sorted. */ - if ((chunk_npoints = H5S_GET_EXTENT_NPOINTS(chunk_info->fspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") - local_info_array[i].full_overwrite = - (local_info_array[i].io_size >= (hsize_t)chunk_npoints * type_info->dst_type_size) ? TRUE - : FALSE; + if (i) { + haddr_t curr_chunk_offset = local_info_array[i].chunk_current.offset; + haddr_t prev_chunk_offset = local_info_array[i - 1].chunk_current.offset; + + if (!H5F_addr_defined(prev_chunk_offset) || !H5F_addr_defined(curr_chunk_offset) || + (curr_chunk_offset < prev_chunk_offset)) + need_sort = TRUE; + } + + /* + * Extensible arrays may calculate a chunk's index a little differently + * than normal when the dataset's unlimited dimension is not the + * slowest-changing dimension, so set the index here based on what the + * extensible array code calculated instead of what was calculated + * in the chunk file mapping. + */ + if (io_info->dset->shared->layout.u.chunk.idx_type == H5D_CHUNK_IDX_EARRAY) + local_info_array[i].index_info.chunk_idx = udata.chunk_idx; + else + local_info_array[i].index_info.chunk_idx = chunk_info->index; + + local_info_array[i].index_info.filter_mask = udata.filter_mask; + local_info_array[i].index_info.need_insert = FALSE; chunk_node = H5SL_next(chunk_node); - } /* end for */ - } /* end if */ + } - /* Redistribute shared chunks to new owners as necessary */ - if (io_info->op_type == H5D_IO_OP_WRITE) -#if MPI_VERSION >= 3 - if (H5D__chunk_redistribute_shared_chunks(io_info, type_info, fm, local_info_array, - &num_chunks_selected) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to redistribute shared chunks") -#else - HGOTO_ERROR( - H5E_DATASET, H5E_WRITEERROR, FAIL, - "unable to redistribute shared chunks - MPI version < 3 (MPI_Mprobe and MPI_Imrecv missing)") + /* Ensure the chunk list is sorted in ascending order of offset in the file */ + if (need_sort) + HDqsort(local_info_array, num_chunks_selected, sizeof(H5D_filtered_collective_io_info_t), + H5D__cmp_filtered_collective_io_info_entry); + +#ifdef H5Dmpio_DEBUG + H5D__mpio_dump_collective_filtered_chunk_list(local_info_array, num_chunks_selected, mpi_rank); #endif + } + else if (H5F_get_coll_metadata_reads(io_info->dset->oloc.file)) { + hsize_t scaled[H5O_LAYOUT_NDIMS] = {0}; + + /* + * If this rank has no selection in the dataset and collective + * metadata reads are enabled, do a fake lookup of a chunk to + * ensure that this rank has the chunk index opened. Otherwise, + * only the ranks that had a selection will have opened the + * chunk index and they will have done so independently. Therefore, + * when ranks with no selection participate in later collective + * metadata reads, they will try to open the chunk index collectively + * and issues will occur since other ranks won't participate. + * + * In the future, we should consider having a chunk index "open" + * callback that can be used to ensure collectivity between ranks + * in a more natural way, but this hack should suffice for now. + */ + if (H5D__chunk_lookup(io_info->dset, scaled, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") + } *chunk_list = local_info_array; *num_entries = num_chunks_selected; done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__construct_filtered_io_info_list() */ +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif -#if MPI_VERSION >= 3 + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_collective_filtered_chunk_io_setup() */ /*------------------------------------------------------------------------- - * Function: H5D__chunk_redistribute_shared_chunks - * - * Purpose: When performing a collective write on a Dataset with - * filters applied, this function is used to redistribute any - * chunks which are selected by more than one process, so as - * to preserve file integrity after the write by ensuring - * that any shared chunks are only modified by one process. - * - * The current implementation follows this 3-phase process: - * - * - Collect everyone's list of chunks into one large list, - * sort the list in increasing order of chunk offset in the - * file and hand the list off to rank 0 - * - * - Rank 0 scans the list looking for matching runs of chunk - * offset in the file (corresponding to a shared chunk which - * has been selected by more than one rank in the I/O - * operation) and for each shared chunk, it redistributes - * the chunk to the process writing to the chunk which - * currently has the least amount of chunks assigned to it - * by modifying the "new_owner" field in each of the list - * entries corresponding to that chunk - * - * - After the chunks have been redistributed, rank 0 re-sorts - * the list in order of previous owner so that each rank - * will get back exactly the array that they contributed to - * the redistribution operation, with the "new_owner" field - * of each chunk they are modifying having possibly been - * modified. Rank 0 then scatters each segment of the list - * back to its corresponding rank + * Function: H5D__mpio_redistribute_shared_chunks * - * Return: Non-negative on success/Negative on failure + * Purpose: When performing a parallel write on a chunked Dataset with + * filters applied, we must ensure that any particular chunk + * is only written to by a single MPI rank in order to avoid + * potential data races on the chunk. This function is used to + * redistribute (by assigning ownership to a single rank) any + * chunks which are selected by more than one MPI rank. + * + * An initial Allgather is performed to determine how many + * chunks each rank has selected in the write operation and + * then that number is compared against a threshold value to + * determine whether chunk redistribution should be done on + * MPI rank 0 only, or on all MPI ranks. * - * Programmer: Jordan Henderson - * Monday, May 1, 2017 + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5D_chunk_map_t * fm, - H5D_filtered_collective_io_info_t *local_chunk_array, - size_t * local_chunk_array_num_entries) +H5D__mpio_redistribute_shared_chunks(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, const H5D_io_info_t *io_info, + const H5D_chunk_map_t *fm, int mpi_rank, int mpi_size, + size_t **rank_chunks_assigned_map) { - H5D_filtered_collective_io_info_t *shared_chunks_info_array = - NULL; /* The list of all chunks selected in the operation by all processes */ - H5S_sel_iter_t *mem_iter = NULL; /* Memory iterator for H5D__gather_mem */ - unsigned char **mod_data = - NULL; /* Array of chunk modification data buffers sent by a process to new chunk owners */ - MPI_Request *send_requests = NULL; /* Array of MPI_Isend chunk modification data send requests */ - MPI_Status * send_statuses = NULL; /* Array of MPI_Isend chunk modification send statuses */ - hbool_t mem_iter_init = FALSE; - size_t shared_chunks_info_array_num_entries = 0; - size_t num_send_requests = 0; - size_t * num_assigned_chunks_array = NULL; - size_t i, last_assigned_idx; - int * send_counts = NULL; - int * send_displacements = NULL; - int scatter_recvcount_int; - int mpi_rank, mpi_size, mpi_code; - herr_t ret_value = SUCCEED; + hbool_t redistribute_on_all_ranks; + size_t *num_chunks_map = NULL; + size_t coll_chunk_list_size = 0; + size_t i; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC + HDassert(chunk_list || 0 == chunk_list_num_entries); HDassert(io_info); - HDassert(type_info); HDassert(fm); - HDassert(local_chunk_array_num_entries); + HDassert(mpi_size > 1); /* No chunk sharing is possible for MPI Comm size of 1 */ - if ((mpi_rank = H5F_mpi_get_rank(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi rank") - if ((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) - HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Redistribute shared chunks"); +#endif - /* Set to latest format for encoding dataspace */ - H5CX_set_libver_bounds(NULL); + /* + * Allocate an array for each rank to keep track of the number of + * chunks assigned to any other rank in order to cut down on future + * MPI communication. + */ + if (NULL == (num_chunks_map = H5MM_malloc((size_t)mpi_size * sizeof(*num_chunks_map)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "couldn't allocate assigned chunks array") - if (*local_chunk_array_num_entries) - if (NULL == (send_requests = - (MPI_Request *)H5MM_malloc(*local_chunk_array_num_entries * sizeof(MPI_Request)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate send requests buffer") + /* Perform initial Allgather to determine the collective chunk list size */ + if (MPI_SUCCESS != (mpi_code = MPI_Allgather(&chunk_list_num_entries, 1, H5_SIZE_T_AS_MPI_TYPE, + num_chunks_map, 1, H5_SIZE_T_AS_MPI_TYPE, io_info->comm))) + HMPI_GOTO_ERROR(FAIL, "MPI_Allgather failed", mpi_code) - if (NULL == (mem_iter = (H5S_sel_iter_t *)H5MM_malloc(sizeof(H5S_sel_iter_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate memory iterator") + for (i = 0; i < (size_t)mpi_size; i++) + coll_chunk_list_size += num_chunks_map[i]; - /* Gather every rank's list of chunks to rank 0 to allow it to perform the redistribution operation. After - * this call, the gathered list will initially be sorted in increasing order of chunk offset in the file. + /* + * Determine whether we should perform chunk redistribution on all + * ranks or just rank 0. For a relatively small number of chunks, + * we redistribute on all ranks to cut down on MPI communication + * overhead. For a larger number of chunks, we redistribute on + * rank 0 only to cut down on memory usage. */ - if (H5D__mpio_array_gatherv(local_chunk_array, *local_chunk_array_num_entries, - sizeof(H5D_filtered_collective_io_info_t), (void **)&shared_chunks_info_array, - &shared_chunks_info_array_num_entries, false, 0, io_info->comm, - H5D__cmp_filtered_collective_io_info_entry) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, "couldn't gather array") + redistribute_on_all_ranks = coll_chunk_list_size < H5D_CHUNK_REDISTRIBUTE_THRES; - /* Rank 0 redistributes any shared chunks to new owners as necessary */ - if (mpi_rank == 0) { - if (NULL == (send_counts = (int *)H5MM_calloc((size_t)mpi_size * sizeof(int)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate send counts buffer") + if (H5D__mpio_redistribute_shared_chunks_int(chunk_list, num_chunks_map, redistribute_on_all_ranks, + io_info, fm, mpi_rank, mpi_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREDISTRIBUTE, FAIL, "can't redistribute shared chunks") - if (NULL == (send_displacements = (int *)H5MM_malloc((size_t)mpi_size * sizeof(int)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate send displacements buffer") + /* + * If the caller provided a pointer for the mapping from + * rank value -> number of chunks assigned, return that + * mapping here. + */ + if (rank_chunks_assigned_map) { + /* + * If we performed chunk redistribution on rank 0 only, distribute + * the rank value -> number of chunks assigned mapping back to all + * ranks. + */ + if (!redistribute_on_all_ranks) { + if (MPI_SUCCESS != + (mpi_code = MPI_Bcast(num_chunks_map, mpi_size, H5_SIZE_T_AS_MPI_TYPE, 0, io_info->comm))) + HMPI_GOTO_ERROR(FAIL, "couldn't broadcast chunk mapping to other ranks", mpi_code) + } - if (NULL == (num_assigned_chunks_array = (size_t *)H5MM_calloc((size_t)mpi_size * sizeof(size_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, - "unable to allocate number of assigned chunks array") + *rank_chunks_assigned_map = num_chunks_map; + } - for (i = 0; i < shared_chunks_info_array_num_entries;) { - H5D_filtered_collective_io_info_t chunk_entry; - haddr_t last_seen_addr = shared_chunks_info_array[i].chunk_states.chunk_current.offset; - size_t set_begin_index = i; - size_t num_writers = 0; - int new_chunk_owner = shared_chunks_info_array[i].owners.original_owner; +done: + if (!rank_chunks_assigned_map || (ret_value < 0)) { + num_chunks_map = H5MM_xfree(num_chunks_map); + } - /* Process each set of duplicate entries caused by another process writing to the same chunk */ +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_redistribute_shared_chunks() */ + +/*------------------------------------------------------------------------- + * Function: H5D__mpio_redistribute_shared_chunks_int + * + * Purpose: Routine to perform redistribution of shared chunks during + * parallel writes to datasets with filters applied. + * + * If `all_ranks_involved` is TRUE, chunk redistribution + * occurs on all MPI ranks. This is usually done when there + * is a relatively small number of chunks involved in order to + * cut down on MPI communication overhead while increasing + * total memory usage a bit. + * + * If `all_ranks_involved` is FALSE, only rank 0 will perform + * chunk redistribution. This is usually done when there is + * a relatively large number of chunks involved in order to + * cut down on total memory usage at the cost of increased + * overhead from MPI communication. + * + * This implementation is as follows: + * + * - All MPI ranks send their list of selected chunks to the + * ranks involved in chunk redistribution. Then, the + * involved ranks sort this new list in order of chunk + * index. + * + * - The involved ranks scan the list looking for matching + * runs of chunk index values (corresponding to a shared + * chunk which has been selected by more than one rank in + * the I/O operation) and for each shared chunk, + * redistribute the chunk to the MPI rank writing to the + * chunk which currently has the least amount of chunks + * assigned to it. This is done by modifying the "new_owner" + * field in each of the list entries corresponding to that + * chunk. The involved ranks then re-sort the list in order + * of original chunk owner so that each rank's section of + * contributed chunks is contiguous in the collective chunk + * list. + * + * - If chunk redistribution occurred on all ranks, each rank + * scans through the collective chunk list to find their + * contributed section of chunks and uses that to update + * their local chunk list with the newly-updated "new_owner" + * and "num_writers" fields. If chunk redistribution + * occurred only on rank 0, an MPI_Scatterv operation will + * be used to scatter the segments of the collective chunk + * list from rank 0 back to the corresponding ranks. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_redistribute_shared_chunks_int(H5D_filtered_collective_io_info_t *chunk_list, + size_t *num_chunks_assigned_map, hbool_t all_ranks_involved, + const H5D_io_info_t *io_info, + const H5D_chunk_map_t H5_ATTR_NDEBUG_UNUSED *fm, int mpi_rank, + int mpi_size) +{ + MPI_Datatype struct_type; + MPI_Datatype packed_type; + hbool_t struct_type_derived = FALSE; + hbool_t packed_type_derived = FALSE; + size_t i; + size_t coll_chunk_list_num_entries = 0; + void *coll_chunk_list = NULL; + int *counts_disps_array = NULL; + int *counts_ptr = NULL; + int *displacements_ptr = NULL; + int num_chunks_int; + int mpi_code; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(num_chunks_assigned_map); + HDassert(chunk_list || 0 == num_chunks_assigned_map[mpi_rank]); + HDassert(io_info); + HDassert(fm); + HDassert(mpi_size > 1); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Redistribute shared chunks (internal)"); +#endif + + /* + * Make sure it's safe to cast this rank's number + * of chunks to be sent into an int for MPI + */ + H5_CHECKED_ASSIGN(num_chunks_int, int, num_chunks_assigned_map[mpi_rank], size_t); + + /* + * Phase 1 - Participate in collective gathering of every rank's + * list of chunks to the ranks which are performing the redistribution + * operation. + */ + + if (all_ranks_involved || (mpi_rank == 0)) { + /* + * Allocate array to store the receive counts of each rank, as well as + * the displacements into the final array where each rank will place + * their data. The first half of the array contains the receive counts + * (in rank order), while the latter half contains the displacements + * (also in rank order). + */ + if (NULL == (counts_disps_array = H5MM_malloc(2 * (size_t)mpi_size * sizeof(*counts_disps_array)))) { + /* Push an error, but still participate in collective gather operation */ + HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "couldn't allocate receive counts and displacements array") + } + else { + /* Set the receive counts from the assigned chunks map */ + counts_ptr = counts_disps_array; + + for (i = 0; i < (size_t)mpi_size; i++) + H5_CHECKED_ASSIGN(counts_ptr[i], int, num_chunks_assigned_map[i], size_t); + + /* Set the displacements into the receive buffer for the gather operation */ + displacements_ptr = &counts_disps_array[mpi_size]; + + *displacements_ptr = 0; + for (i = 1; i < (size_t)mpi_size; i++) + displacements_ptr[i] = displacements_ptr[i - 1] + counts_ptr[i - 1]; + } + } + + /* + * Construct MPI derived types for extracting information + * necessary for MPI communication + */ + if (H5D__mpio_get_chunk_redistribute_info_types(&packed_type, &packed_type_derived, &struct_type, + &struct_type_derived) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't create derived datatypes for chunk redistribution info") + + /* Perform gather operation */ + if (H5_mpio_gatherv_alloc(chunk_list, num_chunks_int, struct_type, counts_ptr, displacements_ptr, + packed_type, all_ranks_involved, 0, io_info->comm, mpi_rank, mpi_size, + &coll_chunk_list, &coll_chunk_list_num_entries) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, + "can't gather chunk redistribution info to involved ranks") + + /* + * If all ranks are redistributing shared chunks, we no + * longer need the receive counts and displacements array + */ + if (all_ranks_involved) { + counts_disps_array = H5MM_xfree(counts_disps_array); + } + + /* + * Phase 2 - Involved ranks now redistribute any shared chunks to new + * owners as necessary. + */ + + if (all_ranks_involved || (mpi_rank == 0)) { + H5D_chunk_redistribute_info_t *chunk_entry; + hsize_t curr_chunk_idx; + size_t set_begin_index; + int num_writers; + int new_chunk_owner; + + /* Clear the mapping from rank value -> number of assigned chunks */ + HDmemset(num_chunks_assigned_map, 0, (size_t)mpi_size * sizeof(*num_chunks_assigned_map)); + + /* Sort collective chunk list according to chunk index */ + HDqsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t), + H5D__cmp_chunk_redistribute_info); + + /* + * Process all chunks in the collective chunk list. + * Note that the loop counter is incremented by both + * the outer loop (while processing each entry in + * the collective chunk list) and the inner loop + * (while processing duplicate entries for shared + * chunks). + */ + chunk_entry = &((H5D_chunk_redistribute_info_t *)coll_chunk_list)[0]; + for (i = 0; i < coll_chunk_list_num_entries;) { + /* Set chunk's initial new owner to its original owner */ + new_chunk_owner = chunk_entry->orig_owner; + + /* + * Set the current chunk index so we know when we've processed + * all duplicate entries for a particular shared chunk + */ + curr_chunk_idx = chunk_entry->chunk_idx; + + /* Reset the initial number of writers to this chunk */ + num_writers = 0; + + /* Set index for the beginning of this section of duplicate chunk entries */ + set_begin_index = i; + + /* + * Process each chunk entry in the set for the current + * (possibly shared) chunk and increment the loop counter + * while doing so. + */ do { - chunk_entry = shared_chunks_info_array[i]; + /* + * The new owner of the chunk is determined by the rank + * writing to the chunk which currently has the least amount + * of chunks assigned to it + */ + if (num_chunks_assigned_map[chunk_entry->orig_owner] < + num_chunks_assigned_map[new_chunk_owner]) + new_chunk_owner = chunk_entry->orig_owner; + + /* Update the number of writers to this particular chunk */ + num_writers++; + + chunk_entry++; + } while (++i < coll_chunk_list_num_entries && chunk_entry->chunk_idx == curr_chunk_idx); + + /* We should never have more writers to a chunk than the number of MPI ranks */ + HDassert(num_writers <= mpi_size); + + /* Set all processed chunk entries' "new_owner" and "num_writers" fields */ + for (; set_begin_index < i; set_begin_index++) { + H5D_chunk_redistribute_info_t *entry; + + entry = &((H5D_chunk_redistribute_info_t *)coll_chunk_list)[set_begin_index]; + + entry->new_owner = new_chunk_owner; + entry->num_writers = num_writers; + } + + /* Update the number of chunks assigned to the MPI rank that now owns this chunk */ + num_chunks_assigned_map[new_chunk_owner]++; + } + + /* + * Re-sort the collective chunk list in order of original chunk owner + * so that each rank's section of contributed chunks is contiguous in + * the collective chunk list. + * + * NOTE: this re-sort is frail in that it needs to sort the collective + * chunk list so that each rank's section of contributed chunks + * is in the exact order it was contributed in, or things will + * be scrambled when each rank's local chunk list is updated. + * Therefore, the sorting algorithm here is tied to the one + * used during the I/O setup operation. Specifically, chunks + * are first sorted by ascending order of offset in the file and + * then by chunk index. In the future, a better redistribution + * algorithm may be devised that doesn't rely on frail sorting, + * but the current implementation is a quick and naive approach. + */ + HDqsort(coll_chunk_list, coll_chunk_list_num_entries, sizeof(H5D_chunk_redistribute_info_t), + H5D__cmp_chunk_redistribute_info_orig_owner); + } + + if (all_ranks_involved) { + /* + * If redistribution occurred on all ranks, search for the section + * in the collective chunk list corresponding to this rank's locally + * selected chunks and update the local list after redistribution. + */ + for (i = 0; i < coll_chunk_list_num_entries; i++) + if (mpi_rank == ((H5D_chunk_redistribute_info_t *)coll_chunk_list)[i].orig_owner) + break; + + for (size_t j = 0; j < (size_t)num_chunks_int; j++) { + H5D_chunk_redistribute_info_t *coll_entry; + + coll_entry = &((H5D_chunk_redistribute_info_t *)coll_chunk_list)[i++]; + + chunk_list[j].new_owner = coll_entry->new_owner; + chunk_list[j].num_writers = coll_entry->num_writers; + } + } + else { + /* + * If redistribution occurred only on rank 0, scatter the segments + * of the collective chunk list back to each rank so that their + * local chunk lists get updated + */ + if (MPI_SUCCESS != + (mpi_code = MPI_Scatterv(coll_chunk_list, counts_ptr, displacements_ptr, packed_type, chunk_list, + num_chunks_int, struct_type, 0, io_info->comm))) + HMPI_GOTO_ERROR(FAIL, "unable to scatter shared chunks info buffer", mpi_code) + } + +#ifdef H5Dmpio_DEBUG + H5D__mpio_dump_collective_filtered_chunk_list(chunk_list, num_chunks_assigned_map[mpi_rank], mpi_rank); +#endif + +done: + H5MM_free(coll_chunk_list); + + if (struct_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&struct_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + if (packed_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&packed_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + + H5MM_free(counts_disps_array); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_redistribute_shared_chunks_int() */ + +/*------------------------------------------------------------------------- + * Function: H5D__mpio_share_chunk_modification_data + * + * Purpose: When performing a parallel write on a chunked dataset with + * filters applied, we must first ensure that any particular + * chunk is only written to by a single MPI rank in order to + * avoid potential data races on the chunk. Once dataset + * chunks have been redistributed in a suitable manner, each + * MPI rank must send its chunk data to other ranks for each + * chunk it no longer owns. + * + * The current implementation here follows the Nonblocking + * Consensus algorithm described in: + * http://unixer.de/publications/img/hoefler-dsde-protocols.pdf + * + * First, each MPI rank scans through its list of selected + * chunks and does the following for each chunk: + * + * * If a chunk in the MPI rank's chunk list is still owned + * by that rank, the rank checks how many messages are + * incoming for that chunk and adds that to its running + * total. Then, the rank updates its local chunk list so + * that any previous chunk entries for chunks that are no + * longer owned by the rank get overwritten by chunk + * entries for chunks the rank still owns. Since the data + * for the chunks no longer owned will have already been + * sent, those chunks can effectively be discarded. + * * If a chunk in the MPI rank's chunk list is no longer + * owned by that rank, the rank sends the data it wishes to + * update the chunk with to the MPI rank that now has + * ownership of that chunk. To do this, it encodes the + * chunk's index, its selection in the chunk and its + * modification data into a buffer and then posts a + * non-blocking MPI_Issend to the owning rank. + * + * Once this step is complete, all MPI ranks allocate arrays + * to hold chunk message receive buffers and MPI request + * objects for each non-blocking receive they will post for + * incoming chunk modification messages. Then, all MPI ranks + * enter a loop that alternates between non-blocking + * MPI_Iprobe calls to probe for incoming messages and + * MPI_Testall calls to see if all send requests have + * completed. As chunk modification messages arrive, + * non-blocking MPI_Irecv calls will be posted for each + * message. + * + * Once all send requests have completed, an MPI_Ibarrier is + * posted and the loop then alternates between MPI_Iprobe + * calls and MPI_Test calls to check if all ranks have reached + * the non-blocking barrier. Once all ranks have reached the + * barrier, processing can move on to updating the selected + * chunks that are owned in the operation. + * + * Any chunk messages that were received from other ranks + * will be returned through the `chunk_msg_bufs` array and + * `chunk_msg_bufs_len` will be set appropriately. + * + * NOTE: The use of non-blocking sends and receives of chunk + * data here may contribute to large amounts of memory + * usage/MPI request overhead if the number of shared + * chunks is high. If this becomes a problem, it may be + * useful to split the message receiving loop away so + * that chunk modification messages can be received and + * processed immediately (MPI_Recv) using a single chunk + * message buffer. However, it's possible this may + * degrade performance since the chunk message sends + * are synchronous (MPI_Issend) in the Nonblocking + * Consensus algorithm. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_share_chunk_modification_data(H5D_filtered_collective_io_info_t *chunk_list, + size_t *chunk_list_num_entries, H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, int mpi_rank, + int H5_ATTR_NDEBUG_UNUSED mpi_size, + H5D_filtered_collective_io_info_t **chunk_hash_table, + unsigned char ***chunk_msg_bufs, int *chunk_msg_bufs_len) +{ +#if MPI_VERSION >= 3 + H5D_filtered_collective_io_info_t *chunk_table = NULL; + H5S_sel_iter_t *mem_iter = NULL; + unsigned char **msg_send_bufs = NULL; + unsigned char **msg_recv_bufs = NULL; + MPI_Request *send_requests = NULL; + MPI_Request *recv_requests = NULL; + MPI_Request ibarrier = MPI_REQUEST_NULL; + hbool_t mem_iter_init = FALSE; + hbool_t ibarrier_posted = FALSE; + size_t send_bufs_nalloc = 0; + size_t num_send_requests = 0; + size_t num_recv_requests = 0; + size_t num_msgs_incoming = 0; + size_t last_assigned_idx; + size_t i; + int mpi_code; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(chunk_list_num_entries); + HDassert(chunk_list || 0 == *chunk_list_num_entries); + HDassert(io_info); + HDassert(type_info); + HDassert(mpi_size > 1); + HDassert(chunk_msg_bufs); + HDassert(chunk_msg_bufs_len); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Share chunk modification data"); +#endif + + /* Set to latest format for encoding dataspace */ + H5CX_set_libver_bounds(NULL); + + if (*chunk_list_num_entries) { + /* Allocate a selection iterator for iterating over chunk dataspaces */ + if (NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate dataspace selection iterator") + + /* + * Allocate send buffer and MPI_Request arrays for non-blocking + * sends of outgoing chunk messages + */ + send_bufs_nalloc = H5D_CHUNK_NUM_SEND_MSGS_INIT; + if (NULL == (msg_send_bufs = H5MM_malloc(send_bufs_nalloc * sizeof(*msg_send_bufs)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk modification message buffer array") + + if (NULL == (send_requests = H5MM_malloc(send_bufs_nalloc * sizeof(*send_requests)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate send requests array") + } + + /* + * For each chunk this rank owns, add to the total number of + * incoming MPI messages, then update the local chunk list to + * overwrite any previous chunks no longer owned by this rank. + * Since the data for those chunks will have already been sent, + * this rank should no longer be interested in them and they + * can effectively be discarded. This bookkeeping also makes + * the code for the collective file space re-allocation and + * chunk re-insertion operations a bit simpler. + * + * For each chunk this rank doesn't own, use non-blocking + * synchronous sends to send the data this rank is writing to + * the rank that does own the chunk. + */ + for (i = 0, last_assigned_idx = 0; i < *chunk_list_num_entries; i++) { + H5D_filtered_collective_io_info_t *chunk_entry = &chunk_list[i]; + + if (mpi_rank == chunk_entry->new_owner) { + num_msgs_incoming += (size_t)(chunk_entry->num_writers - 1); + + /* + * Overwrite chunk entries this rank doesn't own with entries that it + * does own, since it has sent the necessary data and is no longer + * interested in the chunks it doesn't own. + */ + chunk_list[last_assigned_idx] = chunk_list[i]; + + /* + * Since, at large scale, a chunk's index value may be larger than + * the maximum value that can be stored in an int, we cannot rely + * on using a chunk's index value as the tag for the MPI messages + * sent/received for a chunk. Therefore, add this chunk to a hash + * table with the chunk's index as a key so that we can quickly find + * the chunk when processing chunk messages that were received. The + * message itself will contain the chunk's index so we can update + * the correct chunk with the received data. + */ + HASH_ADD(hh, chunk_table, index_info.chunk_idx, sizeof(hsize_t), &chunk_list[last_assigned_idx]); + + last_assigned_idx++; + } + else { + H5D_chunk_info_t *chunk_info = chunk_entry->chunk_info; + unsigned char *mod_data_p = NULL; + hsize_t iter_nelmts; + size_t mod_data_size = 0; + size_t space_size = 0; + + /* Add the size of the chunk index to the encoded size */ + mod_data_size += sizeof(hsize_t); + + /* Determine size of serialized chunk file dataspace */ + if (H5S_encode(chunk_info->fspace, &mod_data_p, &space_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get encoded dataspace size") + mod_data_size += space_size; + + /* Determine size of data being written */ + iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); + H5_CHECK_OVERFLOW(iter_nelmts, hsize_t, size_t); + + mod_data_size += (size_t)iter_nelmts * type_info->src_type_size; + + if (NULL == (msg_send_bufs[num_send_requests] = H5MM_malloc(mod_data_size))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk modification message buffer") + + mod_data_p = msg_send_bufs[num_send_requests]; + + /* Store the chunk's index into the buffer */ + HDmemcpy(mod_data_p, &chunk_entry->index_info.chunk_idx, sizeof(hsize_t)); + mod_data_p += sizeof(hsize_t); + + /* Serialize the chunk's file dataspace into the buffer */ + if (H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to encode dataspace") + + /* Initialize iterator for memory selection */ + if (H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, + H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize memory selection information") + mem_iter_init = TRUE; + + /* Collect the modification data into the buffer */ + if (0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t)iter_nelmts, mod_data_p)) + HGOTO_ERROR(H5E_IO, H5E_CANTGATHER, FAIL, "couldn't gather from write buffer") + + /* + * Ensure that the size of the chunk data being sent can be + * safely cast to an int for MPI. Note that this should + * generally be OK for now (unless a rank is sending a + * whole 32-bit-sized chunk of data + its encoded selection), + * but if we allow larger than 32-bit-sized chunks in the + * future, this may become a problem and derived datatypes + * will need to be used. + */ + H5_CHECK_OVERFLOW(mod_data_size, size_t, int) + + /* Send modification data to new owner */ + if (MPI_SUCCESS != + (mpi_code = MPI_Issend(msg_send_bufs[num_send_requests], (int)mod_data_size, MPI_BYTE, + chunk_entry->new_owner, H5D_CHUNK_MOD_DATA_TAG, io_info->comm, + &send_requests[num_send_requests]))) + HMPI_GOTO_ERROR(FAIL, "MPI_Issend failed", mpi_code) + + num_send_requests++; + + /* Resize send buffer and send request arrays if necessary */ + if (num_send_requests == send_bufs_nalloc) { + void *tmp_alloc; + + send_bufs_nalloc = (size_t)((double)send_bufs_nalloc * 1.5); + + if (NULL == + (tmp_alloc = H5MM_realloc(msg_send_bufs, send_bufs_nalloc * sizeof(*msg_send_bufs)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't resize chunk modification message buffer array") + msg_send_bufs = tmp_alloc; + + if (NULL == + (tmp_alloc = H5MM_realloc(send_requests, send_bufs_nalloc * sizeof(*send_requests)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't resize send requests array") + send_requests = tmp_alloc; + } + + if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release memory selection iterator") + mem_iter_init = FALSE; + } + } + + /* Check if the number of send or receive requests will overflow an int (MPI requirement) */ + if (num_send_requests > INT_MAX || num_msgs_incoming > INT_MAX) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, + "too many shared chunks in parallel filtered write operation") + + H5_CHECK_OVERFLOW(num_send_requests, size_t, int) + H5_CHECK_OVERFLOW(num_msgs_incoming, size_t, int) + + /* + * Allocate receive buffer and MPI_Request arrays for non-blocking + * receives of incoming chunk messages + */ + if (num_msgs_incoming) { + if (NULL == (msg_recv_bufs = H5MM_malloc(num_msgs_incoming * sizeof(*msg_recv_bufs)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk modification message buffer array") + + if (NULL == (recv_requests = H5MM_malloc(num_msgs_incoming * sizeof(*recv_requests)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate receive requests array") + } + + /* Process any incoming messages until everyone is done */ + do { + MPI_Status status; + int msg_flag; + + /* Probe for an incoming message from any rank */ + if (MPI_SUCCESS != (mpi_code = MPI_Iprobe(MPI_ANY_SOURCE, H5D_CHUNK_MOD_DATA_TAG, io_info->comm, + &msg_flag, &status))) + HMPI_GOTO_ERROR(FAIL, "MPI_Iprobe failed", mpi_code) + + /* + * If a message was found, allocate a buffer for the message and + * post a non-blocking receive to receive it + */ + if (msg_flag) { +#if MPI_VERSION >= 3 + MPI_Count msg_size = 0; + + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&status, MPI_BYTE, &msg_size))) + HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements_x failed", mpi_code) + + H5_CHECK_OVERFLOW(msg_size, MPI_Count, int) +#else + int msg_size = 0; + + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements(&status, MPI_BYTE, &msg_size))) + HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) +#endif + + if (msg_size <= 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "invalid chunk modification message size") + + HDassert((num_recv_requests + 1) <= num_msgs_incoming); + if (NULL == + (msg_recv_bufs[num_recv_requests] = H5MM_malloc((size_t)msg_size * sizeof(unsigned char)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, + "couldn't allocate chunk modification message receive buffer") + + if (MPI_SUCCESS != (mpi_code = MPI_Irecv(msg_recv_bufs[num_recv_requests], (int)msg_size, + MPI_BYTE, status.MPI_SOURCE, H5D_CHUNK_MOD_DATA_TAG, + io_info->comm, &recv_requests[num_recv_requests]))) + HMPI_GOTO_ERROR(FAIL, "MPI_Irecv failed", mpi_code) + + num_recv_requests++; + } + + if (ibarrier_posted) { + int ibarrier_completed; + + if (MPI_SUCCESS != (mpi_code = MPI_Test(&ibarrier, &ibarrier_completed, MPI_STATUS_IGNORE))) + HMPI_GOTO_ERROR(FAIL, "MPI_Test failed", mpi_code) + + if (ibarrier_completed) + break; + } + else { + int all_sends_completed; + + /* Determine if all send requests have completed */ + if (MPI_SUCCESS != (mpi_code = MPI_Testall((int)num_send_requests, send_requests, + &all_sends_completed, MPI_STATUSES_IGNORE))) + HMPI_GOTO_ERROR(FAIL, "MPI_Testall failed", mpi_code) + + if (all_sends_completed) { + /* Post non-blocking barrier */ + if (MPI_SUCCESS != (mpi_code = MPI_Ibarrier(io_info->comm, &ibarrier))) + HMPI_GOTO_ERROR(FAIL, "MPI_Ibarrier failed", mpi_code) + ibarrier_posted = TRUE; + + /* + * Now that all send requests have completed, free up the + * send buffers used in the non-blocking operations + */ + if (msg_send_bufs) { + for (i = 0; i < num_send_requests; i++) { + if (msg_send_bufs[i]) + H5MM_free(msg_send_bufs[i]); + } + + msg_send_bufs = H5MM_xfree(msg_send_bufs); + } + } + } + } while (1); + + /* + * Ensure all receive requests have completed before moving on. + * For linked-chunk I/O, more overlap with computation could + * theoretically be achieved by returning the receive requests + * array and postponing this wait until during chunk updating + * when the data is really needed. However, multi-chunk I/O + * only updates a chunk at a time and the messages may not come + * in the order that chunks are processed. So, the safest way to + * support both I/O modes is to simply make sure all messages + * are available. + */ + if (MPI_SUCCESS != (mpi_code = MPI_Waitall((int)num_recv_requests, recv_requests, MPI_STATUSES_IGNORE))) + HMPI_GOTO_ERROR(FAIL, "MPI_Waitall failed", mpi_code) + + /* Set the new number of locally-selected chunks */ + *chunk_list_num_entries = last_assigned_idx; + + /* Return chunk message buffers if any were received */ + *chunk_hash_table = chunk_table; + *chunk_msg_bufs = msg_recv_bufs; + *chunk_msg_bufs_len = (int)num_recv_requests; + +done: + if (ret_value < 0) { + /* If this rank failed, make sure to participate in collective barrier */ + if (!ibarrier_posted) { + if (MPI_SUCCESS != (mpi_code = MPI_Ibarrier(io_info->comm, &ibarrier))) + HMPI_GOTO_ERROR(FAIL, "MPI_Ibarrier failed", mpi_code) + } + + if (num_send_requests) { + for (i = 0; i < num_send_requests; i++) { + MPI_Cancel(&send_requests[i]); + } + } + + if (recv_requests) { + for (i = 0; i < num_recv_requests; i++) { + MPI_Cancel(&recv_requests[i]); + } + } + + if (msg_recv_bufs) { + for (i = 0; i < num_recv_requests; i++) { + H5MM_free(msg_recv_bufs[i]); + } + + H5MM_free(msg_recv_bufs); + } + + HASH_CLEAR(hh, chunk_table); + } + + if (recv_requests) + H5MM_free(recv_requests); + if (send_requests) + H5MM_free(send_requests); + + if (msg_send_bufs) { + for (i = 0; i < num_send_requests; i++) { + if (msg_send_bufs[i]) + H5MM_free(msg_send_bufs[i]); + } + + H5MM_free(msg_send_bufs); + } + + if (mem_iter) { + if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release dataspace selection iterator") + mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter); + } + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif + + FUNC_LEAVE_NOAPI(ret_value) +#else + FUNC_ENTER_STATIC + HERROR( + H5E_DATASET, H5E_WRITEERROR, + "unable to send chunk modification data between MPI ranks - MPI version < 3 (MPI_Ibarrier missing)") + FUNC_LEAVE_NOAPI(FAIL) +#endif +} /* end H5D__mpio_share_chunk_modification_data() */ + +/*------------------------------------------------------------------------- + * Function: H5D__mpio_collective_filtered_chunk_common_io + * + * Purpose: This routine performs the common part of collective I/O + * when reading or writing filtered chunks collectively. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_collective_filtered_chunk_common_io(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, const H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, int mpi_size) +{ + H5D_io_info_t coll_io_info; + H5D_storage_t ctg_store; + MPI_Datatype file_type = MPI_DATATYPE_NULL; + MPI_Datatype mem_type = MPI_DATATYPE_NULL; + hbool_t mem_type_is_derived = FALSE; + hbool_t file_type_is_derived = FALSE; + hsize_t mpi_buf_count; + haddr_t base_read_offset = HADDR_UNDEF; + size_t num_chunks; + size_t i; + char fake_buf; /* Used as a fake buffer for ranks with no chunks, thus a NULL buf pointer */ + int mpi_code; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(chunk_list || 0 == chunk_list_num_entries); + HDassert(io_info); + HDassert(type_info); + + /* Initialize temporary I/O info */ + coll_io_info = *io_info; + + /* + * Construct MPI derived datatype for collective I/O on chunks + */ + if (H5D__mpio_collective_filtered_io_type(chunk_list, chunk_list_num_entries, io_info->op_type, &mem_type, + &mem_type_is_derived, &file_type, &file_type_is_derived) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "couldn't create MPI I/O type for chunk I/O") + + /* + * For reads, determine how many chunks are actually being read. + * Note that if this is a read during a write operation + * (read chunk -> unfilter -> modify -> write back), some + * chunks may not need to be read if they're being fully + * overwritten during a write operation. + */ + if (io_info->op_type == H5D_IO_OP_READ) { + for (i = 0, num_chunks = 0; i < chunk_list_num_entries; i++) { + HDassert(chunk_list[i].buf); + + if (chunk_list[i].need_read) { + if (!H5F_addr_defined(base_read_offset)) + base_read_offset = chunk_list[i].chunk_current.offset; + + num_chunks++; + } + } + } + else + num_chunks = chunk_list_num_entries; + + /* + * If this rank doesn't have a selection, it can + * skip I/O if independent I/O was requested at + * the low level, or if the MPI communicator size + * is 1. + * + * Otherwise, this rank has to participate in + * collective I/O, but probably has a NULL buf + * pointer, so override to a fake buffer since our + * write/read function expects one. + */ + if (num_chunks == 0) { + H5FD_mpio_collective_opt_t coll_opt_mode; + + /* Get the collective_opt property to check whether the application wants to do IO individually. */ + if (H5CX_get_mpio_coll_opt(&coll_opt_mode) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O collective_opt property") + + if ((mpi_size == 1) || (H5FD_MPIO_INDIVIDUAL_IO == coll_opt_mode)) { + HGOTO_DONE(SUCCEED) + } + else { + if (io_info->op_type == H5D_IO_OP_WRITE) + coll_io_info.u.wbuf = &fake_buf; + else + coll_io_info.u.rbuf = &fake_buf; + } + } + + /* + * Setup for I/O operation + */ + + mpi_buf_count = (num_chunks) ? 1 : 0; + + if (num_chunks) { + /* + * Setup the base storage address for this operation + * to be the first chunk's file address + */ + if (io_info->op_type == H5D_IO_OP_WRITE) + ctg_store.contig.dset_addr = chunk_list[0].chunk_new.offset; + else + ctg_store.contig.dset_addr = base_read_offset; + } + else + ctg_store.contig.dset_addr = 0; + + ctg_store.contig.dset_size = (hsize_t)io_info->dset->shared->layout.u.chunk.size; + coll_io_info.store = &ctg_store; + + /* Perform I/O */ + if (H5D__final_collective_io(&coll_io_info, type_info, mpi_buf_count, file_type, mem_type) < 0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't finish MPI I/O") + +done: + /* Free the MPI buf and file types, if they were derived */ + if (mem_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&mem_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + if (file_type_is_derived && MPI_SUCCESS != (mpi_code = MPI_Type_free(&file_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_collective_filtered_chunk_common_io() */ + +/*------------------------------------------------------------------------- + * Function: H5D__mpio_collective_filtered_chunk_read + * + * Purpose: This routine coordinates a collective read across all ranks + * of the chunks they have selected. Each rank will then go + * and + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_collective_filtered_chunk_read(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, const H5D_io_info_t *io_info, + const H5D_type_info_t *type_info, int mpi_rank, int mpi_size) +{ + H5D_fill_buf_info_t fb_info; + H5D_chunk_info_t *chunk_info = NULL; + H5D_io_info_t coll_io_info; + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ + hsize_t file_chunk_size = 0; + hsize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */ + hbool_t should_fill = FALSE; + hbool_t fb_info_init = FALSE; + hbool_t index_empty = FALSE; + size_t i; + H5S_t *fill_space = NULL; + void *base_read_buf = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(chunk_list || 0 == chunk_list_num_entries); + HDassert(io_info); + HDassert(type_info); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Filtered collective chunk read"); +#else + (void)mpi_rank; +#endif + + /* Initialize temporary I/O info */ + coll_io_info = *io_info; + coll_io_info.u.rbuf = NULL; + + if (chunk_list_num_entries) { + /* Retrieve filter settings from API context */ + if (H5CX_get_err_detect(&err_detect) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get error detection info") + if (H5CX_get_filter_cb(&filter_cb) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") + + /* Set size of full chunks in dataset */ + file_chunk_size = io_info->dset->shared->layout.u.chunk.size; + + /* Determine if fill values should be "read" for unallocated chunks */ + should_fill = (io_info->dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC) || + ((io_info->dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET) && + io_info->dset->shared->dcpl_cache.fill.fill_defined); + } + + /* + * Allocate memory buffers for all chunks being read. Chunk data buffers are of + * the largest size between the chunk's current filtered size and the chunk's true + * size, as calculated by the number of elements in the chunk's file space extent + * multiplied by the datatype size. This tries to ensure that: + * + * * If we're reading the chunk and the filter normally reduces the chunk size, + * the unfiltering operation won't need to grow the buffer. + * * If we're reading the chunk and the filter normally grows the chunk size, + * we make sure to read into a buffer of size equal to the filtered chunk's + * size; reading into a (smaller) buffer of size equal to the unfiltered + * chunk size would of course be bad. + */ + for (i = 0; i < chunk_list_num_entries; i++) { + HDassert(chunk_list[i].need_read); + + chunk_list[i].chunk_buf_size = MAX(chunk_list[i].chunk_current.length, file_chunk_size); + + if (NULL == (chunk_list[i].buf = H5MM_malloc(chunk_list[i].chunk_buf_size))) { + /* Push an error, but participate in collective read */ + HDONE_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk data buffer") + break; + } + + /* + * Check if chunk is currently allocated. If not, don't try to + * read it from the file. Instead, just fill the chunk buffer + * with the fill value if necessary. + */ + if (H5F_addr_defined(chunk_list[i].chunk_current.offset)) { + /* Set first read buffer */ + if (!base_read_buf) + base_read_buf = chunk_list[i].buf; + + /* Set chunk's new length for eventual filter pipeline calls */ + if (chunk_list[i].skip_filter_pline) + chunk_list[i].chunk_new.length = file_chunk_size; + else + chunk_list[i].chunk_new.length = chunk_list[i].chunk_current.length; + } + else { + chunk_list[i].need_read = FALSE; + + /* Set chunk's new length for eventual filter pipeline calls */ + chunk_list[i].chunk_new.length = file_chunk_size; + + if (should_fill) { + /* Initialize fill value buffer if not already initialized */ + if (!fb_info_init) { + hsize_t chunk_dims[H5S_MAX_RANK]; + + HDassert(io_info->dset->shared->ndims == io_info->dset->shared->layout.u.chunk.ndims - 1); + for (size_t j = 0; j < io_info->dset->shared->layout.u.chunk.ndims - 1; j++) + chunk_dims[j] = (hsize_t)io_info->dset->shared->layout.u.chunk.dim[j]; + + /* Get a dataspace for filling chunk memory buffers */ + if (NULL == (fill_space = H5S_create_simple( + io_info->dset->shared->layout.u.chunk.ndims - 1, chunk_dims, NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create chunk fill dataspace") + + /* Initialize fill value buffer */ + if (H5D__fill_init(&fb_info, NULL, (H5MM_allocate_t)H5D__chunk_mem_alloc, + (void *)&io_info->dset->shared->dcpl_cache.pline, + (H5MM_free_t)H5D__chunk_mem_free, + (void *)&io_info->dset->shared->dcpl_cache.pline, + &io_info->dset->shared->dcpl_cache.fill, io_info->dset->shared->type, + io_info->dset->shared->type_id, 0, file_chunk_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill value buffer") + + fb_info_init = TRUE; + } + + /* Write fill value to memory buffer */ + HDassert(fb_info.fill_buf); + if (H5D__fill(fb_info.fill_buf, io_info->dset->shared->type, chunk_list[i].buf, + type_info->mem_type, fill_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't fill chunk buffer with fill value") + } + } + } + + /* + * If dataset is incrementally allocated and hasn't been written to + * yet, the chunk index should be empty. In this case, a collective + * read of chunks is essentially a no-op, so avoid it here. + */ + index_empty = FALSE; + if (io_info->dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_INCR) + if (H5D__chunk_index_empty(io_info->dset, &index_empty) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't determine if chunk index is empty") + + if (!index_empty) { + /* + * Override the read buffer to point to the address of + * the first chunk data buffer being read into + */ + if (base_read_buf) + coll_io_info.u.rbuf = base_read_buf; + + /* Perform collective chunk read */ + if (H5D__mpio_collective_filtered_chunk_common_io(chunk_list, chunk_list_num_entries, &coll_io_info, + type_info, mpi_size) < 0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't finish collective filtered chunk read") + } + + /* + * Iterate through all the read chunks, unfiltering them and scattering their + * data out to the application's read buffer. + */ + for (i = 0; i < chunk_list_num_entries; i++) { + chunk_info = chunk_list[i].chunk_info; + + /* Unfilter the chunk, unless we didn't read it from the file */ + if (chunk_list[i].need_read && !chunk_list[i].skip_filter_pline) { + if (H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, H5Z_FLAG_REVERSE, + &(chunk_list[i].index_info.filter_mask), err_detect, filter_cb, + (size_t *)&chunk_list[i].chunk_new.length, &chunk_list[i].chunk_buf_size, + &chunk_list[i].buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFILTER, FAIL, "couldn't unfilter chunk for modifying") + } + + /* Scatter the chunk data to the read buffer */ + iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); + + if (H5D_select_io_mem(io_info->u.rbuf, chunk_info->mspace, chunk_list[i].buf, chunk_info->fspace, + type_info->src_type_size, (size_t)iter_nelmts) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't copy chunk data to read buffer") + } + +done: + /* Free all resources used by entries in the chunk list */ + for (i = 0; i < chunk_list_num_entries; i++) { + if (chunk_list[i].buf) { + H5MM_free(chunk_list[i].buf); + chunk_list[i].buf = NULL; + } + } + + /* Release the fill buffer info, if it's been initialized */ + if (fb_info_init && H5D__fill_term(&fb_info) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + if (fill_space && (H5S_close(fill_space) < 0)) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space") + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_collective_filtered_chunk_read() */ + +/*------------------------------------------------------------------------- + * Function: H5D__mpio_collective_filtered_chunk_update + * + * Purpose: When performing a parallel write on a chunked dataset with + * filters applied, all ranks must update their owned chunks + * with their own modification data and data from other ranks. + * This routine is responsible for coordinating that process. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_collective_filtered_chunk_update(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, + H5D_filtered_collective_io_info_t *chunk_hash_table, + unsigned char **chunk_msg_bufs, int chunk_msg_bufs_len, + const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, + int H5_ATTR_NDEBUG_UNUSED mpi_rank, int mpi_size) +{ + H5D_fill_buf_info_t fb_info; + H5D_chunk_info_t *chunk_info = NULL; + H5S_sel_iter_t *sel_iter = NULL; /* Dataspace selection iterator for H5D__scatter_mem */ + H5D_io_info_t coll_io_info; + H5Z_EDC_t err_detect; /* Error detection info */ + H5Z_cb_t filter_cb; /* I/O filter callback function */ + hsize_t file_chunk_size = 0; + hsize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */ + hbool_t should_fill = FALSE; + hbool_t fb_info_init = FALSE; + hbool_t sel_iter_init = FALSE; + hbool_t index_empty = FALSE; + size_t i; + H5S_t *dataspace = NULL; + H5S_t *fill_space = NULL; + void *base_read_buf = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(chunk_list || 0 == chunk_list_num_entries); + HDassert((chunk_msg_bufs && chunk_hash_table) || 0 == chunk_msg_bufs_len); + HDassert(io_info); + HDassert(type_info); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Filtered collective chunk update"); +#endif + + if (chunk_list_num_entries) { + /* Retrieve filter settings from API context */ + if (H5CX_get_err_detect(&err_detect) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get error detection info") + if (H5CX_get_filter_cb(&filter_cb) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") + + /* Set size of full chunks in dataset */ + file_chunk_size = io_info->dset->shared->layout.u.chunk.size; + + /* Determine if fill values should be written to chunks */ + should_fill = (io_info->dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_ALLOC) || + ((io_info->dset->shared->dcpl_cache.fill.fill_time == H5D_FILL_TIME_IFSET) && + io_info->dset->shared->dcpl_cache.fill.fill_defined); + } + + /* + * Allocate memory buffers for all owned chunks. Chunk data buffers are of the + * largest size between the chunk's current filtered size and the chunk's true + * size, as calculated by the number of elements in the chunk's file space extent + * multiplied by the datatype size. This tries to ensure that: + * + * * If we're fully overwriting the chunk and the filter normally reduces the + * chunk size, we simply have the exact buffer size required to hold the + * unfiltered chunk data. + * * If we're fully overwriting the chunk and the filter normally grows the + * chunk size (e.g., fletcher32 filter), the final filtering operation + * (hopefully) won't need to grow the buffer. + * * If we're reading the chunk and the filter normally reduces the chunk size, + * the unfiltering operation won't need to grow the buffer. + * * If we're reading the chunk and the filter normally grows the chunk size, + * we make sure to read into a buffer of size equal to the filtered chunk's + * size; reading into a (smaller) buffer of size equal to the unfiltered + * chunk size would of course be bad. + */ + for (i = 0; i < chunk_list_num_entries; i++) { + HDassert(mpi_rank == chunk_list[i].new_owner); + + chunk_list[i].chunk_buf_size = MAX(chunk_list[i].chunk_current.length, file_chunk_size); + + /* + * If this chunk hasn't been allocated yet and we aren't writing + * out fill values to it, make sure to 0-fill its memory buffer + * so we don't use uninitialized memory. + */ + if (!H5F_addr_defined(chunk_list[i].chunk_current.offset) && !should_fill) + chunk_list[i].buf = H5MM_calloc(chunk_list[i].chunk_buf_size); + else + chunk_list[i].buf = H5MM_malloc(chunk_list[i].chunk_buf_size); + + if (NULL == chunk_list[i].buf) { + /* Push an error, but participate in collective read */ + HDONE_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk data buffer") + break; + } + + /* Set chunk's new length for eventual filter pipeline calls */ + if (chunk_list[i].need_read) { + /* + * Check if chunk is currently allocated. If not, don't try to + * read it from the file. Instead, just fill the chunk buffer + * with the fill value if fill values are to be written. + */ + if (H5F_addr_defined(chunk_list[i].chunk_current.offset)) { + /* Set first read buffer */ + if (!base_read_buf) + base_read_buf = chunk_list[i].buf; + + /* Set chunk's new length for eventual filter pipeline calls */ + if (chunk_list[i].skip_filter_pline) + chunk_list[i].chunk_new.length = file_chunk_size; + else + chunk_list[i].chunk_new.length = chunk_list[i].chunk_current.length; + } + else { + chunk_list[i].need_read = FALSE; + + /* Set chunk's new length for eventual filter pipeline calls */ + chunk_list[i].chunk_new.length = file_chunk_size; + + if (should_fill) { + /* Initialize fill value buffer if not already initialized */ + if (!fb_info_init) { + hsize_t chunk_dims[H5S_MAX_RANK]; + + HDassert(io_info->dset->shared->ndims == + io_info->dset->shared->layout.u.chunk.ndims - 1); + for (size_t j = 0; j < io_info->dset->shared->layout.u.chunk.ndims - 1; j++) + chunk_dims[j] = (hsize_t)io_info->dset->shared->layout.u.chunk.dim[j]; + + /* Get a dataspace for filling chunk memory buffers */ + if (NULL == (fill_space = H5S_create_simple( + io_info->dset->shared->layout.u.chunk.ndims - 1, chunk_dims, NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to create chunk fill dataspace") + + /* Initialize fill value buffer */ + if (H5D__fill_init(&fb_info, NULL, (H5MM_allocate_t)H5D__chunk_mem_alloc, + (void *)&io_info->dset->shared->dcpl_cache.pline, + (H5MM_free_t)H5D__chunk_mem_free, + (void *)&io_info->dset->shared->dcpl_cache.pline, + &io_info->dset->shared->dcpl_cache.fill, + io_info->dset->shared->type, io_info->dset->shared->type_id, 0, + file_chunk_size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill value buffer") + + fb_info_init = TRUE; + } + + /* Write fill value to memory buffer */ + HDassert(fb_info.fill_buf); + if (H5D__fill(fb_info.fill_buf, io_info->dset->shared->type, chunk_list[i].buf, + type_info->mem_type, fill_space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "couldn't fill chunk buffer with fill value") + } + } + } + else + chunk_list[i].chunk_new.length = file_chunk_size; + } + + /* + * If dataset is incrementally allocated and hasn't been written to + * yet, the chunk index should be empty. In this case, a collective + * read of chunks is essentially a no-op, so avoid it here. + */ + index_empty = FALSE; + if (io_info->dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_INCR) + if (H5D__chunk_index_empty(io_info->dset, &index_empty) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't determine if chunk index is empty") + + if (!index_empty) { + /* + * Setup for I/O operation + */ + + /* Initialize temporary I/O info */ + coll_io_info = *io_info; + coll_io_info.op_type = H5D_IO_OP_READ; + + /* Override the read buffer to point to the address of the first + * chunk data buffer being read into + */ + if (base_read_buf) + coll_io_info.u.rbuf = base_read_buf; + + /* Read all chunks that need to be read from the file */ + if (H5D__mpio_collective_filtered_chunk_common_io(chunk_list, chunk_list_num_entries, &coll_io_info, + type_info, mpi_size) < 0) + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't finish collective filtered chunk read") + } + + /* + * Now that all owned chunks have been read, update the chunks + * with modification data from the owning rank and other ranks. + */ + + /* Process all chunks with data from the owning rank first */ + for (i = 0; i < chunk_list_num_entries; i++) { + HDassert(mpi_rank == chunk_list[i].new_owner); + + chunk_info = chunk_list[i].chunk_info; + + /* + * If this chunk wasn't being fully overwritten, we read it from + * the file, so we need to unfilter it + */ + if (chunk_list[i].need_read && !chunk_list[i].skip_filter_pline) { + if (H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, H5Z_FLAG_REVERSE, + &(chunk_list[i].index_info.filter_mask), err_detect, filter_cb, + (size_t *)&chunk_list[i].chunk_new.length, &chunk_list[i].chunk_buf_size, + &chunk_list[i].buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFILTER, FAIL, "couldn't unfilter chunk for modifying") + } + + iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); + + if (H5D_select_io_mem(chunk_list[i].buf, chunk_info->fspace, io_info->u.wbuf, chunk_info->mspace, + type_info->dst_type_size, (size_t)iter_nelmts) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't copy chunk data to write buffer") + } + + /* Allocate iterator for memory selection */ + if (NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate memory iterator") + + /* Now process all received chunk message buffers */ + for (i = 0; i < (size_t)chunk_msg_bufs_len; i++) { + H5D_filtered_collective_io_info_t *chunk_entry = NULL; + const unsigned char *msg_ptr = chunk_msg_bufs[i]; + hsize_t chunk_idx; + + if (msg_ptr) { + /* Retrieve the chunk's index value */ + HDmemcpy(&chunk_idx, msg_ptr, sizeof(hsize_t)); + msg_ptr += sizeof(hsize_t); + + /* Find the chunk entry according to its chunk index */ + HASH_FIND(hh, chunk_hash_table, &chunk_idx, sizeof(hsize_t), chunk_entry); + HDassert(chunk_entry); + HDassert(mpi_rank == chunk_entry->new_owner); + + /* + * Only process the chunk if its data buffer is allocated. + * In the case of multi-chunk I/O, we're only working on + * a chunk at a time, so we need to skip over messages + * that aren't for the chunk we're currently working on. + */ + if (!chunk_entry->buf) + continue; + else { + /* Decode the chunk file dataspace from the message */ + if (NULL == (dataspace = H5S_decode(&msg_ptr))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, FAIL, "unable to decode dataspace") + + if (H5S_select_iter_init(sel_iter, dataspace, type_info->dst_type_size, + H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to initialize memory selection information") + sel_iter_init = TRUE; + + iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace); + + /* Update the chunk data with the received modification data */ + if (H5D__scatter_mem(msg_ptr, sel_iter, (size_t)iter_nelmts, chunk_entry->buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't scatter to write buffer") + + if (H5S_SELECT_ITER_RELEASE(sel_iter) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") + sel_iter_init = FALSE; + + if (dataspace) { + if (H5S_close(dataspace) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + dataspace = NULL; + } + + H5MM_free(chunk_msg_bufs[i]); + chunk_msg_bufs[i] = NULL; + } + } + } + + /* Finally, filter all the chunks */ + for (i = 0; i < chunk_list_num_entries; i++) { + if (!chunk_list[i].skip_filter_pline) { + if (H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, 0, + &(chunk_list[i].index_info.filter_mask), err_detect, filter_cb, + (size_t *)&chunk_list[i].chunk_new.length, &chunk_list[i].chunk_buf_size, + &chunk_list[i].buf) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "output pipeline failed") + } + +#if H5_SIZEOF_SIZE_T > 4 + /* Check for the chunk expanding too much to encode in a 32-bit value */ + if (chunk_list[i].chunk_new.length > ((size_t)0xffffffff)) + HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") +#endif + } + +done: + if (sel_iter) { + if (sel_iter_init && H5S_SELECT_ITER_RELEASE(sel_iter) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") + sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter); + } + if (dataspace && (H5S_close(dataspace) < 0)) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + if (fill_space && (H5S_close(fill_space) < 0)) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close fill space") + + /* Release the fill buffer info, if it's been initialized */ + if (fb_info_init && H5D__fill_term(&fb_info) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release fill buffer info") + + /* On failure, try to free all resources used by entries in the chunk list */ + if (ret_value < 0) { + for (i = 0; i < chunk_list_num_entries; i++) { + if (chunk_list[i].buf) { + H5MM_free(chunk_list[i].buf); + chunk_list[i].buf = NULL; + } + } + } + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_collective_filtered_chunk_update() */ + +/*------------------------------------------------------------------------- + * Function: H5D__mpio_collective_filtered_chunk_reallocate + * + * Purpose: When performing a parallel write on a chunked dataset with + * filters applied, all ranks must eventually get together and + * perform a collective reallocation of space in the file for + * all chunks that were modified on all ranks. This routine is + * responsible for coordinating that process. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_collective_filtered_chunk_reallocate(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, size_t *num_chunks_assigned_map, + H5D_io_info_t *io_info, H5D_chk_idx_info_t *idx_info, + int mpi_rank, int mpi_size) +{ + H5D_chunk_alloc_info_t *collective_list = NULL; + MPI_Datatype send_type; + MPI_Datatype recv_type; + hbool_t send_type_derived = FALSE; + hbool_t recv_type_derived = FALSE; + hbool_t need_sort = FALSE; + size_t collective_num_entries = 0; + size_t num_local_chunks_processed = 0; + size_t i; + void *gathered_array = NULL; + int *counts_disps_array = NULL; + int *counts_ptr = NULL; + int *displacements_ptr = NULL; + int mpi_code; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(chunk_list || 0 == chunk_list_num_entries); + HDassert(io_info); + HDassert(idx_info); + HDassert(idx_info->storage->idx_type != H5D_CHUNK_IDX_NONE); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Reallocation of chunk file space"); +#endif + + /* + * Make sure it's safe to cast this rank's number + * of chunks to be sent into an int for MPI + */ + H5_CHECK_OVERFLOW(chunk_list_num_entries, size_t, int); + + /* Create derived datatypes for the chunk file space info needed */ + if (H5D__mpio_get_chunk_alloc_info_types(&recv_type, &recv_type_derived, &send_type, &send_type_derived) < + 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't create derived datatypes for chunk file space info") + + /* + * Gather the new chunk sizes to all ranks for a collective reallocation + * of the chunks in the file. + */ + if (num_chunks_assigned_map) { + /* + * If a mapping between rank value -> number of assigned chunks has + * been provided (usually during linked-chunk I/O), we can use this + * to optimize MPI overhead a bit since MPI ranks won't need to + * first inform each other about how many chunks they're contributing. + */ + if (NULL == (counts_disps_array = H5MM_malloc(2 * (size_t)mpi_size * sizeof(*counts_disps_array)))) { + /* Push an error, but still participate in collective gather operation */ + HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "couldn't allocate receive counts and displacements array") + } + else { + /* Set the receive counts from the assigned chunks map */ + counts_ptr = counts_disps_array; + + for (i = 0; i < (size_t)mpi_size; i++) + H5_CHECKED_ASSIGN(counts_ptr[i], int, num_chunks_assigned_map[i], size_t); + + /* Set the displacements into the receive buffer for the gather operation */ + displacements_ptr = &counts_disps_array[mpi_size]; + + *displacements_ptr = 0; + for (i = 1; i < (size_t)mpi_size; i++) + displacements_ptr[i] = displacements_ptr[i - 1] + counts_ptr[i - 1]; + } + + /* Perform gather operation */ + if (H5_mpio_gatherv_alloc(chunk_list, (int)chunk_list_num_entries, send_type, counts_ptr, + displacements_ptr, recv_type, TRUE, 0, io_info->comm, mpi_rank, mpi_size, + &gathered_array, &collective_num_entries) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, "can't gather chunk file space info to/from ranks") + } + else { + /* + * If no mapping between rank value -> number of assigned chunks has + * been provided (usually during multi-chunk I/O), all MPI ranks will + * need to first inform other ranks about how many chunks they're + * contributing before performing the actual gather operation. Use + * the 'simple' MPI_Allgatherv wrapper for this. + */ + if (H5_mpio_gatherv_alloc_simple(chunk_list, (int)chunk_list_num_entries, send_type, recv_type, TRUE, + 0, io_info->comm, mpi_rank, mpi_size, &gathered_array, + &collective_num_entries) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, "can't gather chunk file space info to/from ranks") + } + + /* Collectively re-allocate the modified chunks (from each rank) in the file */ + collective_list = (H5D_chunk_alloc_info_t *)gathered_array; + for (i = 0, num_local_chunks_processed = 0; i < collective_num_entries; i++) { + H5D_chunk_alloc_info_t *coll_entry = &collective_list[i]; + hbool_t need_insert; + hbool_t update_local_chunk; + + if (H5D__chunk_file_alloc(idx_info, &coll_entry->chunk_current, &coll_entry->chunk_new, &need_insert, + NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") + + /* + * If we just re-allocated a chunk that is local to this + * rank, make sure to update the chunk entry in the local + * chunk list + */ + update_local_chunk = + (num_local_chunks_processed < chunk_list_num_entries) && + (coll_entry->chunk_idx == chunk_list[num_local_chunks_processed].index_info.chunk_idx); + + if (update_local_chunk) { + H5D_filtered_collective_io_info_t *local_chunk; + + local_chunk = &chunk_list[num_local_chunks_processed]; + + /* Sanity check that this chunk is actually local */ + HDassert(mpi_rank == local_chunk->orig_owner); + HDassert(mpi_rank == local_chunk->new_owner); + + local_chunk->chunk_new = coll_entry->chunk_new; + local_chunk->index_info.need_insert = need_insert; + + /* + * Since chunk reallocation can move chunks around, check if + * the local chunk list is still in ascending offset of order + * in the file + */ + if (num_local_chunks_processed) { + haddr_t curr_chunk_offset = local_chunk->chunk_new.offset; + haddr_t prev_chunk_offset = chunk_list[num_local_chunks_processed - 1].chunk_new.offset; + + HDassert(H5F_addr_defined(prev_chunk_offset) && H5F_addr_defined(curr_chunk_offset)); + if (curr_chunk_offset < prev_chunk_offset) + need_sort = TRUE; + } + + num_local_chunks_processed++; + } + } + + HDassert(chunk_list_num_entries == num_local_chunks_processed); + + /* + * Ensure this rank's local chunk list is sorted in + * ascending order of offset in the file + */ + if (need_sort) + HDqsort(chunk_list, chunk_list_num_entries, sizeof(H5D_filtered_collective_io_info_t), + H5D__cmp_filtered_collective_io_info_entry); + +done: + H5MM_free(gathered_array); + H5MM_free(counts_disps_array); + + if (send_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&send_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + if (recv_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&recv_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5D__mpio_collective_filtered_chunk_reallocate() */ + +/*------------------------------------------------------------------------- + * Function: H5D__mpio_collective_filtered_chunk_reinsert + * + * Purpose: When performing a parallel write on a chunked dataset with + * filters applied, all ranks must eventually get together and + * perform a collective reinsertion into the dataset's chunk + * index of chunks that were modified. This routine is + * responsible for coordinating that process. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_collective_filtered_chunk_reinsert(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, size_t *num_chunks_assigned_map, + H5D_io_info_t *io_info, H5D_chk_idx_info_t *idx_info, + int mpi_rank, int mpi_size) +{ + H5D_chunk_ud_t chunk_ud; + MPI_Datatype send_type; + MPI_Datatype recv_type; + hbool_t send_type_derived = FALSE; + hbool_t recv_type_derived = FALSE; + hsize_t scaled_coords[H5O_LAYOUT_NDIMS]; + size_t collective_num_entries = 0; + size_t i; + void *gathered_array = NULL; + int *counts_disps_array = NULL; + int *counts_ptr = NULL; + int *displacements_ptr = NULL; + int mpi_code; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(chunk_list || 0 == chunk_list_num_entries); + HDassert(io_info); + HDassert(idx_info); + +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TRACE_ENTER(mpi_rank); + H5D_MPIO_TIME_START(mpi_rank, "Reinsertion of modified chunks into chunk index"); +#endif - send_counts[chunk_entry.owners.original_owner] += (int)sizeof(chunk_entry); + /* Only re-insert chunks if index has an insert method */ + if (!idx_info->storage->ops->insert) + HGOTO_DONE(SUCCEED); - /* The new owner of the chunk is determined by the process - * writing to the chunk which currently has the least amount - * of chunks assigned to it - */ - if (num_assigned_chunks_array[chunk_entry.owners.original_owner] < - num_assigned_chunks_array[new_chunk_owner]) - new_chunk_owner = chunk_entry.owners.original_owner; + /* + * Make sure it's safe to cast this rank's number + * of chunks to be sent into an int for MPI + */ + H5_CHECK_OVERFLOW(chunk_list_num_entries, size_t, int); - num_writers++; - } while (++i < shared_chunks_info_array_num_entries && - shared_chunks_info_array[i].chunk_states.chunk_current.offset == last_seen_addr); + /* Create derived datatypes for the chunk re-insertion info needed */ + if (H5D__mpio_get_chunk_insert_info_types(&recv_type, &recv_type_derived, &send_type, + &send_type_derived) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "can't create derived datatypes for chunk re-insertion info") - /* Set all of the chunk entries' "new_owner" fields */ - for (; set_begin_index < i; set_begin_index++) { - shared_chunks_info_array[set_begin_index].owners.new_owner = new_chunk_owner; - shared_chunks_info_array[set_begin_index].num_writers = num_writers; - } /* end for */ + /* + * Gather information to all ranks for a collective re-insertion + * of the modified chunks into the chunk index + */ + if (num_chunks_assigned_map) { + /* + * If a mapping between rank value -> number of assigned chunks has + * been provided (usually during linked-chunk I/O), we can use this + * to optimize MPI overhead a bit since MPI ranks won't need to + * first inform each other about how many chunks they're contributing. + */ + if (NULL == (counts_disps_array = H5MM_malloc(2 * (size_t)mpi_size * sizeof(*counts_disps_array)))) { + /* Push an error, but still participate in collective gather operation */ + HDONE_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "couldn't allocate receive counts and displacements array") + } + else { + /* Set the receive counts from the assigned chunks map */ + counts_ptr = counts_disps_array; - num_assigned_chunks_array[new_chunk_owner]++; - } /* end for */ + for (i = 0; i < (size_t)mpi_size; i++) + H5_CHECKED_ASSIGN(counts_ptr[i], int, num_chunks_assigned_map[i], size_t); + + /* Set the displacements into the receive buffer for the gather operation */ + displacements_ptr = &counts_disps_array[mpi_size]; - /* Sort the new list in order of previous owner so that each original owner of a chunk - * entry gets that entry back, with the possibly newly-modified "new_owner" field + *displacements_ptr = 0; + for (i = 1; i < (size_t)mpi_size; i++) + displacements_ptr[i] = displacements_ptr[i - 1] + counts_ptr[i - 1]; + } + + /* Perform gather operation */ + if (H5_mpio_gatherv_alloc(chunk_list, (int)chunk_list_num_entries, send_type, counts_ptr, + displacements_ptr, recv_type, TRUE, 0, io_info->comm, mpi_rank, mpi_size, + &gathered_array, &collective_num_entries) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, + "can't gather chunk index re-insertion info to/from ranks") + } + else { + /* + * If no mapping between rank value -> number of assigned chunks has + * been provided (usually during multi-chunk I/O), all MPI ranks will + * need to first inform other ranks about how many chunks they're + * contributing before performing the actual gather operation. Use + * the 'simple' MPI_Allgatherv wrapper for this. */ - if (shared_chunks_info_array_num_entries > 1) - HDqsort(shared_chunks_info_array, shared_chunks_info_array_num_entries, - sizeof(H5D_filtered_collective_io_info_t), - H5D__cmp_filtered_collective_io_info_entry_owner); - - send_displacements[0] = 0; - for (i = 1; i < (size_t)mpi_size; i++) - send_displacements[i] = send_displacements[i - 1] + send_counts[i - 1]; - } /* end if */ + if (H5_mpio_gatherv_alloc_simple(chunk_list, (int)chunk_list_num_entries, send_type, recv_type, TRUE, + 0, io_info->comm, mpi_rank, mpi_size, &gathered_array, + &collective_num_entries) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGATHER, FAIL, + "can't gather chunk index re-insertion info to/from ranks") + } - /* Scatter the segments of the list back to each process */ - H5_CHECKED_ASSIGN(scatter_recvcount_int, int, - *local_chunk_array_num_entries * sizeof(H5D_filtered_collective_io_info_t), size_t); - if (MPI_SUCCESS != - (mpi_code = MPI_Scatterv(shared_chunks_info_array, send_counts, send_displacements, MPI_BYTE, - local_chunk_array, scatter_recvcount_int, MPI_BYTE, 0, io_info->comm))) - HMPI_GOTO_ERROR(FAIL, "unable to scatter shared chunks info buffer", mpi_code) + /* Initialize static chunk udata fields from chunk index info */ + H5D_MPIO_INIT_CHUNK_UD_INFO(chunk_ud, idx_info); - if (shared_chunks_info_array) { - H5MM_free(shared_chunks_info_array); - shared_chunks_info_array = NULL; - } /* end if */ + for (i = 0; i < collective_num_entries; i++) { + H5D_chunk_insert_info_t *coll_entry = &((H5D_chunk_insert_info_t *)gathered_array)[i]; - /* Now that the chunks have been redistributed, each process must send its modification data - * to the new owners of any of the chunks it previously possessed. Accordingly, each process - * must also issue asynchronous receives for any messages it may receive for each of the - * chunks it is assigned, in order to avoid potential deadlocking issues. - */ - if (*local_chunk_array_num_entries) - if (NULL == (mod_data = (unsigned char **)H5MM_malloc(*local_chunk_array_num_entries * - sizeof(unsigned char *)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate modification data buffer array") + /* + * We only need to reinsert this chunk if we had to actually + * allocate or reallocate space in the file for it + */ + if (!coll_entry->index_info.need_insert) + continue; + + chunk_ud.chunk_block = coll_entry->chunk_block; + chunk_ud.chunk_idx = coll_entry->index_info.chunk_idx; + chunk_ud.filter_mask = coll_entry->index_info.filter_mask; + chunk_ud.common.scaled = scaled_coords; + + /* Calculate scaled coordinates for the chunk */ + if (idx_info->layout->idx_type == H5D_CHUNK_IDX_EARRAY && idx_info->layout->u.earray.unlim_dim > 0) { + /* + * Extensible arrays where the unlimited dimension is not + * the slowest-changing dimension "swizzle" the coordinates + * to move the unlimited dimension value to offset 0. Therefore, + * we use the "swizzled" down chunks to calculate the "swizzled" + * scaled coordinates and then we undo the "swizzle" operation. + * + * TODO: In the future, this is something that should be handled + * by the particular chunk index rather than manually + * here. Likely, the chunk index ops should get a new + * callback that accepts a chunk index and provides the + * caller with the scaled coordinates for that chunk. + */ + H5VM_array_calc_pre(chunk_ud.chunk_idx, io_info->dset->shared->ndims, + idx_info->layout->u.earray.swizzled_down_chunks, scaled_coords); - for (i = 0, last_assigned_idx = 0; i < *local_chunk_array_num_entries; i++) { - H5D_filtered_collective_io_info_t *chunk_entry = &local_chunk_array[i]; + H5VM_unswizzle_coords(hsize_t, scaled_coords, idx_info->layout->u.earray.unlim_dim); + } + else { + H5VM_array_calc_pre(chunk_ud.chunk_idx, io_info->dset->shared->ndims, + io_info->dset->shared->layout.u.chunk.down_chunks, scaled_coords); + } - if (mpi_rank != chunk_entry->owners.new_owner) { - H5D_chunk_info_t *chunk_info = NULL; - unsigned char * mod_data_p = NULL; - hsize_t iter_nelmts; - size_t mod_data_size; + scaled_coords[io_info->dset->shared->ndims] = 0; - /* Look up the chunk and get its file and memory dataspaces */ - if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_entry->index))) - HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, FAIL, "can't locate chunk in skip list") +#ifndef NDEBUG + /* + * If a matching local chunk entry is found, the + * `chunk_info` structure (which contains the chunk's + * pre-computed scaled coordinates) will be valid + * for this rank. Compare those coordinates against + * the calculated coordinates above to make sure + * they match. + */ + for (size_t dbg_idx = 0; dbg_idx < chunk_list_num_entries; dbg_idx++) { + if (coll_entry->index_info.chunk_idx == chunk_list[dbg_idx].index_info.chunk_idx) { + hbool_t coords_match = !HDmemcmp(scaled_coords, chunk_list[dbg_idx].chunk_info->scaled, + io_info->dset->shared->ndims * sizeof(hsize_t)); - /* Determine size of serialized chunk file dataspace, plus the size of - * the data being written - */ - if (H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to get encoded dataspace size") + HDassert(coords_match && "Calculated scaled coordinates for chunk didn't match " + "chunk's actual scaled coordinates!"); + break; + } + } +#endif - iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); + if ((idx_info->storage->ops->insert)(idx_info, &chunk_ud, io_info->dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk address into index") + } - H5_CHECK_OVERFLOW(iter_nelmts, hsize_t, size_t); - mod_data_size += (size_t)iter_nelmts * type_info->src_type_size; +done: + H5MM_free(gathered_array); + H5MM_free(counts_disps_array); - if (NULL == (mod_data[num_send_requests] = (unsigned char *)H5MM_malloc(mod_data_size))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, - "couldn't allocate chunk modification send buffer") + if (send_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&send_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + if (recv_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&recv_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } - /* Serialize the chunk's file dataspace into the buffer */ - mod_data_p = mod_data[num_send_requests]; - if (H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to encode dataspace") +#ifdef H5Dmpio_DEBUG + H5D_MPIO_TIME_STOP(mpi_rank); + H5D_MPIO_TRACE_EXIT(mpi_rank); +#endif - /* Initialize iterator for memory selection */ - if (H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to initialize memory selection information") - mem_iter_init = TRUE; + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_collective_filtered_chunk_reinsert() */ - /* Collect the modification data into the buffer */ - if (0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t)iter_nelmts, mod_data_p)) - HGOTO_ERROR(H5E_IO, H5E_CANTGATHER, FAIL, "couldn't gather from write buffer") +/*------------------------------------------------------------------------- + * Function: H5D__mpio_get_chunk_redistribute_info_types + * + * Purpose: Constructs MPI derived datatypes for communicating the + * info from a H5D_filtered_collective_io_info_t structure + * that is necessary for redistributing shared chunks during a + * collective write of filtered chunks. + * + * The datatype returned through `contig_type` has an extent + * equal to the size of an H5D_chunk_redistribute_info_t + * structure and is suitable for communicating that structure + * type. + * + * The datatype returned through `resized_type` has an extent + * equal to the size of an H5D_filtered_collective_io_info_t + * structure. This makes it suitable for sending an array of + * those structures, while extracting out just the info + * necessary for the chunk redistribution operation during + * communication. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_get_chunk_redistribute_info_types(MPI_Datatype *contig_type, hbool_t *contig_type_derived, + MPI_Datatype *resized_type, hbool_t *resized_type_derived) +{ + MPI_Datatype struct_type = MPI_DATATYPE_NULL; + hbool_t struct_type_derived = FALSE; + MPI_Datatype chunk_block_type = MPI_DATATYPE_NULL; + hbool_t chunk_block_type_derived = FALSE; + MPI_Datatype types[5]; + MPI_Aint displacements[5]; + int block_lengths[5]; + int field_count; + int mpi_code; + herr_t ret_value = SUCCEED; - /* Send modification data to new owner */ - H5_CHECK_OVERFLOW(mod_data_size, size_t, int) - H5_CHECK_OVERFLOW(chunk_entry->index, hsize_t, int) - if (MPI_SUCCESS != - (mpi_code = MPI_Isend(mod_data[num_send_requests], (int)mod_data_size, MPI_BYTE, - chunk_entry->owners.new_owner, (int)chunk_entry->index, io_info->comm, - &send_requests[num_send_requests]))) - HMPI_GOTO_ERROR(FAIL, "MPI_Isend failed", mpi_code) + FUNC_ENTER_STATIC - if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release memory selection iterator") - mem_iter_init = FALSE; + HDassert(contig_type); + HDassert(contig_type_derived); + HDassert(resized_type); + HDassert(resized_type_derived); - num_send_requests++; - } /* end if */ - else { - /* Allocate all necessary buffers for an asynchronous receive operation */ - if (chunk_entry->num_writers > 1) { - MPI_Message message; - MPI_Status status; - size_t j; + *contig_type_derived = FALSE; + *resized_type_derived = FALSE; - chunk_entry->async_info.num_receive_requests = (int)chunk_entry->num_writers - 1; - if (NULL == (chunk_entry->async_info.receive_requests_array = (MPI_Request *)H5MM_malloc( - (size_t)chunk_entry->async_info.num_receive_requests * sizeof(MPI_Request)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate async requests array") + /* Create struct type for the inner H5F_block_t structure */ + if (H5F_mpi_get_file_block_type(FALSE, &chunk_block_type, &chunk_block_type_derived) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't create derived type for chunk file description") - if (NULL == - (chunk_entry->async_info.receive_buffer_array = (unsigned char **)H5MM_malloc( - (size_t)chunk_entry->async_info.num_receive_requests * sizeof(unsigned char *)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate async receive buffers") + field_count = 5; + HDassert(field_count == (sizeof(types) / sizeof(MPI_Datatype))); - for (j = 0; j < chunk_entry->num_writers - 1; j++) { - int count = 0; + /* + * Create structure type to pack chunk H5F_block_t structure + * next to chunk_idx, orig_owner, new_owner and num_writers + * fields + */ + block_lengths[0] = 1; + block_lengths[1] = 1; + block_lengths[2] = 1; + block_lengths[3] = 1; + block_lengths[4] = 1; + displacements[0] = offsetof(H5D_chunk_redistribute_info_t, chunk_block); + displacements[1] = offsetof(H5D_chunk_redistribute_info_t, chunk_idx); + displacements[2] = offsetof(H5D_chunk_redistribute_info_t, orig_owner); + displacements[3] = offsetof(H5D_chunk_redistribute_info_t, new_owner); + displacements[4] = offsetof(H5D_chunk_redistribute_info_t, num_writers); + types[0] = chunk_block_type; + types[1] = HSIZE_AS_MPI_TYPE; + types[2] = MPI_INT; + types[3] = MPI_INT; + types[4] = MPI_INT; + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct(field_count, block_lengths, displacements, types, contig_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) + *contig_type_derived = TRUE; - /* Probe for a particular message from any process, removing that message - * from the receive queue in the process and allocating that much memory - * for the asynchronous receive - */ - if (MPI_SUCCESS != (mpi_code = MPI_Mprobe(MPI_ANY_SOURCE, (int)chunk_entry->index, - io_info->comm, &message, &status))) - HMPI_GOTO_ERROR(FAIL, "MPI_Mprobe failed", mpi_code) - - if (MPI_SUCCESS != (mpi_code = MPI_Get_count(&status, MPI_BYTE, &count))) - HMPI_GOTO_ERROR(FAIL, "MPI_Get_count failed", mpi_code) - - HDassert(count >= 0); - if (NULL == (chunk_entry->async_info.receive_buffer_array[j] = - (unsigned char *)H5MM_malloc((size_t)count * sizeof(char *)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, - "unable to allocate modification data receive buffer") - - if (MPI_SUCCESS != (mpi_code = MPI_Imrecv( - chunk_entry->async_info.receive_buffer_array[j], count, MPI_BYTE, - &message, &chunk_entry->async_info.receive_requests_array[j]))) - HMPI_GOTO_ERROR(FAIL, "MPI_Imrecv failed", mpi_code) - } /* end for */ - } /* end if */ - - local_chunk_array[last_assigned_idx++] = local_chunk_array[i]; - } /* end else */ - } /* end for */ + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(contig_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - *local_chunk_array_num_entries = last_assigned_idx; + /* Create struct type to extract the chunk_current, chunk_idx, orig_owner, + * new_owner and num_writers fields from a H5D_filtered_collective_io_info_t + * structure + */ + block_lengths[0] = 1; + block_lengths[1] = 1; + block_lengths[2] = 1; + block_lengths[3] = 1; + block_lengths[4] = 1; + displacements[0] = offsetof(H5D_filtered_collective_io_info_t, chunk_current); + displacements[1] = offsetof(H5D_filtered_collective_io_info_t, index_info.chunk_idx); + displacements[2] = offsetof(H5D_filtered_collective_io_info_t, orig_owner); + displacements[3] = offsetof(H5D_filtered_collective_io_info_t, new_owner); + displacements[4] = offsetof(H5D_filtered_collective_io_info_t, num_writers); + types[0] = chunk_block_type; + types[1] = HSIZE_AS_MPI_TYPE; + types[2] = MPI_INT; + types[3] = MPI_INT; + types[4] = MPI_INT; + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct(field_count, block_lengths, displacements, types, &struct_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) + struct_type_derived = TRUE; - /* Wait for all async send requests to complete before returning */ - if (num_send_requests) { - if (NULL == (send_statuses = (MPI_Status *)H5MM_malloc(num_send_requests * sizeof(MPI_Status)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate send statuses buffer") + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_resized( + struct_type, 0, sizeof(H5D_filtered_collective_io_info_t), resized_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_resized failed", mpi_code) + *resized_type_derived = TRUE; - H5_CHECK_OVERFLOW(num_send_requests, size_t, int); - if (MPI_SUCCESS != (mpi_code = MPI_Waitall((int)num_send_requests, send_requests, send_statuses))) - HMPI_GOTO_ERROR(FAIL, "MPI_Waitall failed", mpi_code) - } /* end if */ + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(resized_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) done: - /* Now that all async send requests have completed, free up the send - * buffers used in the async operations - */ - for (i = 0; i < num_send_requests; i++) { - if (mod_data[i]) - H5MM_free(mod_data[i]); - } /* end for */ + if (struct_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&struct_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + if (chunk_block_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_block_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } - if (send_requests) - H5MM_free(send_requests); - if (send_statuses) - H5MM_free(send_statuses); - if (send_counts) - H5MM_free(send_counts); - if (send_displacements) - H5MM_free(send_displacements); - if (mod_data) - H5MM_free(mod_data); - if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") - if (mem_iter) - H5MM_free(mem_iter); - if (num_assigned_chunks_array) - H5MM_free(num_assigned_chunks_array); - if (shared_chunks_info_array) - H5MM_free(shared_chunks_info_array); + if (ret_value < 0) { + if (*resized_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(resized_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *resized_type_derived = FALSE; + } + if (*contig_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(contig_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *contig_type_derived = FALSE; + } + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__chunk_redistribute_shared_chunks() */ -#endif +} /* end H5D__mpio_get_chunk_redistribute_info_types() */ /*------------------------------------------------------------------------- - * Function: H5D__mpio_filtered_collective_write_type + * Function: H5D__mpio_get_chunk_alloc_info_types * - * Purpose: Constructs a MPI derived datatype for both the memory and - * the file for a collective write of filtered chunks. The - * datatype contains the offsets in the file and the locations - * of the filtered chunk data buffers. + * Purpose: Constructs MPI derived datatypes for communicating the info + * from a H5D_filtered_collective_io_info_t structure that is + * necessary for re-allocating file space during a collective + * write of filtered chunks. * - * Return: Non-negative on success/Negative on failure + * The datatype returned through `contig_type` has an extent + * equal to the size of an H5D_chunk_alloc_info_t structure + * and is suitable for communicating that structure type. + * + * The datatype returned through `resized_type` has an extent + * equal to the size of an H5D_filtered_collective_io_info_t + * structure. This makes it suitable for sending an array of + * those structures, while extracting out just the info + * necessary for the chunk file space reallocation operation + * during communication. * - * Programmer: Jordan Henderson - * Tuesday, November 22, 2016 + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ static herr_t -H5D__mpio_filtered_collective_write_type(H5D_filtered_collective_io_info_t *chunk_list, size_t num_entries, - MPI_Datatype *new_mem_type, hbool_t *mem_type_derived, - MPI_Datatype *new_file_type, hbool_t *file_type_derived) +H5D__mpio_get_chunk_alloc_info_types(MPI_Datatype *contig_type, hbool_t *contig_type_derived, + MPI_Datatype *resized_type, hbool_t *resized_type_derived) { - MPI_Aint *write_buf_array = NULL; /* Relative displacements of filtered chunk data buffers */ - MPI_Aint *file_offset_array = NULL; /* Chunk offsets in the file */ - int * length_array = NULL; /* Filtered Chunk lengths */ - herr_t ret_value = SUCCEED; + MPI_Datatype struct_type = MPI_DATATYPE_NULL; + hbool_t struct_type_derived = FALSE; + MPI_Datatype chunk_block_type = MPI_DATATYPE_NULL; + hbool_t chunk_block_type_derived = FALSE; + MPI_Datatype types[3]; + MPI_Aint displacements[3]; + int block_lengths[3]; + int field_count; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC - HDassert(chunk_list); - HDassert(new_mem_type); - HDassert(mem_type_derived); - HDassert(new_file_type); - HDassert(file_type_derived); + HDassert(contig_type); + HDassert(contig_type_derived); + HDassert(resized_type); + HDassert(resized_type_derived); - if (num_entries > 0) { - size_t i; - int mpi_code; - void * base_buf; - - H5_CHECK_OVERFLOW(num_entries, size_t, int); - - /* Allocate arrays */ - if (NULL == (length_array = (int *)H5MM_malloc((size_t)num_entries * sizeof(int)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, - "memory allocation failed for filtered collective write length array") - if (NULL == (write_buf_array = (MPI_Aint *)H5MM_malloc((size_t)num_entries * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, - "memory allocation failed for filtered collective write buf length array") - if (NULL == (file_offset_array = (MPI_Aint *)H5MM_malloc((size_t)num_entries * sizeof(MPI_Aint)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, - "memory allocation failed for collective write offset array") - - /* Ensure the list is sorted in ascending order of offset in the file */ - HDqsort(chunk_list, num_entries, sizeof(H5D_filtered_collective_io_info_t), - H5D__cmp_filtered_collective_io_info_entry); + *contig_type_derived = FALSE; + *resized_type_derived = FALSE; - base_buf = chunk_list[0].buf; - for (i = 0; i < num_entries; i++) { - /* Set up the offset in the file, the length of the chunk data, and the relative - * displacement of the chunk data write buffer - */ - file_offset_array[i] = (MPI_Aint)chunk_list[i].chunk_states.new_chunk.offset; - length_array[i] = (int)chunk_list[i].chunk_states.new_chunk.length; - write_buf_array[i] = (MPI_Aint)chunk_list[i].buf - (MPI_Aint)base_buf; - } /* end for */ + /* Create struct type for the inner H5F_block_t structure */ + if (H5F_mpi_get_file_block_type(FALSE, &chunk_block_type, &chunk_block_type_derived) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't create derived type for chunk file description") - /* Create memory MPI type */ - if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)num_entries, length_array, - write_buf_array, MPI_BYTE, new_mem_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - *mem_type_derived = TRUE; - if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_mem_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - - /* Create file MPI type */ - if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)num_entries, length_array, - file_offset_array, MPI_BYTE, new_file_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - *file_type_derived = TRUE; - if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_file_type))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - } /* end if */ + field_count = 3; + HDassert(field_count == (sizeof(types) / sizeof(MPI_Datatype))); + + /* + * Create structure type to pack both chunk H5F_block_t structures + * next to chunk_idx field + */ + block_lengths[0] = 1; + block_lengths[1] = 1; + block_lengths[2] = 1; + displacements[0] = offsetof(H5D_chunk_alloc_info_t, chunk_current); + displacements[1] = offsetof(H5D_chunk_alloc_info_t, chunk_new); + displacements[2] = offsetof(H5D_chunk_alloc_info_t, chunk_idx); + types[0] = chunk_block_type; + types[1] = chunk_block_type; + types[2] = HSIZE_AS_MPI_TYPE; + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct(field_count, block_lengths, displacements, types, contig_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) + *contig_type_derived = TRUE; + + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(contig_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) + + /* + * Create struct type to extract the chunk_current, chunk_new and chunk_idx + * fields from a H5D_filtered_collective_io_info_t structure + */ + block_lengths[0] = 1; + block_lengths[1] = 1; + block_lengths[2] = 1; + displacements[0] = offsetof(H5D_filtered_collective_io_info_t, chunk_current); + displacements[1] = offsetof(H5D_filtered_collective_io_info_t, chunk_new); + displacements[2] = offsetof(H5D_filtered_collective_io_info_t, index_info.chunk_idx); + types[0] = chunk_block_type; + types[1] = chunk_block_type; + types[2] = HSIZE_AS_MPI_TYPE; + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct(field_count, block_lengths, displacements, types, &struct_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) + struct_type_derived = TRUE; + + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_resized( + struct_type, 0, sizeof(H5D_filtered_collective_io_info_t), resized_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_resized failed", mpi_code) + *resized_type_derived = TRUE; + + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(resized_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) done: - if (write_buf_array) - H5MM_free(write_buf_array); - if (file_offset_array) - H5MM_free(file_offset_array); - if (length_array) - H5MM_free(length_array); + if (struct_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&struct_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + if (chunk_block_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_block_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + + if (ret_value < 0) { + if (*resized_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(resized_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *resized_type_derived = FALSE; + } + if (*contig_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(contig_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *contig_type_derived = FALSE; + } + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__mpio_filtered_collective_write_type() */ +} /* end H5D__mpio_get_chunk_alloc_info_types() */ /*------------------------------------------------------------------------- - * Function: H5D__filtered_collective_chunk_entry_io - * - * Purpose: Given an entry for a filtered chunk, performs the necessary - * steps for updating the chunk data during a collective - * write, or for reading the chunk from file during a - * collective read. + * Function: H5D__mpio_get_chunk_insert_info_types + * + * Purpose: Constructs MPI derived datatypes for communicating the + * information necessary when reinserting chunks into a + * dataset's chunk index. This includes the chunk's new offset + * and size (H5F_block_t) and the inner `index_info` structure + * of a H5D_filtered_collective_io_info_t structure. + * + * The datatype returned through `contig_type` has an extent + * equal to the size of an H5D_chunk_insert_info_t structure + * and is suitable for communicating that structure type. + * + * The datatype returned through `resized_type` has an extent + * equal to the size of the encompassing + * H5D_filtered_collective_io_info_t structure. This makes it + * suitable for sending an array of + * H5D_filtered_collective_io_info_t structures, while + * extracting out just the information needed during + * communication. * * Return: Non-negative on success/Negative on failure * - * Programmer: Jordan Henderson - * Wednesday, January 18, 2017 - * *------------------------------------------------------------------------- */ static herr_t -H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk_entry, - const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, - const H5D_chunk_map_t *fm) +H5D__mpio_get_chunk_insert_info_types(MPI_Datatype *contig_type, hbool_t *contig_type_derived, + MPI_Datatype *resized_type, hbool_t *resized_type_derived) { - H5D_chunk_info_t *chunk_info = NULL; - H5S_sel_iter_t * mem_iter = NULL; /* Memory iterator for H5D__scatter_mem/H5D__gather_mem */ - H5S_sel_iter_t * file_iter = NULL; - H5Z_EDC_t err_detect; /* Error detection info */ - H5Z_cb_t filter_cb; /* I/O filter callback function */ - unsigned filter_mask = 0; - hsize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */ - hssize_t extent_npoints; - hsize_t true_chunk_size; - hbool_t mem_iter_init = FALSE; - hbool_t file_iter_init = FALSE; - size_t buf_size; - size_t i; - H5S_t * dataspace = NULL; /* Other process' dataspace for the chunk */ - void * tmp_gath_buf = NULL; /* Temporary gather buffer to gather into from application buffer - before scattering out to the chunk data buffer (when writing data), - or vice versa (when reading data) */ - int mpi_code; - herr_t ret_value = SUCCEED; + MPI_Datatype struct_type = MPI_DATATYPE_NULL; + hbool_t struct_type_derived = FALSE; + MPI_Datatype chunk_block_type = MPI_DATATYPE_NULL; + hbool_t chunk_block_type_derived = FALSE; + MPI_Aint contig_type_extent; + MPI_Datatype types[4]; + MPI_Aint displacements[4]; + int block_lengths[4]; + int field_count; + int mpi_code; + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC - HDassert(chunk_entry); - HDassert(io_info); - HDassert(type_info); - HDassert(fm); + HDassert(contig_type); + HDassert(contig_type_derived); + HDassert(resized_type); + HDassert(resized_type_derived); - /* Retrieve filter settings from API context */ - if (H5CX_get_err_detect(&err_detect) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get error detection info") - if (H5CX_get_filter_cb(&filter_cb) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get I/O filter callback function") + *contig_type_derived = FALSE; + *resized_type_derived = FALSE; - /* Look up the chunk and get its file and memory dataspaces */ - if (NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_search(fm->sel_chunks, &chunk_entry->index))) - HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, FAIL, "can't locate chunk in skip list") + /* Create struct type for an H5F_block_t structure */ + if (H5F_mpi_get_file_block_type(FALSE, &chunk_block_type, &chunk_block_type_derived) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't create derived type for chunk file description") - if ((extent_npoints = H5S_GET_EXTENT_NPOINTS(chunk_info->fspace)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") - true_chunk_size = (hsize_t)extent_npoints * type_info->src_type_size; + field_count = 4; + HDassert(field_count == (sizeof(types) / sizeof(MPI_Datatype))); - /* If the size of the filtered chunk is larger than the number of points in the - * chunk file space extent times the datatype size, allocate enough space to hold the - * whole filtered chunk. Otherwise, allocate a buffer equal to the size of the - * chunk so that the unfiltering operation doesn't have to grow the buffer. + /* + * Create struct type to pack information into memory as follows: + * + * Chunk's new Offset/Size (H5F_block_t) -> + * Chunk Index Info (H5D_chunk_index_info_t) */ - buf_size = MAX(chunk_entry->chunk_states.chunk_current.length, true_chunk_size); + block_lengths[0] = 1; + block_lengths[1] = 1; + block_lengths[2] = 1; + block_lengths[3] = 1; + displacements[0] = offsetof(H5D_chunk_insert_info_t, chunk_block); + displacements[1] = offsetof(H5D_chunk_insert_info_t, index_info.chunk_idx); + displacements[2] = offsetof(H5D_chunk_insert_info_t, index_info.filter_mask); + displacements[3] = offsetof(H5D_chunk_insert_info_t, index_info.need_insert); + types[0] = chunk_block_type; + types[1] = HSIZE_AS_MPI_TYPE; + types[2] = MPI_UNSIGNED; + types[3] = MPI_C_BOOL; + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct(field_count, block_lengths, displacements, types, &struct_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) + struct_type_derived = TRUE; - if (NULL == (chunk_entry->buf = H5MM_malloc(buf_size))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk data buffer") + contig_type_extent = (MPI_Aint)(sizeof(H5F_block_t) + sizeof(H5D_chunk_index_info_t)); - /* If this is not a full chunk overwrite or this is a read operation, the chunk must be - * read from the file and unfiltered. + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_resized(struct_type, 0, contig_type_extent, contig_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_resized failed", mpi_code) + *contig_type_derived = TRUE; + + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(contig_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) + + struct_type_derived = FALSE; + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&struct_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + + /* + * Create struct type to correctly extract all needed + * information from a H5D_filtered_collective_io_info_t + * structure. */ - if (!chunk_entry->full_overwrite || io_info->op_type == H5D_IO_OP_READ) { - H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request */ + displacements[0] = offsetof(H5D_filtered_collective_io_info_t, chunk_new); + displacements[1] = offsetof(H5D_filtered_collective_io_info_t, index_info.chunk_idx); + displacements[2] = offsetof(H5D_filtered_collective_io_info_t, index_info.filter_mask); + displacements[3] = offsetof(H5D_filtered_collective_io_info_t, index_info.need_insert); + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct(field_count, block_lengths, displacements, types, &struct_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) + struct_type_derived = TRUE; - chunk_entry->chunk_states.new_chunk.length = chunk_entry->chunk_states.chunk_current.length; + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_resized( + struct_type, 0, sizeof(H5D_filtered_collective_io_info_t), resized_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_resized failed", mpi_code) + *resized_type_derived = TRUE; - /* Currently, these chunk reads are done independently and will likely - * cause issues with collective metadata reads enabled. In the future, - * this should be refactored to use collective chunk reads - JTH */ + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(resized_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - /* Get the original state of parallel I/O transfer mode */ - if (H5CX_get_io_xfer_mode(&xfer_mode) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get MPI-I/O transfer mode") +done: + if (struct_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&struct_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } + if (chunk_block_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(&chunk_block_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + } - /* Change the xfer_mode to independent for handling the I/O */ - if (H5CX_set_io_xfer_mode(H5FD_MPIO_INDEPENDENT) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") + if (ret_value < 0) { + if (*resized_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(resized_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *resized_type_derived = FALSE; + } + if (*contig_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(contig_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *contig_type_derived = FALSE; + } + } - if (H5F_shared_block_read(io_info->f_sh, H5FD_MEM_DRAW, - chunk_entry->chunk_states.chunk_current.offset, - chunk_entry->chunk_states.new_chunk.length, chunk_entry->buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read raw data chunk") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_get_chunk_insert_info_types() */ - /* Return to the original I/O transfer mode setting */ - if (H5CX_set_io_xfer_mode(xfer_mode) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set MPI-I/O transfer mode") +/*------------------------------------------------------------------------- + * Function: H5D__mpio_collective_filtered_io_type + * + * Purpose: Constructs a MPI derived datatype for both the memory and + * the file for a collective I/O operation on filtered chunks. + * The datatype contains the chunk offsets and lengths in the + * file and the locations of the chunk data buffers to read + * into/write from. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__mpio_collective_filtered_io_type(H5D_filtered_collective_io_info_t *chunk_list, size_t num_entries, + H5D_io_op_type_t op_type, MPI_Datatype *new_mem_type, + hbool_t *mem_type_derived, MPI_Datatype *new_file_type, + hbool_t *file_type_derived) +{ + MPI_Aint *io_buf_array = NULL; /* Relative displacements of filtered chunk data buffers */ + MPI_Aint *file_offset_array = NULL; /* Chunk offsets in the file */ + int *length_array = NULL; /* Filtered Chunk lengths */ + int mpi_code; + herr_t ret_value = SUCCEED; - if (H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, H5Z_FLAG_REVERSE, &filter_mask, err_detect, - filter_cb, (size_t *)&chunk_entry->chunk_states.new_chunk.length, &buf_size, - &chunk_entry->buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFILTER, FAIL, "couldn't unfilter chunk for modifying") - } /* end if */ - else { - chunk_entry->chunk_states.new_chunk.length = true_chunk_size; - } /* end else */ + FUNC_ENTER_STATIC - /* Initialize iterator for memory selection */ - if (NULL == (mem_iter = (H5S_sel_iter_t *)H5MM_malloc(sizeof(H5S_sel_iter_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate memory iterator") + HDassert(chunk_list || 0 == num_entries); + HDassert(new_mem_type); + HDassert(mem_type_derived); + HDassert(new_file_type); + HDassert(file_type_derived); - if (H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") - mem_iter_init = TRUE; + *mem_type_derived = FALSE; + *file_type_derived = FALSE; + *new_mem_type = MPI_BYTE; + *new_file_type = MPI_BYTE; - /* If this is a read operation, scatter the read chunk data to the user's buffer. - * - * If this is a write operation, update the chunk data buffer with the modifications - * from the current process, then apply any modifications from other processes. Finally, - * filter the newly-updated chunk. - */ - switch (io_info->op_type) { - case H5D_IO_OP_READ: - if (NULL == (file_iter = (H5S_sel_iter_t *)H5MM_malloc(sizeof(H5S_sel_iter_t)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate file iterator") + if (num_entries > 0) { + H5F_block_t *chunk_block; + size_t last_valid_idx = 0; + size_t i; + int chunk_count; - if (H5S_select_iter_init(file_iter, chunk_info->fspace, type_info->src_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to initialize memory selection information") - file_iter_init = TRUE; + /* + * Determine number of chunks for I/O operation and + * setup for derived datatype creation if I/O operation + * includes multiple chunks + */ + if (num_entries == 1) { + /* Set last valid index to 0 for contiguous datatype creation */ + last_valid_idx = 0; - iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); + if (op_type == H5D_IO_OP_WRITE) + chunk_count = 1; + else + chunk_count = chunk_list[0].need_read ? 1 : 0; + } + else { + MPI_Aint chunk_buf; + MPI_Aint base_buf; + haddr_t base_offset = HADDR_UNDEF; + + H5_CHECK_OVERFLOW(num_entries, size_t, int); + + /* Allocate arrays */ + if (NULL == (length_array = H5MM_malloc((size_t)num_entries * sizeof(int)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for filtered collective I/O length array") + if (NULL == (io_buf_array = H5MM_malloc((size_t)num_entries * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for filtered collective I/O buf length array") + if (NULL == (file_offset_array = H5MM_malloc((size_t)num_entries * sizeof(MPI_Aint)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, + "memory allocation failed for filtered collective I/O offset array") + + /* + * If doing a write, we can set the base chunk offset + * and base chunk data buffer right away. + * + * If doing a read, some chunks may be skipped over + * for reading if they aren't yet allocated in the + * file. Therefore, we have to find the first chunk + * actually being read in order to set the base chunk + * offset and base chunk data buffer. + */ + if (op_type == H5D_IO_OP_WRITE) { +#if MPI_VERSION >= 3 + if (MPI_SUCCESS != (mpi_code = MPI_Get_address(chunk_list[0].buf, &base_buf))) + HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code) +#else + base_buf = (MPI_Aint)chunk_list[0].buf; +#endif - if (NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer") + base_offset = chunk_list[0].chunk_new.offset; + } - if (!H5D__gather_mem(chunk_entry->buf, file_iter, (size_t)iter_nelmts, tmp_gath_buf)) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't gather from chunk buffer") + for (i = 0, chunk_count = 0; i < num_entries; i++) { + if (op_type == H5D_IO_OP_READ) { + /* + * If this chunk isn't being read, don't add it + * to the MPI type we're building up for I/O + */ + if (!chunk_list[i].need_read) + continue; - iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); + /* + * If this chunk is being read, go ahead and + * set the base chunk offset and base chunk + * data buffer if we haven't already + */ + if (!H5F_addr_defined(base_offset)) { +#if MPI_VERSION >= 3 + if (MPI_SUCCESS != (mpi_code = MPI_Get_address(chunk_list[i].buf, &base_buf))) + HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code) +#else + base_buf = (MPI_Aint)chunk_list[i].buf; +#endif - if (H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t)iter_nelmts, io_info->u.rbuf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer") + base_offset = chunk_list[i].chunk_current.offset; + } + } - break; + /* Set convenience pointer for current chunk block */ + chunk_block = + (op_type == H5D_IO_OP_READ) ? &chunk_list[i].chunk_current : &chunk_list[i].chunk_new; - case H5D_IO_OP_WRITE: - iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace); + /* + * Set the current chunk entry's offset in the file, relative to + * the first chunk entry + */ + HDassert(H5F_addr_defined(chunk_block->offset)); + file_offset_array[chunk_count] = (MPI_Aint)(chunk_block->offset - base_offset); - if (NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer") + /* + * Ensure the chunk list is sorted in ascending ordering of + * offset in the file + */ + if (chunk_count) + HDassert(file_offset_array[chunk_count] > file_offset_array[chunk_count - 1]); - /* Gather modification data from the application write buffer into a temporary buffer */ - if (0 == H5D__gather_mem(io_info->u.wbuf, mem_iter, (size_t)iter_nelmts, tmp_gath_buf)) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "couldn't gather from write buffer") + /* Set the current chunk entry's size for the I/O operation */ + H5_CHECK_OVERFLOW(chunk_block->length, hsize_t, int); + length_array[chunk_count] = (int)chunk_block->length; - if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") - mem_iter_init = FALSE; + /* + * Set the displacement of the chunk entry's chunk data buffer, + * relative to the first entry's data buffer + */ +#if MPI_VERSION >= 3 && MPI_SUBVERSION >= 1 + if (MPI_SUCCESS != (mpi_code = MPI_Get_address(chunk_list[i].buf, &chunk_buf))) + HMPI_GOTO_ERROR(FAIL, "MPI_Get_address failed", mpi_code) - /* Initialize iterator for file selection */ - if (H5S_select_iter_init(mem_iter, chunk_info->fspace, type_info->dst_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to initialize file selection information") - mem_iter_init = TRUE; + io_buf_array[chunk_count] = MPI_Aint_diff(chunk_buf, base_buf); +#else + chunk_buf = (MPI_Aint)chunk_list[i].buf; + io_buf_array[chunk_count] = chunk_buf - base_buf; +#endif - iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace); + /* + * Set last valid index in case only a single chunk will + * be involved in the I/O operation + */ + last_valid_idx = i; - /* Scatter the owner's modification data into the chunk data buffer according to - * the file space. - */ - if (H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t)iter_nelmts, chunk_entry->buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to chunk data buffer") + chunk_count++; + } /* end for */ + } - if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") - mem_iter_init = FALSE; + /* + * Create derived datatypes for the chunk list if this + * rank has any chunks to work on + */ + if (chunk_count > 0) { + if (chunk_count == 1) { + int chunk_len; - if (MPI_SUCCESS != - (mpi_code = MPI_Waitall(chunk_entry->async_info.num_receive_requests, - chunk_entry->async_info.receive_requests_array, MPI_STATUSES_IGNORE))) - HMPI_GOTO_ERROR(FAIL, "MPI_Waitall failed", mpi_code) + /* Single chunk - use a contiguous type for both memory and file */ - /* For each asynchronous receive call previously posted, receive the chunk modification - * buffer from another rank and update the chunk data - */ - for (i = 0; i < (size_t)chunk_entry->async_info.num_receive_requests; i++) { - const unsigned char *mod_data_p; + /* Ensure that we can cast chunk size to an int for MPI */ + chunk_block = (op_type == H5D_IO_OP_READ) ? &chunk_list[last_valid_idx].chunk_current + : &chunk_list[last_valid_idx].chunk_new; + H5_CHECKED_ASSIGN(chunk_len, int, chunk_block->length, hsize_t); - /* Decode the process' chunk file dataspace */ - mod_data_p = chunk_entry->async_info.receive_buffer_array[i]; - if (NULL == (dataspace = H5S_decode(&mod_data_p))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDECODE, FAIL, "unable to decode dataspace") + if (MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(chunk_len, MPI_BYTE, new_file_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) + *new_mem_type = *new_file_type; - if (H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to initialize memory selection information") - mem_iter_init = TRUE; + /* + * Since we use the same datatype for both memory and file, only + * mark the file type as derived so the caller doesn't try to + * free the same type twice + */ + *mem_type_derived = FALSE; + *file_type_derived = TRUE; - iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace); + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_file_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) + } + else { + HDassert(file_offset_array); + HDassert(length_array); + HDassert(io_buf_array); - /* Update the chunk data with the received modification data */ - if (H5D__scatter_mem(mod_data_p, mem_iter, (size_t)iter_nelmts, chunk_entry->buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "couldn't scatter to write buffer") + /* Multiple chunks - use an hindexed type for both memory and file */ - if (H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") - mem_iter_init = FALSE; - if (dataspace) { - if (H5S_close(dataspace) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") - dataspace = NULL; - } - H5MM_free(chunk_entry->async_info.receive_buffer_array[i]); - } /* end for */ + /* Create memory MPI type */ + if (MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed( + chunk_count, length_array, io_buf_array, MPI_BYTE, new_mem_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) + *mem_type_derived = TRUE; - /* Filter the chunk */ - if (H5Z_pipeline(&io_info->dset->shared->dcpl_cache.pline, 0, &filter_mask, err_detect, filter_cb, - (size_t *)&chunk_entry->chunk_states.new_chunk.length, &buf_size, - &chunk_entry->buf) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "output pipeline failed") + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_mem_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) -#if H5_SIZEOF_SIZE_T > 4 - /* Check for the chunk expanding too much to encode in a 32-bit value */ - if (chunk_entry->chunk_states.new_chunk.length > ((size_t)0xffffffff)) - HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "chunk too large for 32-bit length") -#endif - break; + /* Create file MPI type */ + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_hindexed(chunk_count, length_array, file_offset_array, + MPI_BYTE, new_file_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) + *file_type_derived = TRUE; - default: - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "invalid I/O operation") - } /* end switch */ + if (MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_file_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) + } + } + } /* end if */ done: - if (chunk_entry->async_info.receive_buffer_array) - H5MM_free(chunk_entry->async_info.receive_buffer_array); - if (chunk_entry->async_info.receive_requests_array) - H5MM_free(chunk_entry->async_info.receive_requests_array); - if (tmp_gath_buf) - H5MM_free(tmp_gath_buf); - if (file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") - if (file_iter) - H5MM_free(file_iter); - if (mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "couldn't release selection iterator") - if (mem_iter) - H5MM_free(mem_iter); - if (dataspace) - if (H5S_close(dataspace) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + if (file_offset_array) + H5MM_free(file_offset_array); + if (io_buf_array) + H5MM_free(io_buf_array); + if (length_array) + H5MM_free(length_array); + + if (ret_value < 0) { + if (*file_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(new_file_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *file_type_derived = FALSE; + } + if (*mem_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(new_mem_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *mem_type_derived = FALSE; + } + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D__mpio_collective_filtered_io_type() */ + +#ifdef H5Dmpio_DEBUG + +static herr_t +H5D__mpio_dump_collective_filtered_chunk_list(H5D_filtered_collective_io_info_t *chunk_list, + size_t chunk_list_num_entries, int mpi_rank) +{ + H5D_filtered_collective_io_info_t *chunk_entry; + size_t i; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC_NOERR + + H5D_MPIO_DEBUG(mpi_rank, "CHUNK LIST: ["); + for (i = 0; i < chunk_list_num_entries; i++) { + unsigned chunk_rank; + + chunk_entry = &chunk_list[i]; + + HDassert(chunk_entry->chunk_info); + chunk_rank = (unsigned)H5S_GET_EXTENT_NDIMS(chunk_entry->chunk_info->fspace); + + H5D_MPIO_DEBUG(mpi_rank, " {"); + H5D_MPIO_DEBUG_VA(mpi_rank, " - Entry %zu -", i); + + H5D_MPIO_DEBUG(mpi_rank, " - Chunk Fspace Info -"); + H5D_MPIO_DEBUG_VA(mpi_rank, + " Chunk Current Info: { Offset: %" PRIuHADDR ", Length: %" PRIuHADDR " }", + chunk_entry->chunk_current.offset, chunk_entry->chunk_current.length); + H5D_MPIO_DEBUG_VA(mpi_rank, " Chunk New Info: { Offset: %" PRIuHADDR ", Length: %" PRIuHADDR " }", + chunk_entry->chunk_new.offset, chunk_entry->chunk_new.length); + + H5D_MPIO_DEBUG(mpi_rank, " - Chunk Insert Info -"); + H5D_MPIO_DEBUG_VA(mpi_rank, + " Chunk Scaled Coords (4-d): { %" PRIuHSIZE ", %" PRIuHSIZE ", %" PRIuHSIZE + ", %" PRIuHSIZE " }", + chunk_rank < 1 ? 0 : chunk_entry->chunk_info->scaled[0], + chunk_rank < 2 ? 0 : chunk_entry->chunk_info->scaled[1], + chunk_rank < 3 ? 0 : chunk_entry->chunk_info->scaled[2], + chunk_rank < 4 ? 0 : chunk_entry->chunk_info->scaled[3]); + H5D_MPIO_DEBUG_VA(mpi_rank, " Chunk Index: %" PRIuHSIZE, chunk_entry->index_info.chunk_idx); + H5D_MPIO_DEBUG_VA(mpi_rank, " Filter Mask: %u", chunk_entry->index_info.filter_mask); + H5D_MPIO_DEBUG_VA(mpi_rank, " Need Insert: %s", + chunk_entry->index_info.need_insert ? "YES" : "NO"); + + H5D_MPIO_DEBUG(mpi_rank, " - Other Info -"); + H5D_MPIO_DEBUG_VA(mpi_rank, " Chunk Info Ptr: %p", (void *)chunk_entry->chunk_info); + H5D_MPIO_DEBUG_VA(mpi_rank, " Need Read: %s", chunk_entry->need_read ? "YES" : "NO"); + H5D_MPIO_DEBUG_VA(mpi_rank, " Chunk I/O Size: %zu", chunk_entry->io_size); + H5D_MPIO_DEBUG_VA(mpi_rank, " Chunk Buffer Size: %zu", chunk_entry->chunk_buf_size); + H5D_MPIO_DEBUG_VA(mpi_rank, " Original Owner: %d", chunk_entry->orig_owner); + H5D_MPIO_DEBUG_VA(mpi_rank, " New Owner: %d", chunk_entry->new_owner); + H5D_MPIO_DEBUG_VA(mpi_rank, " # of Writers: %d", chunk_entry->num_writers); + H5D_MPIO_DEBUG_VA(mpi_rank, " Chunk Data Buffer Ptr: %p", (void *)chunk_entry->buf); + + H5D_MPIO_DEBUG(mpi_rank, " }"); + } + H5D_MPIO_DEBUG(mpi_rank, "]"); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__filtered_collective_chunk_entry_io() */ +} /* end H5D__mpio_dump_collective_filtered_chunk_list() */ + +#endif + #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Dnone.c b/src/H5Dnone.c index b2dfd1a819d..1588fcb47c4 100644 --- a/src/H5Dnone.c +++ b/src/H5Dnone.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -301,7 +300,7 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t ch */ static herr_t H5D__none_idx_remove(const H5D_chk_idx_info_t H5_ATTR_UNUSED *idx_info, - H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) + H5D_chunk_common_ud_t H5_ATTR_UNUSED *udata) { FUNC_ENTER_STATIC_NOERR @@ -363,7 +362,7 @@ H5D__none_idx_delete(const H5D_chk_idx_info_t *idx_info) */ static herr_t H5D__none_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_info_src, - const H5D_chk_idx_info_t * idx_info_dst) + const H5D_chk_idx_info_t *idx_info_dst) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Doh.c b/src/H5Doh.c index f6245d5be0a..1147b2f307f 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -41,11 +40,11 @@ /********************/ /* Local Prototypes */ /********************/ -static void * H5O__dset_get_copy_file_udata(void); +static void *H5O__dset_get_copy_file_udata(void); static void H5O__dset_free_copy_file_udata(void *); static htri_t H5O__dset_isa(const H5O_t *loc); -static void * H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); -static void * H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); +static void *H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); +static void *H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__dset_get_oloc(hid_t obj_id); static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); static herr_t H5O__dset_flush(void *_obj_ptr); @@ -211,7 +210,7 @@ H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { H5D_t *dset = NULL; /* Dataset opened */ hid_t dapl_id; /* dapl to use to open this dataset */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -273,8 +272,8 @@ static void * H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) { H5D_obj_create_t *crt_info = (H5D_obj_create_t *)_crt_info; /* Dataset creation parameters */ - H5D_t * dset = NULL; /* New dataset created */ - void * ret_value = NULL; /* Return value */ + H5D_t *dset = NULL; /* New dataset created */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -321,7 +320,7 @@ H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) static H5O_loc_t * H5O__dset_get_oloc(hid_t obj_id) { - H5D_t * dset; /* Dataset opened */ + H5D_t *dset; /* Dataset opened */ H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -438,7 +437,7 @@ H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info) static herr_t H5O__dset_flush(void *_obj_ptr) { - H5D_t * dset = (H5D_t *)_obj_ptr; /* Pointer to dataset object */ + H5D_t *dset = (H5D_t *)_obj_ptr; /* Pointer to dataset object */ H5O_type_t obj_type; /* Type of object at location */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 64f2c7a263f..cf89496d9d0 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -92,7 +91,7 @@ typedef struct H5D_type_info_t { /* Initial values */ const H5T_t *mem_type; /* Pointer to memory datatype */ const H5T_t *dset_type; /* Pointer to dataset datatype */ - H5T_path_t * tpath; /* Datatype conversion path */ + H5T_path_t *tpath; /* Datatype conversion path */ hid_t src_type_id; /* Source datatype ID */ hid_t dst_type_id; /* Destination datatype ID */ @@ -105,9 +104,9 @@ typedef struct H5D_type_info_t { const H5T_subset_info_t *cmpd_subset; /* Info related to the compound subset conversion functions */ H5T_bkg_t need_bkg; /* Type of background buf needed */ size_t request_nelmts; /* Requested strip mine */ - uint8_t * tconv_buf; /* Datatype conv buffer */ + uint8_t *tconv_buf; /* Datatype conv buffer */ hbool_t tconv_buf_allocated; /* Whether the type conversion buffer was allocated */ - uint8_t * bkg_buf; /* Background buffer */ + uint8_t *bkg_buf; /* Background buffer */ hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ } H5D_type_info_t; @@ -123,13 +122,12 @@ typedef hbool_t (*H5D_layout_is_space_alloc_func_t)(const H5O_storage_t *storage typedef hbool_t (*H5D_layout_is_data_cached_func_t)(const H5D_shared_t *shared_dset); typedef herr_t (*H5D_layout_io_init_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, - struct H5D_chunk_map_t *cm); + H5S_t *file_space, 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[], @@ -170,10 +168,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 { @@ -194,7 +192,7 @@ typedef struct { } H5D_chunk_storage_t; typedef struct { - void * buf; /* Buffer for compact dataset */ + void *buf; /* Buffer for compact dataset */ hbool_t *dirty; /* Pointer to dirty flag to mark */ } H5D_compact_storage_t; @@ -219,12 +217,12 @@ typedef struct H5D_io_info_t { MPI_Comm comm; /* MPI communicator for file */ hbool_t using_mpi_vfd; /* Whether the file is using an MPI-based VFD */ #endif /* H5_HAVE_PARALLEL */ - H5D_storage_t * store; /* Dataset storage info */ + H5D_storage_t *store; /* Dataset storage info */ H5D_layout_ops_t layout_ops; /* Dataset layout I/O operation function pointers */ H5D_io_ops_t io_ops; /* I/O operation function pointers */ H5D_io_op_type_t op_type; union { - void * rbuf; /* Pointer to buffer for read */ + void *rbuf; /* Pointer to buffer for read */ const void *wbuf; /* Pointer to buffer to write */ } u; } H5D_io_info_t; @@ -235,9 +233,9 @@ typedef struct H5D_io_info_t { /* Typedef for chunked dataset index operation info */ typedef struct H5D_chk_idx_info_t { - H5F_t * f; /* File pointer for operation */ - const H5O_pline_t * pline; /* I/O pipeline info */ - H5O_layout_chunk_t * layout; /* Chunk layout description */ + H5F_t *f; /* File pointer for operation */ + const H5O_pline_t *pline; /* I/O pipeline info */ + H5O_layout_chunk_t *layout; /* Chunk layout description */ H5O_storage_chunk_t *storage; /* Chunk storage description */ } H5D_chk_idx_info_t; @@ -265,9 +263,9 @@ typedef struct H5D_chunk_rec_t { * to which the index points. */ typedef struct H5D_chunk_common_ud_t { - const H5O_layout_chunk_t * layout; /* Chunk layout description */ + const H5O_layout_chunk_t *layout; /* Chunk layout description */ const H5O_storage_chunk_t *storage; /* Chunk storage description */ - const hsize_t * scaled; /* Scaled coordinates for a chunk */ + const hsize_t *scaled; /* Scaled coordinates for a chunk */ } H5D_chunk_common_ud_t; /* B-tree callback info for various operations */ @@ -335,9 +333,9 @@ typedef struct H5D_chunk_info_t { hsize_t index; /* "Index" of chunk in dataset */ uint32_t chunk_points; /* Number of elements selected in chunk */ hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Scaled coordinates of chunk (in file dataset's dataspace) */ - H5S_t * fspace; /* Dataspace describing chunk & selection in it */ + H5S_t *fspace; /* Dataspace describing chunk & selection in it */ hbool_t fspace_shared; /* Indicate that the file space for a chunk is shared and shouldn't be freed */ - H5S_t * mspace; /* Dataspace describing selection in memory corresponding to this chunk */ + H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ hbool_t mspace_shared; /* Indicate that the memory space for a chunk is shared and shouldn't be freed */ } H5D_chunk_info_t; @@ -346,11 +344,11 @@ 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 * mchunk_tmpl; /* Dataspace template for new memory chunks */ + 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 */ H5S_sel_type msel_type; /* Selection type in memory */ @@ -358,7 +356,7 @@ typedef struct H5D_chunk_map_t { H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ - H5S_t * single_space; /* Dataspace for single chunk */ + H5S_t *single_space; /* Dataspace for single chunk */ H5D_chunk_info_t *single_chunk_info; /* Pointer to single chunk's info */ hbool_t use_single; /* Whether I/O is on a single element */ @@ -388,7 +386,7 @@ typedef struct H5D_chunk_cached_t { /* List of files held open during refresh operations */ typedef struct H5D_virtual_held_file_t { - H5F_t * file; /* Pointer to file held open */ + H5F_t *file; /* Pointer to file held open */ struct H5D_virtual_held_file_t *next; /* Pointer to next node in list */ } H5D_virtual_held_file_t; @@ -413,9 +411,9 @@ typedef struct H5D_rdcc_t { int nused; /* Number of chunk slots in use */ H5D_chunk_cached_t last; /* Cached copy of last chunk information */ struct H5D_rdcc_ent_t **slot; /* Chunk slots, each points to a chunk*/ - H5SL_t * sel_chunks; /* Skip list containing information for each chunk selected */ - H5S_t * single_space; /* Dataspace for single element I/O on chunks */ - H5D_chunk_info_t * single_chunk_info; /* Pointer to single chunk's info */ + H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ + H5S_t *single_space; /* Dataspace for single element I/O on chunks */ + H5D_chunk_info_t *single_chunk_info; /* Pointer to single chunk's info */ /* Cached information about scaled dataspace dimensions */ hsize_t scaled_dims[H5S_MAX_RANK]; /* The scaled dim sizes */ @@ -434,7 +432,7 @@ typedef struct H5D_rdcdc_t { /* * A dataset is made of two layers, an H5D_t struct that is unique to - * each instance of an opened datset, and a shared struct that is only + * each instance of an opened dataset, and a shared struct that is only * created once for a given dataset. Thus, if a dataset is opened twice, * there will be two IDs and two H5D_t structs, both sharing one H5D_shared_t. */ @@ -442,8 +440,8 @@ struct H5D_shared_t { size_t fo_count; /* Reference count */ hbool_t closing; /* Flag to indicate dataset is closing */ hid_t type_id; /* ID for dataset's datatype */ - H5T_t * type; /* Datatype for this dataset */ - H5S_t * space; /* Dataspace of this dataset */ + H5T_t *type; /* Datatype for this dataset */ + H5S_t *space; /* Dataspace of this dataset */ hid_t dcpl_id; /* Dataset creation property id */ hid_t dapl_id; /* Dataset access property id */ H5D_dcpl_cache_t dcpl_cache; /* Cached DCPL values */ @@ -467,8 +465,8 @@ struct H5D_shared_t { } cache; H5D_append_flush_t append_flush; /* Append flush property information */ - char * extfile_prefix; /* expanded external file prefix */ - char * vds_prefix; /* expanded vds prefix */ + char *extfile_prefix; /* expanded external file prefix */ + char *vds_prefix; /* expanded vds prefix */ }; struct H5D_t { @@ -496,21 +494,21 @@ typedef struct { /* Typedef for filling a buffer with a fill value */ typedef struct H5D_fill_buf_info_t { H5MM_allocate_t fill_alloc_func; /* Routine to call for allocating fill buffer */ - void * fill_alloc_info; /* Extra info for allocation routine */ + void *fill_alloc_info; /* Extra info for allocation routine */ H5MM_free_t fill_free_func; /* Routine to call for freeing fill buffer */ - void * fill_free_info; /* Extra info for free routine */ + void *fill_free_info; /* Extra info for free routine */ H5T_path_t *fill_to_mem_tpath; /* Datatype conversion path for converting the fill value to the memory buffer */ H5T_path_t *mem_to_dset_tpath; /* Datatype conversion path for converting the memory buffer to the dataset elements */ const H5O_fill_t *fill; /* Pointer to fill value */ - void * fill_buf; /* Fill buffer */ + void *fill_buf; /* Fill buffer */ size_t fill_buf_size; /* Size of fill buffer */ hbool_t use_caller_fill_buf; /* Whether the caller provided the fill buffer */ - void * bkg_buf; /* Background conversion buffer */ + void *bkg_buf; /* Background conversion buffer */ size_t bkg_buf_size; /* Size of background buffer */ - H5T_t * mem_type; /* Pointer to memory datatype */ - const H5T_t * file_type; /* Pointer to file datatype */ + H5T_t *mem_type; /* Pointer to memory datatype */ + const H5T_t *file_type; /* Pointer to file datatype */ hid_t mem_tid; /* ID for memory version of disk datatype */ hid_t file_tid; /* ID for disk datatype */ size_t mem_elmt_size, file_elmt_size; /* Size of element in memory and on disk */ @@ -549,10 +547,10 @@ H5_DLLVAR const unsigned H5O_layout_ver_bounds[H5F_LIBVER_NBOUNDS]; /* Package Private Prototypes */ /******************************/ -H5_DLL H5D_t *H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id); -H5_DLL H5D_t *H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, const H5S_t *space, - hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); -H5_DLL H5D_t * H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id); +H5_DLL H5D_t *H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id); +H5_DLL H5D_t *H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, const H5S_t *space, + hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); +H5_DLL H5D_t *H5D__open_name(const H5G_loc_t *loc, const char *name, hid_t dapl_id); H5_DLL hid_t H5D__get_space(const H5D_t *dset); H5_DLL hid_t H5D__get_type(const H5D_t *dset); H5_DLL herr_t H5D__get_space_status(const H5D_t *dset, H5D_space_status_t *allocation); @@ -560,11 +558,13 @@ H5_DLL herr_t H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t hbool_t full_overwrite, hsize_t old_dim[]); H5_DLL herr_t H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size); H5_DLL herr_t H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage_size); +H5_DLL herr_t H5D__chunk_index_empty(const H5D_t *dset, hbool_t *empty); H5_DLL herr_t H5D__get_num_chunks(const H5D_t *dset, const H5S_t *space, hsize_t *nchunks); H5_DLL herr_t H5D__get_chunk_info(const H5D_t *dset, const H5S_t *space, hsize_t chk_idx, hsize_t *coord, unsigned *filter_mask, haddr_t *offset, hsize_t *size); H5_DLL herr_t H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); +H5_DLL herr_t H5D__chunk_iter(H5D_t *dset, H5D_chunk_iter_op_t cb, void *op_data); H5_DLL haddr_t H5D__get_offset(const H5D_t *dset); H5_DLL herr_t H5D__vlen_get_buf_size(H5D_t *dset, hid_t type_id, hid_t space_id, hsize_t *size); H5_DLL herr_t H5D__vlen_get_buf_size_gen(H5VL_object_t *vol_obj, hid_t type_id, hid_t space_id, @@ -580,25 +580,29 @@ H5_DLL herr_t H5D__refresh(hid_t dset_id, H5D_t *dataset); 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 direct copying between memory buffers */ +H5_DLL herr_t H5D_select_io_mem(void *dst_buf, H5S_t *dst_space, const void *src_buf, H5S_t *src_space, + size_t elmt_size, size_t nelmts); /* 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); @@ -616,9 +620,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); @@ -635,7 +639,13 @@ H5_DLL herr_t H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_ov const hsize_t old_dim[]); H5_DLL herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk, H5F_block_t *new_chunk, hbool_t *need_insert, const hsize_t *scaled); +H5_DLL void *H5D__chunk_mem_alloc(size_t size, void *pline); +H5_DLL void H5D__chunk_mem_free(void *chk, void *pline); +H5_DLL void *H5D__chunk_mem_xfree(void *chk, const void *pline); +H5_DLL void *H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline); H5_DLL herr_t H5D__chunk_update_old_edge_chunks(H5D_t *dset, hsize_t old_dim[]); +H5_DLL hbool_t H5D__chunk_is_partial_edge_chunk(unsigned dset_ndims, const uint32_t *chunk_dims, + const hsize_t *chunk_scaled, const hsize_t *dset_dims); H5_DLL herr_t H5D__chunk_prune_by_extent(H5D_t *dset, const hsize_t *old_dim); H5_DLL herr_t H5D__chunk_set_sizes(H5D_t *dset); #ifdef H5_HAVE_PARALLEL @@ -685,7 +695,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); @@ -694,39 +704,41 @@ H5_DLL herr_t H5D__fill_term(H5D_fill_buf_info_t *fb_info); #ifdef H5_HAVE_PARALLEL -#ifdef H5S_DEBUG +#ifdef H5D_DEBUG #ifndef H5Dmpio_DEBUG #define H5Dmpio_DEBUG #endif /*H5Dmpio_DEBUG*/ -#endif /*H5S_DEBUG*/ +#endif /*H5D_DEBUG*/ /* MPI-IO function to read, it will select either regular or irregular read */ H5_DLL herr_t H5D__mpio_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); + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space); /* MPI-IO function to write, it will select either regular or irregular read */ H5_DLL herr_t H5D__mpio_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); /* MPI-IO functions to handle contiguous collective IO */ H5_DLL herr_t H5D__contig_collective_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, + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); H5_DLL herr_t H5D__contig_collective_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, + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); /* MPI-IO functions to handle chunked collective IO */ H5_DLL herr_t H5D__chunk_collective_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, + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); H5_DLL herr_t H5D__chunk_collective_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, + hsize_t nelmts, H5S_t *file_space, H5S_t *mem_space, H5D_chunk_map_t *fm); /* MPI-IO function to check if a direct I/O transfer is possible between * memory and the file */ H5_DLL htri_t H5D__mpio_opt_possible(const H5D_io_info_t *io_info, const H5S_t *file_space, const H5S_t *mem_space, const H5D_type_info_t *type_info); +H5_DLL herr_t H5D__mpio_get_no_coll_cause_strings(char *local_cause, size_t local_cause_len, + char *global_cause, size_t global_cause_len); #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index f9ef7727b98..53393376e57 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -137,8 +136,8 @@ typedef struct H5D_dcpl_cache_t { /* Callback information for copying datasets */ typedef struct H5D_copy_file_ud_t { H5O_copy_file_ud_common_t common; /* Shared information (must be first) */ - struct H5S_extent_t * src_space_extent; /* Copy of dataspace extent for dataset */ - H5T_t * src_dtype; /* Copy of datatype for dataset */ + struct H5S_extent_t *src_space_extent; /* Copy of dataspace extent for dataset */ + H5T_t *src_dtype; /* Copy of datatype for dataset */ } H5D_copy_file_ud_t; /* Structure for dataset append flush property (H5Pset_append_flush) */ @@ -146,7 +145,7 @@ typedef struct H5D_append_flush_t { unsigned ndims; /* The # of dimensions for "boundary" */ hsize_t boundary[H5S_MAX_RANK]; /* The dimension sizes for determining boundary */ H5D_append_cb_t func; /* The callback function */ - void * udata; /* User data */ + void *udata; /* User data */ } H5D_append_flush_t; /*****************************/ @@ -157,13 +156,13 @@ typedef struct H5D_append_flush_t { /* Library Private Prototypes */ /******************************/ -H5_DLL herr_t H5D_init(void); -H5_DLL H5D_t *H5D_open(const H5G_loc_t *loc, hid_t dapl_id); -H5_DLL herr_t H5D_close(H5D_t *dataset); -H5_DLL herr_t H5D_mult_refresh_close(hid_t dset_id); -H5_DLL herr_t H5D_mult_refresh_reopen(H5D_t *dataset); -H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset); -H5_DLL H5G_name_t *H5D_nameof(const H5D_t *dataset); +H5_DLL herr_t H5D_init(void); +H5_DLL H5D_t *H5D_open(const H5G_loc_t *loc, hid_t dapl_id); +H5_DLL herr_t H5D_close(H5D_t *dataset); +H5_DLL herr_t H5D_mult_refresh_close(hid_t dset_id); +H5_DLL herr_t H5D_mult_refresh_reopen(H5D_t *dataset); +H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset); +H5_DLL H5G_name_t *H5D_nameof(H5D_t *dataset); H5_DLL herr_t H5D_flush_all(H5F_t *f); H5_DLL hid_t H5D_get_create_plist(const H5D_t *dset); H5_DLL hid_t H5D_get_access_plist(const H5D_t *dset); @@ -177,7 +176,7 @@ H5_DLL herr_t H5D_virtual_check_mapping_pre(const H5S_t *vspace, const H5S_t *sr H5_DLL herr_t H5D_virtual_check_mapping_post(const H5O_storage_virtual_ent_t *ent); H5_DLL herr_t H5D_virtual_check_min_dims(const H5D_t *dset); H5_DLL herr_t H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx); -H5_DLL herr_t H5D_virtual_parse_source_name(const char * source_name, +H5_DLL herr_t H5D_virtual_parse_source_name(const char *source_name, H5O_storage_virtual_name_seg_t **parsed_name, size_t *static_strlen, size_t *nsubs); H5_DLL herr_t H5D_virtual_free_parsed_name(H5O_storage_virtual_name_seg_t *name_seg); diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index b73e62dc343..32d4f64e37c 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -30,9 +29,11 @@ /* Macros used to "unset" chunk cache configuration parameters */ #define H5D_CHUNK_CACHE_NSLOTS_DEFAULT ((size_t)-1) #define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t)-1) -#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0f) +#define H5D_CHUNK_CACHE_W0_DEFAULT (-1.0) -/* Bit flags for the H5Pset_chunk_opts() and H5Pget_chunk_opts() */ +/** + * Bit flags for the H5Pset_chunk_opts() and H5Pget_chunk_opts() + */ #define H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS (0x0002u) /*******************/ @@ -44,13 +45,12 @@ * Values for the H5D_LAYOUT property */ typedef enum H5D_layout_t { - H5D_LAYOUT_ERROR = -1, - - H5D_COMPACT = 0, /**< raw data is very small */ - H5D_CONTIGUOUS = 1, /**< the default */ - H5D_CHUNKED = 2, /**< slow and fancy */ - H5D_VIRTUAL = 3, /**< actual data is stored in other datasets */ - H5D_NLAYOUTS = 4 /**< this one must be last! */ + H5D_LAYOUT_ERROR = -1, /**< error */ + H5D_COMPACT = 0, /**< raw data is small (< 64KB) */ + H5D_CONTIGUOUS = 1, /**< contiguous layout */ + H5D_CHUNKED = 2, /**< chunked or tiled layout */ + H5D_VIRTUAL = 3, /**< actual data is stored in other datasets */ + H5D_NLAYOUTS = 4 /**< this one must be last! */ } H5D_layout_t; //! @@ -75,11 +75,11 @@ typedef enum H5D_chunk_index_t { * Values for the space allocation time property */ typedef enum H5D_alloc_time_t { - H5D_ALLOC_TIME_ERROR = -1, - H5D_ALLOC_TIME_DEFAULT = 0, - H5D_ALLOC_TIME_EARLY = 1, - H5D_ALLOC_TIME_LATE = 2, - H5D_ALLOC_TIME_INCR = 3 + H5D_ALLOC_TIME_ERROR = -1, /**< Error */ + H5D_ALLOC_TIME_DEFAULT = 0, /**< Default (layout dependent) */ + H5D_ALLOC_TIME_EARLY = 1, /**< Allocate on creation */ + H5D_ALLOC_TIME_LATE = 2, /**< Allocate on first write */ + H5D_ALLOC_TIME_INCR = 3 /**< Allocate incrementally (by chunk) */ } H5D_alloc_time_t; //! @@ -88,10 +88,11 @@ typedef enum H5D_alloc_time_t { * Values for the status of space allocation */ typedef enum H5D_space_status_t { - H5D_SPACE_STATUS_ERROR = -1, - H5D_SPACE_STATUS_NOT_ALLOCATED = 0, - H5D_SPACE_STATUS_PART_ALLOCATED = 1, - H5D_SPACE_STATUS_ALLOCATED = 2 + H5D_SPACE_STATUS_ERROR = -1, /**< Error */ + H5D_SPACE_STATUS_NOT_ALLOCATED = 0, /**< Space has not been allocated for this dataset. */ + H5D_SPACE_STATUS_PART_ALLOCATED = 1, /**< Space has been partially allocated for this dataset. + (Used only for datasets with chunked storage.) */ + H5D_SPACE_STATUS_ALLOCATED = 2 /**< Space has been allocated for this dataset. */ } H5D_space_status_t; //! @@ -100,10 +101,10 @@ typedef enum H5D_space_status_t { * Values for time of writing fill value property */ typedef enum H5D_fill_time_t { - H5D_FILL_TIME_ERROR = -1, - H5D_FILL_TIME_ALLOC = 0, - H5D_FILL_TIME_NEVER = 1, - H5D_FILL_TIME_IFSET = 2 + H5D_FILL_TIME_ERROR = -1, /**< Error */ + H5D_FILL_TIME_ALLOC = 0, /**< Fill on allocation */ + H5D_FILL_TIME_NEVER = 1, /**< Never write fill values */ + H5D_FILL_TIME_IFSET = 2 /**< Fill if fill-value was set */ } H5D_fill_time_t; //! @@ -112,10 +113,10 @@ typedef enum H5D_fill_time_t { * Values for fill value status */ typedef enum H5D_fill_value_t { - H5D_FILL_VALUE_ERROR = -1, - H5D_FILL_VALUE_UNDEFINED = 0, - H5D_FILL_VALUE_DEFAULT = 1, - H5D_FILL_VALUE_USER_DEFINED = 2 + H5D_FILL_VALUE_ERROR = -1, /**< Error */ + H5D_FILL_VALUE_UNDEFINED = 0, /**< No fill value defined */ + H5D_FILL_VALUE_DEFAULT = 1, /**< Default fill-value */ + H5D_FILL_VALUE_USER_DEFINED = 2 /**< User-defined fill-value */ } H5D_fill_value_t; //! @@ -124,22 +125,40 @@ typedef enum H5D_fill_value_t { * Values for VDS bounds option */ typedef enum H5D_vds_view_t { - H5D_VDS_ERROR = -1, - H5D_VDS_FIRST_MISSING = 0, - H5D_VDS_LAST_AVAILABLE = 1 + H5D_VDS_ERROR = -1, /**< Error */ + H5D_VDS_FIRST_MISSING = 0, /**< Include all data before the first missing mapped data */ + H5D_VDS_LAST_AVAILABLE = 1 /**< Include all available mapped data */ } H5D_vds_view_t; //! //! /** - * Callback for H5Pset_append_flush() in a dataset access property list + * \brief Callback for H5Pset_append_flush() + * + * \dset_id{dataset_id} + * \param[in] cur_dims The current extent of the dataset's dimensions + * \param[in,out] op_data User context + * + * \return \herr_t + * */ typedef herr_t (*H5D_append_cb_t)(hid_t dataset_id, hsize_t *cur_dims, void *op_data); //! //! /** - * Define the operator function pointer for H5Diterate() + * \brief Callback for H5Diterate() + * + * \param[in,out] elem Pointer to the memory buffer containing the current dataset + * element + * \param[in] type_id Datatype identifier of the elements stored in \p elem + * \param[in] ndim Number of dimensions for the \p point array + * \param[in] point Array containing the location of the element within + * the original dataspace + * \param[in,out] operator_data Pointer to any user-defined data associated with + * the operation + * \return \herr_t_iter + * */ typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data); @@ -147,7 +166,29 @@ typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim, const //! /** - * Define the operator function pointer for H5Dscatter() + * \brief Callback for H5Dscatter() + * + * \param[out] src_buf Pointer to the buffer holding the next set of elements to + * scatter. On entry, the value of where \p src_buf points to + * is undefined. The callback function should set \p src_buf + * to point to the next set of elements. + * \param[out] src_buf_bytes_used Pointer to the number of valid bytes in \p src_buf. + * On entry, the value where \p src_buf_bytes_used points + * to is undefined. The callback function should set + * \p src_buf_bytes_used to the of valid bytes in \p src_buf. + * This number must be a multiple of the datatype size. + * \param[in,out] op_data User-defined pointer to data required by the callback + * function. A pass-through of the \p op_data pointer provided + * with the H5Dscatter() function call. + * \return herr_t + * + * \details The callback function should always return at least one + * element in \p src_buf, and must not return more elements + * than are remaining to be scattered. This function will be + * repeatedly called until all elements to be scattered have + * been returned. The callback function should return zero (0) + * to indicate success, and a negative value to indicate failure. + * */ typedef herr_t (*H5D_scatter_func_t)(const void **src_buf /*out*/, size_t *src_buf_bytes_used /*out*/, void *op_data); @@ -155,11 +196,52 @@ typedef herr_t (*H5D_scatter_func_t)(const void **src_buf /*out*/, size_t *src_b //! /** - * Define the operator function pointer for H5Dgather() + * \brief Callback for H5Dgather() + * + * \param[in] dst_buf Pointer to the destination buffer which has been filled + * with the next set of elements gathered. This will always + * be identical to the \p dst_buf passed to H5Dgather() + * \param[in] dst_buf_bytes_used Pointer to the number of valid bytes in + * \p dst_buf. This number must be a multiple of + * the datatype size. + * \param[in,out] op_data User-defined pointer to data required by the callback + * function; a pass-through of the \p op_data pointer + * provided with the H5Dgather() function call. + * \returns \herr_t + * + * \details The callback function should process, store, or otherwise make use + * of the data returned in dst_buf before it returns, because the + * buffer will be overwritten unless it is the last call to the + * callback. This function will be repeatedly called until all gathered + * elements have been passed to the callback in dst_buf. The callback + * function should return zero (0) to indicate success, and a negative + * value to indicate failure. + * */ typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, size_t dst_buf_bytes_used, void *op_data); //! +//! +/** + * \brief Callback for H5Dchunk_iter() + * + * \param[in] offset Logical position of the chunk’s first element in units of dataset elements + * \param[in] filter_mask Bitmask indicating the filters used when the chunk was written + * \param[in] addr Chunk address in the file + * \param[in] size Chunk size in bytes, 0 if the chunk does not exist + * \param[in,out] op_data Pointer to any user-defined data associated with + * the operation. + * \returns \li Zero (#H5_ITER_CONT) causes the iterator to continue, returning + * zero when all elements have been processed. + * \li A positive value (#H5_ITER_STOP) causes the iterator to + * immediately return that value, indicating short-circuit success. + * \li A negative (#H5_ITER_ERROR) causes the iterator to immediately + * return that value, indicating failure. + */ +typedef int (*H5D_chunk_iter_op_t)(const hsize_t *offset, unsigned filter_mask, haddr_t addr, hsize_t size, + void *op_data); +//! + /********************/ /* Public Variables */ /********************/ @@ -178,7 +260,7 @@ extern "C" { * \brief Creates a new dataset and links it into the file * * \fgdta_loc_id - * \param[in] name Name of the dataset to create + * \param[in] name Name of the dataset to create * \type_id * \space_id * \lcpl_id @@ -197,39 +279,32 @@ extern "C" { * * \p loc_id may specify a file, group, dataset, named datatype, * or attribute. If an attribute, dataset, or named datatype is - * specified then the dataset will be created at the location + * specified, then the dataset will be created at the location * where the attribute, dataset, or named datatype is attached. * * \p name may be either an absolute path in the file or a relative * path from \p loc_id naming the dataset. * - * \p dtype_id specifies the datatype of each data element as stored - * in the file. If \p dtype_id is either a fixed-length or - * variable-length string, it is important to set the string length - * when defining the datatype. String datatypes are derived from - * #H5T_C_S1 (or #H5T_FORTRAN_S1 for Fortran codes), which defaults - * to 1 character in size. - * * If \p dtype_id is a committed datatype, and if the file location * associated with the committed datatype is different from the * file location where the dataset will be created, the datatype * is copied and converted to a transient type. * - * The link creation property list, \p lcpl_id, governs creation + * The link creation property list, \p lcpl_id, governs the creation * of the link(s) by which the new dataset is accessed and the - * creation of any * intermediate groups that may be missing. + * creation of any intermediate groups that may be missing. * * The datatype and dataspace properties and the dataset creation * and access property lists are attached to the dataset, so the * caller may derive new datatypes, dataspaces, and creation and * access properties from the old ones and reuse them in calls to * create additional datasets. Once created, the dataset can be - * read from or written to. Reading data from a datatset that was + * read from or written to. Reading data from a dataset that was * not previously written, the HDF5 library will return default * or user-defined fill values. * - * To conserve and release resources, the dataset should be closed - * when access is no longer required. + * \par Example + * \snippet H5D_examples.c create * * \since 1.8.0 * @@ -259,43 +334,23 @@ H5_DLL hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t spa * * \p loc_id may specify a file, group, dataset, named datatype, * or attribute. If an attribute, dataset, or named datatype is - * specified then the dataset will be created at the location + * specified, then the dataset will be created at the location * where the attribute, dataset, or named datatype is attached. * * The dataset’s datatype and dataspace are specified by * \p type_id and \p space_id, respectively. These are the - * datatype and dataspace of the dataset as it will exist in + * datatype and dataspace of the dataset as they will exist in * the file, which may differ from the datatype and dataspace * in application memory. * - * Dataset creation property list and dataset access creation - * property list are specified by \p dcpl_id and \p dapl_id. - * * H5Dcreate_anon() returns a new dataset identifier. Using * this identifier, the new dataset must be linked into the * HDF5 file structure with H5Olink() or it will be deleted - * from the file when the file is closed. - * - * See H5Dcreate2() for further details and considerations on - * the use of H5Dcreate2() and H5Dcreate_anon(). - * - * The differences between this function and H5Dcreate2() are - * as follows: - * \li H5Dcreate_anon() explicitly includes a dataset access property - * list. H5Dcreate() always uses default dataset access properties. - * - * \li H5Dcreate_anon() neither provides the new dataset’s name nor - * links it into the HDF5 file structure; those actions must be - * performed separately through a call to H5Olink(), which offers - * greater control over linking. - * - * A dataset created with this function should be closed with - * H5Dclose() when the dataset is no longer needed so that resource - * leaks will not develop. + * when the file is closed. * * \since 1.8.0 * - * \see H5Olink(), H5Dcreate(), Using Identifiers + * \see H5Olink(), H5Dcreate() * */ H5_DLL hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id); @@ -304,7 +359,7 @@ H5_DLL hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t d * -------------------------------------------------------------------------- * \ingroup H5D * - * \brief Creates a new dataset and links it into the file + * \brief Opens an existing dataset * * \fgdta_loc_id * \param[in] name Name of the dataset to open @@ -321,12 +376,6 @@ H5_DLL hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t d * specified then the dataset will be opened at the location * where the attribute, dataset, or named datatype is attached. * - * The dataset access property list, \p dapl_id, provides - * information regarding access to the dataset. - * - * To conserve and release resources, the dataset should be closed - * when access is no longer required. - * * \since 1.8.0 * * \see H5Dcreate2(), H5Dclose() @@ -352,6 +401,9 @@ H5_DLL hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id); * be released with H5Sclose() when the identifier is no longer * needed so that resource leaks will not occur. * + * \par Example + * \snippet H5D_examples.c update + * * \see H5Sclose() * */ @@ -360,7 +412,33 @@ H5_DLL hid_t H5Dget_space(hid_t dset_id); /** * -------------------------------------------------------------------------- * \ingroup H5D - * \todo Document this function! + * + * \brief Determines whether space has been allocated for a dataset + * + * \dset_id + * \param[out] allocation Space allocation status + * + * \return \herr_t + * + * \details H5Dget_space_status() determines whether space has been allocated + * for the dataset \p dset_id. + * + * \note \Bold{BUG:} Prior to the HDF5 1.14.0, 1.12.2 and 1.10.9 releases, + * H5Dget_space_status() may return incorrect space allocation status + * values for datasets with filters applied to them. + * H5Dget_space_status() calculated the space allocation status by + * comparing the sum of the sizes of all the allocated chunks in the + * dataset against the total data size of the dataset, as calculated by + * the number of elements in the dataset's dataspace multiplied by the + * dataset's datatype size. If the dataset had any compression filters + * applied to it and the dataset chunks were successfully compressed, + * the sum of the sizes of the allocated dataset chunks would generally + * always be less than the total data size of the dataset, and + * H5Dget_space_status() wouldn't ever return + * `H5D_SPACE_STATUS_ALLOCATED`. + * + * \since 1.6.0 + * */ H5_DLL herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation); @@ -379,27 +457,7 @@ H5_DLL herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) * * If a dataset has a named datatype, then an identifier to the * opened datatype is returned. Otherwise, the returned datatype - * is read-only. If atomization of the datatype fails, then the - * datatype is closed. - * - * A datatype identifier returned from this function should be - * released with H5Tclose() when the identifier is no longer - * needed to prevent resource leaks. - * - * \note Datatype Identifiers - * - * Please note that the datatype identifier is actually an object - * identifier or a handle returned from opening the datatype. It - * is not persistent and its value can be different from one HDF5 - * session to the next. - * - * H5Tequal() can be used to compare datatypes. - * - * HDF5 High Level APIs that may also be of interest are: - * - * H5LTdtype_to_text() creates a text description of a - * datatype. H5LTtext_to_dtype() creates an HDF5 datatype - * given a text description. + * is read-only. * */ H5_DLL hid_t H5Dget_type(hid_t dset_id); @@ -419,8 +477,8 @@ H5_DLL hid_t H5Dget_type(hid_t dset_id); * a copy of the dataset creation property list associated with * the dataset specified by \p dset_id. * - * The creation property list identifier should be released - * with H5Pclose() to prevent resource leaks. + * The creation property list identifier should be released with + * H5Pclose() to prevent resource leaks. * */ H5_DLL hid_t H5Dget_create_plist(hid_t dset_id); @@ -455,10 +513,6 @@ H5_DLL hid_t H5Dget_create_plist(hid_t dset_id); * All link access properties in the returned list will be set * to the default values. * - * The access property list identifier should be released with - * H5Pclose() when the identifier is no longer needed so that - * resource leaks will not develop. - * * \since 1.8.3 * */ @@ -477,11 +531,8 @@ H5_DLL hid_t H5Dget_access_plist(hid_t dset_id); * \details H5Dget_storage_size() returns the amount of storage, * in bytes, that is allocated in the file for the raw data of * the dataset specified by \p dset_id. - * - * \note The amount of storage in this case is the storage - * allocated in the written file, which will typically differ - * from the space required to hold a dataset in working memory. - * + * H5Dget_storage_size() reports only the space required to store + * the dataset elements, excluding any metadata. * \li For contiguous datasets, the returned size equals the current * allocated size of the raw data. * \li For unfiltered chunked datasets, the returned size is the @@ -491,21 +542,19 @@ H5_DLL hid_t H5Dget_access_plist(hid_t dset_id); * compression filter is in use, H5Dget_storage_size() will return * the total space required to store the compressed chunks. * - * H5Dget_storage_size() reports only the space required to store - * the data, not including that of any metadata. + * \note Note that H5Dget_storage_size() is not generally an + * appropriate function to use when determining the amount + * of memory required to work with a dataset. In such + * circumstances, you must determine the number of data + * points in a dataset and the size of an individual dataset + * element. H5Sget_simple_extent_npoints() and H5Tget_size() + * can be used to calculate that amount. * - * \attention H5Dget_storage_size() does not differentiate between 0 (zero), + * \warning H5Dget_storage_size() does not differentiate between 0 (zero), * the value returned for the storage size of a dataset * with no stored values, and 0 (zero), the value returned to * indicate an error. * - * \note Note that H5Dget_storage_size() is not generally an - * appropriate function to use when determining the amount - * of memory required to work with a dataset. In such - * circumstances, you must determine the number of data - * points in a dataset and the size of an individual data - * element. H5Sget_simple_extent_npoints() and H5Tget_size() - * can be used to get that information. * */ H5_DLL hsize_t H5Dget_storage_size(hid_t dset_id); @@ -562,7 +611,7 @@ H5_DLL herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hs * effect. Also, the implementation does not handle the #H5S_ALL * macro correctly. As a workaround, application can get * the dataspace for the dataset using H5Dget_space() and pass that - * in for \p fspace_id. This will be fixed in coming releases. + * in for \p fspace_id. This will be fixed in a future release. * * \since 1.10.5 * @@ -576,10 +625,10 @@ H5_DLL herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks * \brief Retrieves information about a chunk specified by its coordinates * * \dset_id - * \param[in] offset Logical position of the chunk’s first element - * \param[out] filter_mask Indicating filters used with the chunk when written + * \param[in] offset Logical position of the chunk’s first element in units of dataset elements + * \param[out] filter_mask Bitmask indicating the filters used when the chunk was written * \param[out] addr Chunk address in the file - * \param[out] size Chunk size in bytes, 0 if chunk doesn’t exist + * \param[out] size Chunk size in bytes, 0 if the chunk does not exist * * \return \herr_t * @@ -601,6 +650,34 @@ H5_DLL herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size); +/** + * -------------------------------------------------------------------------- + * \ingroup H5D + * + * \brief Iterate over all chunks of a chunked dataset + * + * \dset_id + * \param[in] dxpl_id Identifier of a transfer property list + * \param[in] cb User callback function, called for every chunk. + * \param[in] op_data User-defined pointer to data required by op + * + * \return \herr_t + * + * \details H5Dchunk_iter iterates over all chunks in the dataset, calling the + * user supplied callback with the details of the chunk and the supplied + * context \p op_data. + * + * \par Example + * For each chunk, print the allocated chunk size (0 for unallocated chunks). + * \snippet H5D_examples.c H5Dchunk_iter_cb + * Iterate over all chunked datasets and chunks in a file. + * \snippet H5D_examples.c H5Ovisit_cb + * + * \since 1.12.3 + * + */ +H5_DLL herr_t H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t cb, void *op_data); + /** * -------------------------------------------------------------------------- * \ingroup H5D @@ -610,39 +687,39 @@ H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, u * \dset_id * \param[in] fspace_id File dataspace selection identifier (See Note below) * \param[in] chk_idx Index of the chunk - * \param[out] offset Logical position of the chunk’s first element - * \param[out] filter_mask Indicating filters used with the chunk when written + * \param[out] offset Logical position of the chunk’s first element in units of dataset elements + * \param[out] filter_mask Bitmask indicating the filters used when the chunk was written * \param[out] addr Chunk address in the file - * \param[out] size Chunk size in bytes, 0 if chunk doesn’t exist + * \param[out] size Chunk size in bytes, 0 if the chunk does not exist * * \return \herr_t * - * \details H5Dget_chunk_info() retrieves the offset coordinates - * offset, filter mask filter_mask, size size and address addr for - * the dataset specified by the identifier dset_id and the chunk - * specified by the index index. The chunk belongs to a set of - * chunks in the selection specified by fspace_id. If the queried + * \details H5Dget_chunk_info() retrieves the offset coordinates, + * \p offset, filter mask, \p filter_mask, size, \p size, and address + * \p addr for the dataset specified by the identifier \p dset_id and the chunk + * specified by the index \p index. The chunk belongs to a set of + * chunks in the selection specified by \p fspace_id. If the queried * chunk does not exist in the file, the size will be set to 0 and - * address to \c HADDR_UNDEF. The value pointed to by filter_mask will - * not be modified. NULL can be passed in for any \p out parameters. + * address to HADDR_UNDEF. The value pointed to by filter_mask will + * not be modified. \c NULL can be passed in for any \p out parameters. * - * \p chk_idx is the chunk index in the selection. Index value + * \p chk_idx is the chunk index in the selection. The index value * may have a value of 0 up to the number of chunks stored in - * the file that have a nonempty intersection with the file - * dataspace selection + * the file that has a nonempty intersection with the file + * dataspace selection. * * \note As of 1.10.5, the dataspace intersection is not yet - * supported, hence, the index is of all the written chunks. + * supported. Hence, the index is of all the written chunks. * * \p fspace_id specifies the file dataspace selection. It is - * intended to take #H5S_ALL for specifying the current selection. + * intended to take #H5S_ALL to specify the current selection. * * \note Please be aware that this function currently does not - * support non-trivial selections, thus \p fspace_id has no + * support non-trivial selections; thus \p fspace_id has no * effect. Also, the implementation does not handle the #H5S_ALL - * macro correctly. As a workaround, application can get + * macro correctly. As a workaround, an application can get * the dataspace for the dataset using H5Dget_space() and pass that - * in for \p fspace_id. This will be fixed in coming releases. + * in for \p fspace_id. This will be fixed in a future release. * * \since 1.10.5 * @@ -658,7 +735,7 @@ H5_DLL herr_t H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_idx, * * \dset_id * - * \return Returns the offset in bytes; otherwise, returns \c HADDR_UNDEF, + * \return Returns the offset in bytes; otherwise, returns HADDR_UNDEF, * a negative value. * * \details H5Dget_offset() returns the address in the file of @@ -707,9 +784,8 @@ H5_DLL haddr_t H5Dget_offset(hid_t dset_id); * used for the memory dataspace and the selection defined with \p * file_space_id is used for the selection within that dataspace. * - * If raw data storage space has not been allocated for the dataset - * and a fill value has been defined, the returned buffer \p buf - * is filled with the fill value. + * The number of elements selected in the memory dataspace \Emph{must} + * be equal to the number of elements selected in the file dataspace. * * The behavior of the library for the various combinations of * valid dataspace identifiers and #H5S_ALL for the \p mem_space_id @@ -754,14 +830,12 @@ H5_DLL haddr_t H5Dget_offset(hid_t dset_id); * * * - * \details Setting an #H5S_ALL selection indicates that the entire - * dataspace, as defined by the current dimensions of a dataspace, - * will be selected. The number of elements selected in the memory - * dataspace must match the number of elements selected in the - * file dataspace. + * \note If no storage space was allocated for the dataset + * and a fill value is defined, the returned buffer \p buf + * is filled with the fill value. * - * \p dxpl_id can be the constant #H5P_DEFAULT, in which case the - * default data transfer properties are used. + * \par Example + * \snippet H5D_examples.c read * */ H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, @@ -865,6 +939,8 @@ H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_ * time if the dataset's fill time is set to #H5D_FILL_TIME_IFSET * or #H5D_FILL_TIME_ALLOC. * + * \par_compr_note + * * \attention If a dataset's storage layout is 'compact', care must be * taken when writing data to the dataset in parallel. A compact * dataset's raw data is cached in memory and may be flushed @@ -872,6 +948,9 @@ H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_ * applications should always attempt to write identical data to * the dataset from all processes. * + * \par Example + * \snippet H5D_examples.c update + * * \see H5Pset_fill_time(), H5Pset_alloc_time() * */ @@ -903,13 +982,8 @@ H5_DLL herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid * pipeline, including filters, and will be written directly to * the file. Only one chunk can be written with this function. * - * H5Dwrite_chunk() replaces the now deprecated H5DOwrite_chunk() - * function, which was located in the high level optimization - * library. The parameters and behavior are identical to the - * original. - * * \p filters is a mask providing a record of which filters are - * used with the the chunk. The default value of the mask is + * used with the chunk. The default value of the mask is * zero (0), indicating that all enabled filters are applied. A * filter is skipped if the bit corresponding to the filter’s * position in the pipeline (0 ≤ position < 32) is turned on. @@ -935,11 +1009,10 @@ H5_DLL herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid * in a file. H5Dwrite_chunk() bypasses hyperslab selection, the * conversion of data from one datatype to another, and the filter * pipeline to write the chunk. Developers should have experience - * with these processes before using this function. Please see - * Using the Direct Chunk Write Function for more information. + * with these processes before using this function. * - * \note H5Dread_chunk() and H5Dwrite_chunk() are not supported under - * parallel and do not support variable length types. + * \note H5Dread_chunk() and H5Dwrite_chunk() are currently not supported + * with parallel HDF5 and do not support variable-length types. * * \since 1.10.2 * @@ -977,10 +1050,10 @@ H5_DLL herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, con * the dimension limits and must specify a point that falls on * a dataset chunk boundary. * - * The mask \p filters indicates which filters are used with the - * chunk when written. A zero value indicates that all enabled - * filters are applied on the chunk. A filter is skipped if the - * bit corresponding to the filter’s position in the pipeline + * The mask \p filters indicates which filters were used when the + * chunk was written. A zero value (all bits 0) indicates that all + * enabled filters are applied on the chunk. A filter is skipped if + * the bit corresponding to the filter’s position in the pipeline * (0 ≤ position < 32) is turned on. * * \p buf is the memory buffer containing the chunk read from @@ -994,8 +1067,8 @@ H5_DLL herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, con * with these processes before using this function. Please see * Using the Direct Chunk Write Function for more information. * - * \note H5Dread_chunk() and H5Dwrite_chunk() are not supported under - * parallel and do not support variable length types. + * \note H5Dread_chunk() and H5Dwrite_chunk() are currently not supported + * with parallel HDF5 and do not support variable-length datatypes. * * \since 1.10.2 * @@ -1025,53 +1098,12 @@ H5_DLL herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, * in the memory buffer \p buf, executing the callback function * \p op once for each such data element. * - * The prototype of the callback function \p op is as follows - * (as defined in the source code file H5Lpublic.h): - * \snippet this H5D_operator_t_snip - * The parameters of this callback function are: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
\c elem[in,out]Pointer to the memory buffer containing the current - * data element
\c type_id[in]Datatype identifier of the elements stored in elem
\c ndim[in]Number of dimensions for the point array
\c point[in]Array containing the location of the element within - * the original dataspace
\c operator_data[in,out]Pointer to any user-defined data associated with the - * operation
- * - * The possible return values from the callback function, and - * the effect ofeach,are as follows: - * - * \li Zero causes the iterator to continue, returning zero - * when all data elements have been processed. - * \li A positive value causes the iterator to immediately - * return that positive value, indicating short-circuit success. - * \li A negative value causes the iterator to immediately return - * that value, indicating failure. - * - * The \p operator_data parameter is a user-defined pointer to - * the data required to process dataset elements in the course - * of the iteration. If operator needs to pass data back to the - * application, such data can be returned in this same buffer. This - * pointer is passed back to each step of the iteration in the - * operator callback function’s operator_data parameter. - * - * Unlike other HDF5 iterators, this iteration operation cannot - * be restarted at the point of exit; a second H5Diterate() - * call will always restart at the beginning. + * \attention Unlike other HDF5 iterators, this iteration operation cannot + * be restarted at the point of exit; a second H5Diterate() + * call will always restart at the beginning. * + * \warning Modifying the selection of \p space_id during iteration + * will lead to undefined behavior. * * \since 1.10.2 * @@ -1120,30 +1152,25 @@ H5_DLL herr_t H5Dvlen_get_buf_size(hid_t dset_id, hid_t type_id, hid_t space_id, * * \return \herr_t * - * \details H5Dfill() fills the dataspace selection in memory, \p space_id, + * \details H5Dfill() fills the dataspace selection, \p space_id, in memory * with the fill value specified in \p fill. If \p fill is NULL, * a fill value of 0 (zero) is used. * * \p fill_type_id specifies the datatype of the fill value. - * \p buf specifies the buffer in which the dataspace elements - * will be written. - * \p buf_type_id specifies the datatype of those data elements. + * \p buf specifies the buffer in which the fill elements + * will be written. \p buf_type_id specifies the datatype of + * those data elements. * * \note Note that if the fill value datatype differs from the memory - * buffer datatype, the fill value will be converted to the memory - * buffer datatype before filling the selection. + * buffer datatype, the fill value will be converted to the memory + * buffer datatype before filling the selection. * * \note Applications sometimes write data only to portions of an - * allocated dataset. It is often useful in such cases to fill - * the unused space with a known fill value. See the following - * function for more information: - * - H5Pset_fill_value() - * - H5Pget_fill_value() - * - H5Pfill_value_defined() - * - H5Pset_fill_time() - * - H5Pget_fill_time() - * - H5Pcreate() - * - H5Pcreate_anon() + * allocated dataset. It is often useful in such cases to fill + * the unused space with a known fill value. + * + * \see H5Pset_fill_value(), H5Pget_fill_value(), H5Pfill_value_defined(), + * H5Pset_fill_time(), H5Pget_fill_time(), H5Pcreate(), H5Dcreate_anon() * */ H5_DLL herr_t H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_t space_id); @@ -1190,22 +1217,21 @@ H5_DLL herr_t H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf * - If the dataset’s fill time is set to #H5D_FILL_TIME_ALLOC * (see H5Pset_alloc_time()) * - * \note - * \li If the sizes specified in \p size array are smaller than - * the dataset’s current dimension sizes, H5Dset_extent() will reduce - * the dataset’s dimension sizes to the specified values. It is the - * user application’s responsibility to ensure that valuable data is - * not lost as H5Dset_extent() does not check. + * \note If the sizes specified in \p size array are smaller than the dataset’s + * current dimension sizes, H5Dset_extent() will reduce the dataset’s + * dimension sizes to the specified values. It is the user application’s + * responsibility to ensure that valuable data is not lost as + * H5Dset_extent() does not check. * - * \li Except for external datasets, H5Dset_extent() is for use with - * chunked datasets only, not contiguous datasets. + * \note Except for external datasets, H5Dset_extent() is for use with + * chunked datasets only, not contiguous datasets. * - * \li A call to H5Dset_extent() affects the dataspace of a dataset. - * If a dataspace handle was opened for a dataset prior to a call to - * H5Dset_extent() then that dataspace handle will no longer reflect - * the correct dataspace extent of the dataset. H5Dget_space() must - * be called (after closing the previous handle) to obtain the current - * dataspace extent. + * \note A call to H5Dset_extent() affects the dataspace of a dataset. If a + * dataspace handle was opened for a dataset prior to a call to + * H5Dset_extent() then that dataspace handle will no longer reflect the + * correct dataspace extent of the dataset. H5Dget_space() must be called + * (after closing the previous handle) to obtain the current dataspace + * extent. * * \since 1.8.0 * @@ -1232,6 +1258,8 @@ H5_DLL herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]); * open files. After that, the OS is responsible for ensuring * that the data is actually flushed to disk. * + * \since 1.10.0 + * */ H5_DLL herr_t H5Dflush(hid_t dset_id); @@ -1278,7 +1306,7 @@ H5_DLL herr_t H5Drefresh(hid_t dset_id); * \p op and scatters it to the supplied buffer \p dst_buf in a * manner similar to data being written to a dataset. * - * \p dst_space_id is a dataspace which defines the extent of \p + * \p dst_space_id is a dataspace that defines the extent of \p * dst_buf and the selection within it to scatter the data to. * * \p type_id is the datatype of the data to be scattered in both @@ -1290,40 +1318,7 @@ H5_DLL herr_t H5Drefresh(hid_t dset_id); * * To retrieve the data to be scattered, H5Dscatter() repeatedly * calls \p op, which should return a valid source buffer, until - * enough data to fill the selection has been retrieved. The - * prototype of the callback function \p op is as follows (as - * defined in the source code file H5Dpublic.h): - * \snippet this H5D_scatter_func_t_snip - * The parameters of this callback function are described below: - * - * - * - * - * - * - * - * - * - * - * - *
\c src_buf[out]Pointer to the buffer holding the next set of elements to - * scatter. On entry, the value of where \c src_buf points to - * is undefined. The callback function should set \c src_buf - * to point to the next set of elements.
\c src_buf_bytes_used[out]Pointer to the number of valid bytes in \c src_buf. On - * entry, the value where \c src_buf_bytes_used points to is - * undefined. The callback function should set - * \c src_buf_bytes_used to the of valid bytes in \c src_buf. - * This number must be a multiple of the datatype size. - *
\c op_data[in,out]User-defined pointer to data required by the callback - * function. A pass-through of the \c op_data pointer provided - * with the H5Dscatter() function call.
- * - * The callback function should always return at least one - * element in \p src_buf, and must not return more elements - * than are remaining to be scattered. This function will be - * repeatedly called until all elements to be scattered have - * been returned. The callback function should return zero (0) - * to indicate success, and a negative value to indicate failure. + * enough data to fill the selection has been retrieved. * * \since 1.10.2 * @@ -1368,34 +1363,16 @@ H5_DLL herr_t H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hi * enough to hold all the data if the callback function \p op is * not provided. * - * \p op is a callback function which handles the gathered data. + * \p op is a callback function that handles the gathered data. * It is optional if \p dst_buf is large enough to hold all of the * gathered data; required otherwise. * * If no callback function is provided, H5Dgather() simply gathers * the data into \p dst_buf and returns. If a callback function is * provided, H5Dgather() repeatedly gathers up to \p dst_buf_size - * bytes to process the serialized data. The prototype of the - * callback function \p op is as follows (as defined in the source - * code file H5Dpublic.h): - * \snippet this H5D_gather_func_t_snip - * The parameters of this callback function are described in the - * table below. - * - * - * - * - * - * - * - *
\c dst_bufPointer to the destination buffer which has been filled - * with the next set of elements gathered. This will always be - * identical to the \p dst_buf passed to H5Dgather().
\c dst_buf_bytes_usedPointer to the number of valid bytes in \p dst_buf. - * This number must be a multiple of the datatype - * size.
\c op_dataUser-defined pointer to data required by the callback - * function; a pass-through of the \p op_data pointer - * provided with the H5Dgather() function call.
- * The callback function should process, store, or otherwise, + * bytes to process the serialized data. + * + * The callback function \p op should process, store, or otherwise, * make use of the data returned in \p dst_buf before it returns, * because the buffer will be overwritten unless it is the last * call to the callback. This function will be repeatedly called @@ -1419,11 +1396,11 @@ H5_DLL herr_t H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, * * \return \herr_t * - * \details H5Dclose() ends access to a dataset specified by \p dset_id - * and releases resources used by it. + * \details H5Dclose() terminates access to a dataset via the identifier + * \p dset_id and releases the underlying resources. * - * \attention Further use of a released dataset identifier is illegal; a - * function using such an identifier will generate an error. + * \par Example + * \snippet H5D_examples.c read * * \since 1.8.0 * @@ -1432,10 +1409,12 @@ H5_DLL herr_t H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, */ H5_DLL herr_t H5Dclose(hid_t dset_id); +/// \cond DEV /* Internal API routines */ H5_DLL herr_t H5Ddebug(hid_t dset_id); H5_DLL herr_t H5Dformat_convert(hid_t dset_id); H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); +/// \endcond /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -1476,8 +1455,7 @@ H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); * * \return \hid_t{dataset} * - * \deprecated This function is deprecated in favor of the function H5Dcreate2() - * or the macro H5Dcreate(). + * \deprecation_note{H5Dcreate2() or the macro H5Dcreate()} * * \details H5Dcreate1() creates a data set with a name, \p name, in the * location specified by the identifier \p loc_id. \p loc_id may be a @@ -1515,10 +1493,10 @@ H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); * * H5Dcreate() and H5Dcreate_anon() return a dataset identifier for * success or a negative value for failure. The dataset identifier - * should eventually be closed by calling H5Dclose() to release + * should eventually be closed by calling H5Dclose() to release the * resources it uses. * - * See H5Dcreate_anon() for discussion of the differences between + * See H5Dcreate_anon() for a discussion of the differences between * H5Dcreate() and H5Dcreate_anon(). * * The HDF5 library provides flexible means of specifying a fill value, @@ -1543,8 +1521,7 @@ H5_DLL hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t spa * * \return \hid_t{dataset} * - * \deprecated This function is deprecated in favor of the function H5Dopen2() - * or the macro H5Dopen(). + * \deprecation_note{H5Dopen2() or the macro H5Dopen()} * * \details H5Dopen1() opens an existing dataset for access at the location * specified by \p loc_id. \p loc_id may be a file, group, dataset, @@ -1574,10 +1551,10 @@ H5_DLL hid_t H5Dopen1(hid_t loc_id, const char *name); * * \return \herr_t * - * \deprecated This function is deprecated in favor of the function H5Dset_extent(). + * \deprecation_note{H5Dset_extent()} * * \details H5Dextend() verifies that the dataset is at least of size \p size, - * extending it if necessary. The dimensionality of size is the same as + * extending it if necessary. The length of \p size is the same as * that of the dataspace of the dataset being changed. * * This function can be applied to the following datasets: @@ -1595,9 +1572,9 @@ H5_DLL hid_t H5Dopen1(hid_t loc_id, const char *name); * * This function ensures that the dataset dimensions are of at least * the sizes specified in size. The function H5Dset_extent() must be - * used if the dataset dimension sizes are are to be reduced. + * used if the dataset dimension sizes are to be reduced. * - * \version 1.8.0 Function Function deprecated in this release. Parameter size + * \version 1.8.0 Function deprecated in this release. Parameter size * syntax changed to \Code{const hsize_t size[]} in this release. * */ @@ -1615,8 +1592,7 @@ H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t size[]); * * \return \herr_t * - * \deprecated This function has been deprecated in HDF5-1.12 in favor of the - * function H5Treclaim(). + * \deprecation_note{H5Treclaim()} * * \details H5Dvlen_reclaim() reclaims memory buffers created to store VL * datatypes. @@ -1624,7 +1600,7 @@ H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t size[]); * The \p type_id must be the datatype stored in the buffer. The \p * space_id describes the selection for the memory buffer to free the * VL datatypes within. The \p dxpl_id is the dataset transfer property - * list which was used for the I/O transfer to create the buffer. And + * list that was used for the I/O transfer to create the buffer. And * \p buf is the pointer to the buffer to be reclaimed. * * The VL structures (\ref hvl_t) in the user's buffer are modified to @@ -1634,7 +1610,7 @@ H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t size[]); * frees them from the bottom up, releasing all the memory without * creating memory leaks. * - * \version 1.12.0 Routine was deprecated + * \version 1.12.0 Function was deprecated * */ H5_DLL herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t dxpl_id, void *buf); diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index 1888adb1d21..83b27973cd6 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -84,11 +83,11 @@ static herr_t H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, size_t nelmts, const void *_buf) { H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ - hsize_t * off = NULL; /* Pointer to sequence offsets */ + hsize_t *off = NULL; /* Pointer to sequence offsets */ hsize_t mem_off; /* Offset in memory */ size_t mem_curr_seq; /* "Current sequence" in memory */ size_t dset_curr_seq; /* "Current sequence" in dataset */ - size_t * len = NULL; /* Array to store sequence lengths */ + size_t *len = NULL; /* Array to store sequence lengths */ size_t orig_mem_len, mem_len; /* Length of sequence in memory */ size_t nseq; /* Number of sequences generated */ size_t nelem; /* Number of elements used in sequences */ @@ -181,11 +180,11 @@ static size_t H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, size_t nelmts, void *_buf /*out*/) { H5D_io_info_t tmp_io_info; /* Temporary I/O info object */ - hsize_t * off = NULL; /* Pointer to sequence offsets */ + hsize_t *off = NULL; /* Pointer to sequence offsets */ hsize_t mem_off; /* Offset in memory */ size_t mem_curr_seq; /* "Current sequence" in memory */ size_t dset_curr_seq; /* "Current sequence" in dataset */ - size_t * len = NULL; /* Pointer to sequence lengths */ + size_t *len = NULL; /* Pointer to sequence lengths */ size_t orig_mem_len, mem_len; /* Length of sequence in memory */ size_t nseq; /* Number of sequences generated */ size_t nelem; /* Number of elements used in sequences */ @@ -273,10 +272,10 @@ H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, size_t nel herr_t H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_buf /*out*/) { - uint8_t * buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */ + uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */ const uint8_t *tscat_buf = (const uint8_t *)_tscat_buf; - hsize_t * off = NULL; /* Pointer to sequence offsets */ - size_t * len = NULL; /* Pointer to sequence lengths */ + hsize_t *off = NULL; /* Pointer to sequence offsets */ + size_t *len = NULL; /* Pointer to sequence lengths */ size_t curr_len; /* Length of bytes left to process in sequence */ size_t nseq; /* Number of sequences generated */ size_t curr_seq; /* Current sequence being processed */ @@ -359,9 +358,9 @@ size_t H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf /*out*/) { const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */ - uint8_t * tgath_buf = (uint8_t *)_tgath_buf; - hsize_t * off = NULL; /* Pointer to sequence offsets */ - size_t * len = NULL; /* Pointer to sequence lengths */ + uint8_t *tgath_buf = (uint8_t *)_tgath_buf; + hsize_t *off = NULL; /* Pointer to sequence offsets */ + size_t *len = NULL; /* Pointer to sequence lengths */ size_t curr_len; /* Length of bytes left to process in sequence */ size_t nseq; /* Number of sequences generated */ size_t curr_seq; /* Current sequence being processed */ @@ -437,9 +436,9 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_tg */ 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 */ + void *buf = io_info->u.rbuf; /* Local pointer to application buffer */ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/ hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/ @@ -577,9 +576,9 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf */ 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 */ + const void *buf = io_info->u.wbuf; /* Local pointer to application buffer */ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/ hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */ H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/ @@ -745,7 +744,7 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, const H5D_type_info_ uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */ uint8_t *xdbuf; /* Pointer into dataset buffer */ hsize_t *off = NULL; /* Pointer to sequence offsets */ - size_t * len = NULL; /* Pointer to sequence lengths */ + size_t *len = NULL; /* Pointer to sequence lengths */ size_t src_stride, dst_stride, copy_size; size_t dxpl_vec_size; /* Vector length from API context's DXPL */ size_t vec_size; /* Vector length */ @@ -918,11 +917,11 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) herr_t H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_id, void *dst_buf) { - H5T_t * type; /* Datatype */ - H5S_t * dst_space; /* Dataspace */ + H5T_t *type; /* Datatype */ + H5S_t *dst_space; /* Dataspace */ H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ - const void * src_buf = NULL; /* Source (contiguous) data buffer */ + const void *src_buf = NULL; /* Source (contiguous) data buffer */ size_t src_buf_nbytes = 0; /* Size of src_buf */ size_t type_size; /* Datatype element size */ hssize_t nelmts; /* Number of remaining elements in selection */ @@ -1015,8 +1014,8 @@ herr_t H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf_size, void *dst_buf, H5D_gather_func_t op, void *op_data) { - H5T_t * type; /* Datatype */ - H5S_t * src_space; /* Dataspace */ + H5T_t *type; /* Datatype */ + H5S_t *src_space; /* Dataspace */ H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ size_t type_size; /* Datatype element size */ diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 7d2ead13202..747f771eb34 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -44,8 +43,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,17 +76,17 @@ 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 */ H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info */ hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */ - hsize_t * mem_off = NULL; /* Pointer to sequence offsets in memory */ - hsize_t * file_off = NULL; /* Pointer to sequence offsets in the file */ - size_t * mem_len = NULL; /* Pointer to sequence lengths in memory */ - size_t * file_len = NULL; /* Pointer to sequence lengths in the file */ + hsize_t *mem_off = NULL; /* Pointer to sequence offsets in memory */ + hsize_t *file_off = NULL; /* Pointer to sequence offsets in the file */ + size_t *mem_len = NULL; /* Pointer to sequence lengths in memory */ + size_t *file_len = NULL; /* Pointer to sequence lengths in the file */ size_t curr_mem_seq; /* Current memory sequence to operate on */ size_t curr_file_seq; /* Current file sequence to operate on */ size_t mem_nseq; /* Number of sequences generated in the file */ @@ -105,6 +104,9 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, co HDassert(io_info->store); HDassert(io_info->u.rbuf); + if (elmt_size == 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "invalid elmt_size of 0") + /* Check for only one element in selection */ if (nelmts == 1) { hsize_t single_mem_off; /* Offset in memory */ @@ -226,8 +228,6 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, co /* Decrement number of elements left to process */ HDassert(((size_t)tmp_file_len % elmt_size) == 0); - if (elmt_size == 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "Resulted in division by zero") nelmts -= ((size_t)tmp_file_len / elmt_size); } /* end while */ } /* end else */ @@ -256,6 +256,188 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, co FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__select_io() */ +/*------------------------------------------------------------------------- + * Function: H5D_select_io_mem + * + * Purpose: Perform memory copies directly between two memory buffers + * according to the selections in the `dst_space` and + * `src_space` dataspaces. + * + * Note: This routine is [basically] the same as H5D__select_io, + * with the only difference being that the readvv/writevv + * calls are exchanged for H5VM_memcpyvv calls. Changes should + * be made to both routines. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5D_select_io_mem(void *dst_buf, H5S_t *dst_space, const void *src_buf, H5S_t *src_space, size_t elmt_size, + size_t nelmts) +{ + H5S_sel_iter_t *dst_sel_iter = NULL; /* Destination dataspace iteration info */ + H5S_sel_iter_t *src_sel_iter = NULL; /* Source dataspace iteration info */ + hbool_t dst_sel_iter_init = FALSE; /* Destination dataspace selection iterator initialized? */ + hbool_t src_sel_iter_init = FALSE; /* Source dataspace selection iterator initialized? */ + hsize_t *dst_off = NULL; /* Pointer to sequence offsets in destination buffer */ + hsize_t *src_off = NULL; /* Pointer to sequence offsets in source buffer */ + size_t *dst_len = NULL; /* Pointer to sequence lengths in destination buffer */ + size_t *src_len = NULL; /* Pointer to sequence lengths in source buffer */ + size_t curr_dst_seq; /* Current destination buffer sequence to operate on */ + size_t curr_src_seq; /* Current source buffer sequence to operate on */ + size_t dst_nseq; /* Number of sequences generated for destination buffer */ + size_t src_nseq; /* Number of sequences generated for source buffer */ + size_t dxpl_vec_size; /* Vector length from API context's DXPL */ + size_t vec_size; /* Vector length */ + ssize_t bytes_copied; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(dst_buf); + HDassert(dst_space); + HDassert(src_buf); + HDassert(src_space); + + if (elmt_size == 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "invalid elmt_size of 0") + + /* Check for only one element in selection */ + if (nelmts == 1) { + hsize_t single_dst_off; /* Offset in dst_space */ + hsize_t single_src_off; /* Offset in src_space */ + size_t single_dst_len; /* Length in dst_space */ + size_t single_src_len; /* Length in src_space */ + + /* Get offset of first element in selections */ + if (H5S_SELECT_OFFSET(dst_space, &single_dst_off) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve destination selection offset") + if (H5S_SELECT_OFFSET(src_space, &single_src_off) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't retrieve source selection offset") + + /* Set up necessary information for I/O operation */ + dst_nseq = src_nseq = 1; + curr_dst_seq = curr_src_seq = 0; + single_dst_off *= elmt_size; + single_src_off *= elmt_size; + single_dst_len = single_src_len = elmt_size; + + /* Perform vectorized memcpy from src_buf to dst_buf */ + if ((bytes_copied = + H5VM_memcpyvv(dst_buf, dst_nseq, &curr_dst_seq, &single_dst_len, &single_dst_off, src_buf, + src_nseq, &curr_src_seq, &single_src_len, &single_src_off)) < 0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") + + HDassert(((size_t)bytes_copied % elmt_size) == 0); + } + else { + unsigned sel_iter_flags = H5S_SEL_ITER_GET_SEQ_LIST_SORTED | H5S_SEL_ITER_SHARE_WITH_DATASPACE; + size_t dst_nelem; /* Number of elements used in destination buffer sequences */ + size_t src_nelem; /* Number of elements used in source buffer sequences */ + + /* Get info from API context */ + if (H5CX_get_vec_size(&dxpl_vec_size) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "can't retrieve I/O vector size") + + /* Allocate the vector I/O arrays */ + if (dxpl_vec_size > H5D_IO_VECTOR_SIZE) + vec_size = dxpl_vec_size; + else + vec_size = H5D_IO_VECTOR_SIZE; + + if (NULL == (dst_len = H5FL_SEQ_MALLOC(size_t, vec_size))) + HGOTO_ERROR(H5E_IO, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") + if (NULL == (dst_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + HGOTO_ERROR(H5E_IO, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") + if (NULL == (src_len = H5FL_SEQ_MALLOC(size_t, vec_size))) + HGOTO_ERROR(H5E_IO, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array") + if (NULL == (src_off = H5FL_SEQ_MALLOC(hsize_t, vec_size))) + HGOTO_ERROR(H5E_IO, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array") + + /* Allocate the dataspace selection iterators */ + if (NULL == (dst_sel_iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate destination selection iterator") + if (NULL == (src_sel_iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate source selection iterator") + + /* Initialize destination selection iterator */ + if (H5S_select_iter_init(dst_sel_iter, dst_space, elmt_size, sel_iter_flags) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") + dst_sel_iter_init = TRUE; /* Destination selection iteration info has been initialized */ + + /* Initialize source selection iterator */ + if (H5S_select_iter_init(src_sel_iter, src_space, elmt_size, H5S_SEL_ITER_SHARE_WITH_DATASPACE) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") + src_sel_iter_init = TRUE; /* Source selection iteration info has been initialized */ + + /* Initialize sequence counts */ + curr_dst_seq = curr_src_seq = 0; + dst_nseq = src_nseq = 0; + + /* Loop, until all bytes are processed */ + while (nelmts > 0) { + /* Check if more destination buffer sequences are needed */ + if (curr_dst_seq >= dst_nseq) { + /* Get sequences for destination selection */ + if (H5S_SELECT_ITER_GET_SEQ_LIST(dst_sel_iter, vec_size, nelmts, &dst_nseq, &dst_nelem, + dst_off, dst_len) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "sequence length generation failed") + + /* Start at the beginning of the sequences again */ + curr_dst_seq = 0; + } + + /* Check if more source buffer sequences are needed */ + if (curr_src_seq >= src_nseq) { + /* Get sequences for source selection */ + if (H5S_SELECT_ITER_GET_SEQ_LIST(src_sel_iter, vec_size, nelmts, &src_nseq, &src_nelem, + src_off, src_len) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "sequence length generation failed") + + /* Start at the beginning of the sequences again */ + curr_src_seq = 0; + } /* end if */ + + /* Perform vectorized memcpy from src_buf to dst_buf */ + if ((bytes_copied = H5VM_memcpyvv(dst_buf, dst_nseq, &curr_dst_seq, dst_len, dst_off, src_buf, + src_nseq, &curr_src_seq, src_len, src_off)) < 0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vectorized memcpy failed") + + /* Decrement number of elements left to process */ + HDassert(((size_t)bytes_copied % elmt_size) == 0); + nelmts -= ((size_t)bytes_copied / elmt_size); + } + } + +done: + /* Release selection iterators */ + if (src_sel_iter) { + if (src_sel_iter_init && H5S_SELECT_ITER_RELEASE(src_sel_iter) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + + src_sel_iter = H5FL_FREE(H5S_sel_iter_t, src_sel_iter); + } + if (dst_sel_iter) { + if (dst_sel_iter_init && H5S_SELECT_ITER_RELEASE(dst_sel_iter) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + + dst_sel_iter = H5FL_FREE(H5S_sel_iter_t, dst_sel_iter); + } + + /* Release vector arrays, if allocated */ + if (src_off) + src_off = H5FL_SEQ_FREE(hsize_t, src_off); + if (src_len) + src_len = H5FL_SEQ_FREE(size_t, src_len); + if (dst_off) + dst_off = H5FL_SEQ_FREE(hsize_t, dst_off); + if (dst_len) + dst_len = H5FL_SEQ_FREE(size_t, dst_len); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_select_io_mem() */ + /*------------------------------------------------------------------------- * Function: H5D__select_read * @@ -270,7 +452,7 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size, size_t nelmts, co */ 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 +481,7 @@ H5D__select_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, */ 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/H5Dsingle.c b/src/H5Dsingle.c index 50cf6a12c43..b6692d2453d 100644 --- a/src/H5Dsingle.c +++ b/src/H5Dsingle.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -125,8 +124,14 @@ H5D__single_idx_init(const H5D_chk_idx_info_t *idx_info, const H5S_t H5_ATTR_UNU HDassert(idx_info->layout); HDassert(idx_info->storage); - if (idx_info->pline->nused) + if (idx_info->pline->nused) { idx_info->layout->flags |= H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER; + + if (!H5F_addr_defined(idx_info->storage->idx_addr)) { + idx_info->storage->u.single.nbytes = 0; + idx_info->storage->u.single.filter_mask = 0; + } + } else idx_info->layout->flags = 0; @@ -416,7 +421,7 @@ H5D__single_idx_delete(const H5D_chk_idx_info_t *idx_info) */ static herr_t H5D__single_idx_copy_setup(const H5D_chk_idx_info_t H5_ATTR_NDEBUG_UNUSED *idx_info_src, - const H5D_chk_idx_info_t * idx_info_dst) + const H5D_chk_idx_info_t *idx_info_dst) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dtest.c b/src/H5Dtest.c index f37682d3c32..1d9d2cae32b 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index beee8c691ab..7865e46e1b5 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -84,45 +84,56 @@ /* 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 */ static herr_t H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *virtual_ent, H5O_storage_virtual_srcdset_t *source_dset); -static herr_t H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t * virtual_ent, +static herr_t H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, H5O_storage_virtual_srcdset_t *source_dset); static herr_t H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, size_t *buf_size); static herr_t H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, - H5O_storage_virtual_name_seg_t * src); -static herr_t H5D__virtual_build_source_name(char * source_name, + H5O_storage_virtual_name_seg_t *src); +static herr_t H5D__virtual_build_source_name(char *source_name, const H5O_storage_virtual_name_seg_t *parsed_name, 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 */ @@ -195,7 +206,7 @@ H5D_virtual_check_mapping_pre(const H5S_t *vspace, const H5S_t *src_space, "can't get number of elements in non-unlimited dimension") if (nenu_vs != nenu_ss) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "numbers of elemnts in the non-unlimited dimensions is different for source and " + "numbers of elements in the non-unlimited dimensions is different for source and " "virtual spaces") } /* end if */ /* We will handle the printf case after parsing the source names */ @@ -228,7 +239,7 @@ H5D_virtual_check_mapping_post(const H5O_storage_virtual_ent_t *ent) { hsize_t nelmts_vs; /* Number of elements in virtual selection */ hsize_t nelmts_ss; /* Number of elements in source selection */ - H5S_t * tmp_space = NULL; /* Temporary dataspace */ + H5S_t *tmp_space = NULL; /* Temporary dataspace */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -271,9 +282,9 @@ H5D_virtual_check_mapping_post(const H5O_storage_virtual_ent_t *ent) else /* Make sure there are no printf substitutions */ if ((ent->psfn_nsubs > 0) || (ent->psdn_nsubs > 0)) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, - "printf specifier(s) in source name(s) without an unlimited virtual selection and " - "limited source selection") + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, + "printf specifier(s) in source name(s) without an unlimited virtual selection and " + "limited source selection") done: /* Free temporary space */ @@ -302,7 +313,7 @@ H5D_virtual_check_mapping_post(const H5O_storage_virtual_ent_t *ent) herr_t H5D_virtual_update_min_dims(H5O_layout_t *layout, size_t idx) { - H5O_storage_virtual_t * virt = &layout->storage.u.virt; + H5O_storage_virtual_t *virt = &layout->storage.u.virt; H5O_storage_virtual_ent_t *ent = &virt->list[idx]; H5S_sel_type sel_type; int rank; @@ -410,9 +421,9 @@ herr_t H5D__virtual_store_layout(H5F_t *f, H5O_layout_t *layout) { H5O_storage_virtual_t *virt = &layout->storage.u.virt; - uint8_t * heap_block = NULL; /* Block to add to heap */ - size_t * str_size = NULL; /* Array for VDS entry string lengths */ - uint8_t * heap_block_p; /* Pointer into the heap block, while encoding */ + uint8_t *heap_block = NULL; /* Block to add to heap */ + size_t *str_size = NULL; /* Array for VDS entry string lengths */ + uint8_t *heap_block_p; /* Pointer into the heap block, while encoding */ size_t block_size; /* Total size of block needed */ hsize_t tmp_nentries; /* Temp. variable for # of VDS entries */ uint32_t chksum; /* Checksum for heap data */ @@ -547,10 +558,10 @@ herr_t H5D__virtual_copy_layout(H5O_layout_t *layout) { H5O_storage_virtual_ent_t *orig_list = NULL; - H5O_storage_virtual_t * virt = &layout->storage.u.virt; + H5O_storage_virtual_t *virt = &layout->storage.u.virt; hid_t orig_source_fapl; hid_t orig_source_dapl; - H5P_genplist_t * plist; + H5P_genplist_t *plist; size_t i; herr_t ret_value = SUCCEED; @@ -881,7 +892,7 @@ static herr_t H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *virtual_ent, H5O_storage_virtual_srcdset_t *source_dset) { - H5F_t * src_file = NULL; /* Source file */ + H5F_t *src_file = NULL; /* Source file */ hbool_t src_file_open = FALSE; /* Whether we have opened and need to close src_file */ herr_t ret_value = SUCCEED; /* Return value */ @@ -972,7 +983,7 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *vir *------------------------------------------------------------------------- */ static herr_t -H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t * virtual_ent, +H5D__virtual_reset_source_dset(H5O_storage_virtual_ent_t *virtual_ent, H5O_storage_virtual_srcdset_t *source_dset) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1085,7 +1096,7 @@ H5D__virtual_str_append(const char *src, size_t src_len, char **p, char **buf, s /* Extend buffer if necessary */ if ((p_offset + src_len + (size_t)1) > *buf_size) { - char * tmp_buf; + char *tmp_buf; size_t tmp_buf_size; /* Calculate new size of buffer */ @@ -1130,14 +1141,14 @@ herr_t H5D_virtual_parse_source_name(const char *source_name, H5O_storage_virtual_name_seg_t **parsed_name, size_t *static_strlen, size_t *nsubs) { - H5O_storage_virtual_name_seg_t * tmp_parsed_name = NULL; + H5O_storage_virtual_name_seg_t *tmp_parsed_name = NULL; H5O_storage_virtual_name_seg_t **tmp_parsed_name_p = &tmp_parsed_name; size_t tmp_static_strlen; size_t tmp_strlen; size_t tmp_nsubs = 0; - const char * p; - const char * pct; - char * name_seg_p = NULL; + const char *p; + const char *pct; + char *name_seg_p = NULL; size_t name_seg_size = 0; herr_t ret_value = SUCCEED; /* Return value */ @@ -1246,8 +1257,8 @@ H5D_virtual_parse_source_name(const char *source_name, H5O_storage_virtual_name_ static herr_t H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, H5O_storage_virtual_name_seg_t *src) { - H5O_storage_virtual_name_seg_t * tmp_dst = NULL; - H5O_storage_virtual_name_seg_t * p_src = src; + H5O_storage_virtual_name_seg_t *tmp_dst = NULL; + H5O_storage_virtual_name_seg_t *p_src = src; H5O_storage_virtual_name_seg_t **p_dst = &tmp_dst; herr_t ret_value = SUCCEED; @@ -1334,7 +1345,7 @@ static herr_t H5D__virtual_build_source_name(char *source_name, const H5O_storage_virtual_name_seg_t *parsed_name, size_t static_strlen, size_t nsubs, hsize_t blockno, char **built_name) { - char * tmp_name = NULL; /* Name buffer */ + char *tmp_name = NULL; /* Name buffer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1352,7 +1363,7 @@ H5D__virtual_build_source_name(char *source_name, const H5O_storage_virtual_name } /* end if */ else { const H5O_storage_virtual_name_seg_t *name_seg = parsed_name; - char * p; + char *p; hsize_t blockno_down = blockno; size_t blockno_len = 1; size_t name_len; @@ -1482,7 +1493,7 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset) storage->list[i].source_dset.dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy source dataspace extent") - /* Get source space dimenstions */ + /* Get source space dimensions */ if (H5S_get_simple_extent_dims(storage->list[i].source_select, curr_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get source space dimensions") @@ -1960,7 +1971,7 @@ H5D__virtual_init_all(const H5D_t *dset) storage->list[i].source_dset.dset->shared->space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy source dataspace extent") - /* Get source space dimenstions */ + /* Get source space dimensions */ if (H5S_get_simple_extent_dims(storage->list[i].source_select, source_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get source space dimensions") @@ -2176,7 +2187,7 @@ herr_t H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) { H5O_storage_virtual_t *storage; /* Convenience pointer */ - H5P_genplist_t * dapl; /* Data access property list object pointer */ + H5P_genplist_t *dapl; /* Data access property list object pointer */ hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset (unused) */ size_t i; /* Local index variables */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2238,7 +2249,7 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) /* Retrieve VDS file FAPL to layout */ if (storage->source_fapl <= 0) { - H5P_genplist_t * source_fapl = NULL; /* Source file FAPL */ + H5P_genplist_t *source_fapl = NULL; /* Source file FAPL */ H5F_close_degree_t close_degree = H5F_CLOSE_WEAK; /* Close degree for source files */ if ((storage->source_fapl = H5F_get_access_plist(f, FALSE)) < 0) @@ -2254,7 +2265,7 @@ H5D__virtual_init(H5F_t *f, const H5D_t *dset, hid_t dapl_id) } /* end if */ #ifndef NDEBUG else { - H5P_genplist_t * source_fapl = NULL; /* Source file FAPL */ + H5P_genplist_t *source_fapl = NULL; /* Source file FAPL */ H5F_close_degree_t close_degree; /* Close degree for source files */ /* Get property list pointer */ @@ -2321,7 +2332,7 @@ H5D__virtual_is_space_alloc(const H5O_storage_t H5_ATTR_UNUSED *storage) * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner - * Wednessday, March 6, 2016 + * Wednesday, March 6, 2016 * *------------------------------------------------------------------------- */ @@ -2344,7 +2355,7 @@ H5D__virtual_is_data_cached(const H5D_shared_t *shared_dset) if (storage->list[i].psfn_nsubs || storage->list[i].psdn_nsubs) { /* Iterate over sub-source dsets */ for (j = storage->list[i].sub_dset_io_start; j < storage->list[i].sub_dset_io_end; j++) - /* Check for cahced data in source dset */ + /* Check for cached data in source dset */ if (storage->list[i].sub_dset[j].dset && storage->list[i].sub_dset[j].dset->shared->layout.ops->is_data_cached && storage->list[i].sub_dset[j].dset->shared->layout.ops->is_data_cached( @@ -2377,8 +2388,8 @@ H5D__virtual_is_data_cached(const H5D_shared_t *shared_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) +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 */ @@ -2665,10 +2676,10 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) else /* Close projected memory space */ if (storage->list[i].source_dset.projected_mem_space) { - if (H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") - storage->list[i].source_dset.projected_mem_space = NULL; - } /* end if */ + if (H5S_close(storage->list[i].source_dset.projected_mem_space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close temporary space") + storage->list[i].source_dset.projected_mem_space = NULL; + } /* end if */ /* Note the lack of a done: label. This is because there are no HGOTO_ERROR * calls. If one is added, a done: label must also be added */ @@ -2678,7 +2689,7 @@ H5D__virtual_post_io(H5O_storage_virtual_t *storage) /*------------------------------------------------------------------------- * Function: H5D__virtual_read_one * - * Purpose: Read from a singe source dataset in a virtual dataset. + * Purpose: Read from a single source dataset in a virtual dataset. * * Return: Non-negative on success/Negative on failure * @@ -2688,7 +2699,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,12 +2759,12 @@ H5D__virtual_read_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, *------------------------------------------------------------------------- */ 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 */ - H5S_t * fill_space = NULL; /* Space to fill with fill value */ + H5S_t *fill_space = NULL; /* Space to fill with fill value */ size_t i, j; /* Local index variables */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2794,7 +2805,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsiz else /* Read from source dataset */ if (H5D__virtual_read_one(io_info, type_info, file_space, &storage->list[i].source_dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read source dataset") + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "unable to read source dataset") } /* end for */ /* Fill unmapped part of buffer with fill value */ @@ -2868,7 +2879,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsiz /*------------------------------------------------------------------------- * Function: H5D__virtual_write_one * - * Purpose: Write to a singe source dataset in a virtual dataset. + * Purpose: Write to a single source dataset in a virtual dataset. * * Return: Non-negative on success/Negative on failure * @@ -2878,7 +2889,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsiz *------------------------------------------------------------------------- */ 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 +2952,7 @@ H5D__virtual_write_one(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, */ 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 */ @@ -2991,7 +3002,7 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsi else /* Write to source dataset */ if (H5D__virtual_write_one(io_info, type_info, file_space, &storage->list[i].source_dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write to source dataset") + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to write to source dataset") } /* end for */ done: @@ -3063,7 +3074,7 @@ H5D__virtual_flush(H5D_t *dset) herr_t H5D__virtual_hold_source_dset_files(const H5D_t *dset, H5D_virtual_held_file_t **head) { - H5O_storage_virtual_t * storage; /* Convenient pointer into layout struct */ + H5O_storage_virtual_t *storage; /* Convenient pointer into layout struct */ H5D_virtual_held_file_t *tmp; /* Temporary held file node */ size_t i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3212,9 +3223,9 @@ H5D__virtual_refresh_source_dsets(H5D_t *dset) else /* Check if source dataset is open */ if (storage->list[i].source_dset.dset) - /* Refresh source dataset */ - if (H5D__virtual_refresh_source_dset(&storage->list[i].source_dset.dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") + /* Refresh source dataset */ + if (H5D__virtual_refresh_source_dset(&storage->list[i].source_dset.dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5E.c b/src/H5E.c index bcadd6333f9..cf7f1473983 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -81,10 +80,11 @@ static ssize_t H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t s static int H5E__close_msg_cb(void *obj_ptr, hid_t obj_id, void *udata); static herr_t H5E__close_msg(H5E_msg_t *err); static H5E_msg_t *H5E__create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg); -static H5E_t * H5E__get_current_stack(void); +static H5E_t *H5E__get_current_stack(void); static herr_t H5E__set_current_stack(H5E_t *estack); static herr_t H5E__close_stack(H5E_t *err_stack); static ssize_t H5E__get_num(const H5E_t *err_stack); +static herr_t H5E__print2(hid_t err_stack, FILE *stream); /*********************/ /* Package Variables */ @@ -325,10 +325,10 @@ H5E__set_default_auto(H5E_t *stk) #endif /* H5_USE_16_API_DEFAULT */ stk->auto_op.func1 = stk->auto_op.func1_default = (H5E_auto1_t)H5Eprint1; - stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5Eprint2; + stk->auto_op.func2 = stk->auto_op.func2_default = (H5E_auto2_t)H5E__print2; stk->auto_op.is_default = TRUE; #else /* H5_NO_DEPRECATED_SYMBOLS */ - stk->auto_op.func2 = (H5E_auto2_t)H5Eprint2; + stk->auto_op.func2 = (H5E_auto2_t)H5E__print2; #endif /* H5_NO_DEPRECATED_SYMBOLS */ stk->auto_data = NULL; @@ -637,7 +637,7 @@ H5E__get_class_name(const H5E_cls_t *cls, char *name, size_t size) /* Set the user's buffer, if provided */ if (name) { - HDstrncpy(name, cls->cls_name, MIN((size_t)(len + 1), size)); + HDstrncpy(name, cls->cls_name, size); if ((size_t)len >= size) name[size - 1] = '\0'; } /* end if */ @@ -719,7 +719,7 @@ H5Eclose_msg(hid_t err_id) /*------------------------------------------------------------------------- * Function: H5E__close_msg * - * Purpose: Private function to close an error messge. + * Purpose: Private function to close an error message. * * Return: SUCCEED/FAIL * @@ -959,10 +959,10 @@ H5Eget_current_stack(void) static H5E_t * H5E__get_current_stack(void) { - H5E_t * current_stack; /* Pointer to the current error stack */ - H5E_t * estack_copy = NULL; /* Pointer to new error stack to return */ + H5E_t *current_stack; /* Pointer to the current error stack */ + H5E_t *estack_copy = NULL; /* Pointer to new error stack to return */ unsigned u; /* Local index variable */ - H5E_t * ret_value = NULL; /* Return value */ + H5E_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1078,7 +1078,7 @@ H5Eset_current_stack(hid_t err_stack) static herr_t H5E__set_current_stack(H5E_t *estack) { - H5E_t * current_stack; /* Default error stack */ + H5E_t *current_stack; /* Default error stack */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1209,7 +1209,7 @@ H5E__close_stack(H5E_t *estack) ssize_t H5Eget_num(hid_t error_stack_id) { - H5E_t * estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ ssize_t ret_value; /* Return value */ /* Don't clear the error stack! :-) */ @@ -1338,8 +1338,8 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid hid_t min_id, const char *fmt, ...) { va_list ap; /* Varargs info */ - H5E_t * estack; /* Pointer to error stack to modify */ - char * tmp = NULL; /* Buffer to place formatted description in */ + H5E_t *estack; /* Pointer to error stack to modify */ + char *tmp = NULL; /* Buffer to place formatted description in */ hbool_t va_started = FALSE; /* Whether the variable argument list is open */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1446,13 +1446,37 @@ H5Eclear2(hid_t err_stack) herr_t H5Eprint2(hid_t err_stack, FILE *stream) { - H5E_t *estack; /* Error stack to operate on */ herr_t ret_value = SUCCEED; /* Return value */ /* Don't clear the error stack! :-) */ FUNC_ENTER_API_NOCLEAR(FAIL) /*NO TRACE*/ + /* Print error stack */ + if ((ret_value = H5E__print2(err_stack, stream)) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Eprint2() */ + +/*------------------------------------------------------------------------- + * Function: H5E__print2 + * + * Purpose: Internal helper routine for H5Eprint2. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +static herr_t +H5E__print2(hid_t err_stack, FILE *stream) +{ + H5E_t *estack; /* Error stack to operate on */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + /* Need to check for errors */ if (err_stack == H5E_DEFAULT) { if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in @@ -1472,8 +1496,8 @@ H5Eprint2(hid_t err_stack, FILE *stream) HGOTO_ERROR(H5E_ERROR, H5E_CANTLIST, FAIL, "can't display error stack") done: - FUNC_LEAVE_API(ret_value) -} /* end H5Eprint2() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5E__print2() */ /*------------------------------------------------------------------------- * Function: H5Ewalk2 @@ -1491,7 +1515,7 @@ H5Eprint2(hid_t err_stack, FILE *stream) herr_t H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t stack_func, void *client_data) { - H5E_t * estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ H5E_walk_op_t op; /* Operator for walking error stack */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1541,7 +1565,7 @@ H5Ewalk2(hid_t err_stack, H5E_direction_t direction, H5E_walk2_t stack_func, voi herr_t H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) { - H5E_t * estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ H5E_auto_op_t op; /* Error stack function */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1604,7 +1628,7 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data) herr_t H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data) { - H5E_t * estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ H5E_auto_op_t op; /* Error stack operator */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5EA.c b/src/H5EA.c index 4d6b7c1167f..fe4de72795b 100644 --- a/src/H5EA.c +++ b/src/H5EA.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -116,39 +115,40 @@ H5FL_BLK_DEFINE(ea_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, - H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata)) +static H5EA_t * +H5EA__new(H5F_t *f, haddr_t ea_addr, hbool_t from_open, void *ctx_udata) +{ + H5EA_t *ea = NULL; /* Pointer to new extensible array */ + H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ + H5EA_t *ret_value = NULL; - /* Local variables */ - H5EA_t * ea = NULL; /* Pointer to new extensible array */ - H5EA_hdr_t *hdr = NULL; /* The extensible array header information */ + FUNC_ENTER_STATIC - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Allocate extensible array wrapper */ if (NULL == (ea = H5FL_CALLOC(H5EA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array info") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for extensible array info") /* Lock the array header into memory */ if (NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, "unable to load extensible array header") /* Check for pending array deletion */ if (from_open && hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open extensible array pending deletion") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTOPENOBJ, NULL, "can't open extensible array pending deletion") /* Point extensible array wrapper at header and bump it's ref count */ ea->hdr = hdr; if (H5EA__hdr_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") /* Increment # of files using this array header */ if (H5EA__hdr_fuse_incr(ea->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, + "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ ea->f = f; @@ -156,15 +156,16 @@ BEGIN_FUNC(STATIC, ERR, H5EA_t *, NULL, NULL, /* Set the return value */ ret_value = ea; - CATCH +done: if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, "unable to release extensible array header") if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(STATIC) /* end H5EA__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__new() */ /*------------------------------------------------------------------------- * Function: H5EA_create @@ -179,16 +180,16 @@ END_FUNC(STATIC) /* end H5EA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, - H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) - - /* Local variables */ +H5EA_t * +H5EA_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata) +{ H5EA_t *ea = NULL; /* Pointer to new extensible array */ haddr_t ea_addr; /* Array header address */ + H5EA_t *ret_value = NULL; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(cparam); @@ -197,22 +198,23 @@ BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, /* Create extensible array header */ if (HADDR_UNDEF == (ea_addr = H5EA__hdr_create(f, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "can't create extensible array header") /* Allocate and initialize new extensible array wrapper */ if (NULL == (ea = H5EA__new(f, ea_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; - CATCH - +done: if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_create() */ /*------------------------------------------------------------------------- * Function: H5EA_open @@ -227,31 +229,33 @@ END_FUNC(PRIV) /* end H5EA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5EA_t *, NULL, NULL, H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) +H5EA_t * +H5EA_open(H5F_t *f, haddr_t ea_addr, void *ctx_udata) +{ + H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ + H5EA_t *ret_value = NULL; - /* Local variables */ - H5EA_t *ea = NULL; /* Pointer to new extensible array wrapper */ + FUNC_ENTER_NOAPI(NULL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Allocate and initialize new extensible array wrapper */ if (NULL == (ea = H5EA__new(f, ea_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for extensible array wrapper") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for extensible array wrapper") /* Set the return value */ ret_value = ea; - CATCH - +done: if (!ret_value) if (ea && H5EA_close(ea) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close extensible array") + HDONE_ERROR(H5E_EARRAY, H5E_CLOSEERROR, NULL, "unable to close extensible array") -END_FUNC(PRIV) /* end H5EA_open() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_open() */ /*------------------------------------------------------------------------- * Function: H5EA_get_nelmts @@ -265,20 +269,20 @@ END_FUNC(PRIV) /* end H5EA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts)) - - /* Local variables */ +herr_t +H5EA_get_nelmts(const H5EA_t *ea, hsize_t *nelmts) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(nelmts); /* Retrieve the max. index set */ *nelmts = ea->hdr->stats.stored.max_idx_set; -END_FUNC(PRIV) /* end H5EA_get_nelmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_nelmts() */ /*------------------------------------------------------------------------- * Function: H5EA_get_addr @@ -292,13 +296,12 @@ END_FUNC(PRIV) /* end H5EA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_addr(const H5EA_t *ea, haddr_t *addr)) - - /* Local variables */ +herr_t +H5EA_get_addr(const H5EA_t *ea, haddr_t *addr) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(ea->hdr); HDassert(addr); @@ -306,7 +309,8 @@ BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_addr(const H5EA_t *ea, hadd /* Retrieve the address of the extensible array's header */ *addr = ea->hdr->addr; -END_FUNC(PRIV) /* end H5EA_get_addr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_addr() */ /*------------------------------------------------------------------------- * Function: H5EA__lookup_elmt @@ -321,25 +325,25 @@ END_FUNC(PRIV) /* end H5EA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned thing_acc, - void **thing, uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, - H5EA__unprotect_func_t *thing_unprot_func)) - - /* Local variables */ - H5EA_hdr_t * hdr = ea->hdr; /* Header for EA */ - H5EA_iblock_t * iblock = NULL; /* Pointer to index block for EA */ - H5EA_sblock_t * sblock = NULL; /* Pointer to super block for EA */ - H5EA_dblock_t * dblock = NULL; /* Pointer to data block for EA */ +static herr_t +H5EA__lookup_elmt(const H5EA_t *ea, hsize_t idx, hbool_t will_extend, unsigned thing_acc, void **thing, + uint8_t **thing_elmt_buf, hsize_t *thing_elmt_idx, + H5EA__unprotect_func_t *thing_unprot_func) +{ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block for EA */ + H5EA_sblock_t *sblock = NULL; /* Pointer to super block for EA */ + H5EA_dblock_t *dblock = NULL; /* Pointer to data block for EA */ H5EA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for EA */ unsigned iblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting index block */ unsigned sblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting super block */ hbool_t stats_changed = FALSE; /* Whether array statistics changed */ hbool_t hdr_dirty = FALSE; /* Whether the array header changed */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_STATIC + + /* Check arguments */ HDassert(ea); HDassert(hdr); HDassert(thing); @@ -365,17 +369,18 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Create the index block */ hdr->idx_blk_addr = H5EA__iblock_create(hdr, &stats_changed); if (!H5F_addr_defined(hdr->idx_blk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, "unable to create index block") hdr_dirty = TRUE; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Check if element is in index block */ if (idx < hdr->cparam.idx_blk_elmts) { @@ -416,21 +421,23 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, dblk_addr = H5EA__dblock_create(hdr, iblock, &stats_changed, dblk_off, hdr->sblk_info[sblk_idx].dblk_nelmts); if (!H5F_addr_defined(dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array data block") /* Set data block address in index block */ iblock->dblk_addrs[dblk_idx] = dblk_addr; iblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, iblock, iblock->dblk_addrs[dblk_idx], hdr->sblk_info[sblk_idx].dblk_nelmts, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)iblock->dblk_addrs[dblk_idx]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)iblock->dblk_addrs[dblk_idx]) /* Adjust index to offset in data block */ elmt_idx %= hdr->sblk_info[sblk_idx].dblk_nelmts; @@ -438,9 +445,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check if there is already a dependency on the header */ if (will_extend && !dblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block and header, index = %llu", - (unsigned long long)idx) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block and header, index = %llu", + (unsigned long long)idx) dblock->has_hdr_depend = TRUE; } /* end if */ @@ -465,21 +473,23 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Create super block */ sblk_addr = H5EA__sblock_create(hdr, iblock, &stats_changed, sblk_idx); if (!H5F_addr_defined(sblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array super block") /* Set super block address in index block */ iblock->sblk_addrs[sblk_off] = sblk_addr; iblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect super block */ if (NULL == (sblock = H5EA__sblock_protect(hdr, iblock, iblock->sblk_addrs[sblk_off], sblk_idx, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)iblock->sblk_addrs[sblk_off]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)iblock->sblk_addrs[sblk_off]) /* Compute the data block index in super block */ dblk_idx = (size_t)(elmt_idx / sblock->dblk_nelmts); @@ -498,7 +508,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, dblk_addr = H5EA__dblock_create(hdr, sblock, &stats_changed, dblk_off, sblock->dblk_nelmts); if (!H5F_addr_defined(dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array data block") /* Set data block address in index block */ sblock->dblk_addrs[dblk_idx] = dblk_addr; @@ -508,8 +519,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, */ if (will_extend && !sblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between super block and header, address " "= %llu", (unsigned long long)sblock->addr) @@ -517,7 +528,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, } /* end if */ } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Adjust index to offset in data block */ @@ -548,29 +559,29 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, if (0 == (thing_acc & H5AC__READ_ONLY_FLAG)) { /* i.e. r/w access */ /* Create the data block page */ if (H5EA__dblk_page_create(hdr, sblock, dblk_page_addr) < 0) - H5E_THROW(H5E_CANTCREATE, "unable to create data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, "unable to create data block page") /* Mark data block page as initialized in super block */ H5VM_bit_set(sblock->page_init, page_init_idx, TRUE); sblock_cache_flags |= H5AC__DIRTIED_FLAG; } /* end if */ else - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ /* Protect data block page */ if (NULL == (dblk_page = H5EA__dblk_page_protect(hdr, sblock, dblk_page_addr, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect extensible array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Check if there is already a dependency on the header */ if (will_extend && !dblk_page->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block page and header, " - "index = %llu", - (unsigned long long)idx) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block page and header, " + "index = %llu", + (unsigned long long)idx) dblk_page->has_hdr_depend = TRUE; } /* end if */ @@ -584,15 +595,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, sblock, sblock->dblk_addrs[dblk_idx], sblock->dblk_nelmts, thing_acc))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect extensible array data block, address = %llu", - (unsigned long long)sblock->dblk_addrs[dblk_idx]) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)sblock->dblk_addrs[dblk_idx]) /* Check if there is already a dependency on the header */ if (will_extend && !dblock->has_hdr_depend) { if (H5EA__create_flush_depend((H5AC_info_t *)hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, index = %llu", (unsigned long long)idx) dblock->has_hdr_depend = TRUE; @@ -611,7 +622,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, HDassert(*thing != NULL); HDassert(*thing_unprot_func != NULL); - CATCH +done: /* Reset 'thing' info on error */ if (ret_value < 0) { *thing = NULL; @@ -627,20 +638,22 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check for header modified */ if (hdr_dirty) if (H5EA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") + HDONE_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, + "unable to mark extensible array header as modified") /* Release resources */ if (iblock && *thing != iblock && H5EA__iblock_unprotect(iblock, iblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") /* (Note: super blocks don't contain elements, so don't have a '*thing != sblock' check) */ if (sblock && H5EA__sblock_unprotect(sblock, sblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") if (dblock && *thing != dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") if (dblk_page && *thing != dblk_page && H5EA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block page") -END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__lookup_elmt() */ /*------------------------------------------------------------------------- * Function: H5EA_set @@ -654,20 +667,21 @@ END_FUNC(STATIC) /* end H5EA__lookup_elmt() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt)) - - /* Local variables */ +herr_t +H5EA_set(const H5EA_t *ea, hsize_t idx, const void *elmt) +{ H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ - void * thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ + void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ hsize_t thing_elmt_idx; /* Index of the element in the element buffer for the array metadata */ H5EA__unprotect_func_t thing_unprot_func; /* Function pointer for unprotecting the array metadata */ hbool_t will_extend; /* Flag indicating if setting the element will extend the array */ unsigned thing_cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting array metadata */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); HDassert(hdr); @@ -678,7 +692,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t will_extend = (idx >= hdr->stats.stored.max_idx_set); if (H5EA__lookup_elmt(ea, idx, will_extend, H5AC__NO_FLAGS_SET, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) - H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to protect array metadata") /* Sanity check */ HDassert(thing); @@ -695,15 +709,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_set(const H5EA_t *ea, hsize_t /* Update the max index for the array */ hdr->stats.stored.max_idx_set = idx + 1; if (H5EA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as modified") - } /* end if */ + HGOTO_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, + "unable to mark extensible array header as modified") + } - CATCH +done: /* Release resources */ if (thing && (thing_unprot_func)(thing, thing_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_set() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_set() */ /*------------------------------------------------------------------------- * Function: H5EA_get @@ -717,17 +733,18 @@ END_FUNC(PRIV) /* end H5EA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt)) - - /* Local variables */ +herr_t +H5EA_get(const H5EA_t *ea, hsize_t idx, void *elmt) +{ H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ void *thing = NULL; /* Pointer to the array metadata containing the array index we are interested in */ H5EA__unprotect_func_t thing_unprot_func = NULL; /* Function pointer for unprotecting the array metadata */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); HDassert(hdr); @@ -735,7 +752,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t if (idx >= hdr->stats.stored.max_idx_set) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else { uint8_t *thing_elmt_buf; /* Pointer to the element buffer for the array metadata */ @@ -747,13 +764,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t /* Look up the array metadata containing the element we want to set */ if (H5EA__lookup_elmt(ea, idx, FALSE, H5AC__READ_ONLY_FLAG, &thing, &thing_elmt_buf, &thing_elmt_idx, &thing_unprot_func) < 0) - H5E_THROW(H5E_CANTPROTECT, "unable to protect array metadata") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to protect array metadata") /* Check if the thing holding the element has been created yet */ if (NULL == thing) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else /* Get element from thing's element buffer */ @@ -761,12 +778,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_get(const H5EA_t *ea, hsize_t hdr->cparam.cls->nat_elmt_size); } /* end else */ - CATCH +done: /* Release thing */ if (thing && (thing_unprot_func)(thing, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array metadata") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array metadata") -END_FUNC(PRIV) /* end H5EA_get() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_get() */ /*------------------------------------------------------------------------- * Function: H5EA_depend @@ -781,14 +799,15 @@ END_FUNC(PRIV) /* end H5EA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent)) +herr_t +H5EA_depend(H5EA_t *ea, H5AC_proxy_entry_t *parent) +{ + H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = ea->hdr; /* Header for EA */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(hdr); HDassert(parent); @@ -807,13 +826,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_depend(H5EA_t *ea, H5AC_proxy_ /* Add the extensible array as a child of the parent (proxy) */ if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array as child of proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, "unable to add extensible array as child of proxy") hdr->parent = parent; - } /* end if */ + } - CATCH - -END_FUNC(PRIV) /* end H5EA_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_depend() */ /*------------------------------------------------------------------------- * Function: H5EA_close @@ -827,15 +846,16 @@ END_FUNC(PRIV) /* end H5EA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) - - /* Local variables */ +herr_t +H5EA_close(H5EA_t *ea) +{ hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ haddr_t ea_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(ea); /* Close the header, if it was set */ @@ -868,8 +888,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) /* Check the header's status in the metadata cache */ if (H5AC_get_entry_status(ea->f, ea_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, - "unable to check metadata cache status for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, + "unable to check metadata cache status for extensible array header") /* Sanity checks on header */ HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -881,7 +901,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ if (NULL == (hdr = H5EA__hdr_protect(ea->f, ea_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTLOAD, FAIL, "unable to load extensible array header") /* Set the shared array header's file context for this operation */ hdr->f = ea->f; @@ -891,11 +911,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) * immediately -QAK) */ if (H5EA__hdr_decr(ea->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ if (H5EA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array") } /* end if */ else { /* Decrement the reference count on the array header */ @@ -903,16 +924,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_close(H5EA_t *ea)) * immediately -QAK) */ if (H5EA__hdr_decr(ea->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") } /* end else */ } /* end if */ /* Release the extensible array wrapper */ ea = (H5EA_t *)H5FL_FREE(H5EA_t, ea); - CATCH - -END_FUNC(PRIV) /* end H5EA_close() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_close() */ /*------------------------------------------------------------------------- * Function: H5EA_delete @@ -926,21 +948,22 @@ END_FUNC(PRIV) /* end H5EA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata)) +herr_t +H5EA_delete(H5F_t *f, haddr_t ea_addr, void *ctx_udata) +{ + H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* The fractal heap header information */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(ea_addr)); /* Lock the array header into memory */ if (NULL == (hdr = H5EA__hdr_protect(f, ea_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", - (unsigned long long)ea_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) /* Check for files using shared array header */ if (hdr->file_rc) @@ -951,17 +974,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5EA_delete(H5F_t *f, haddr_t ea_ad /* Delete array now, starting with header (unprotects header) */ if (H5EA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array") hdr = NULL; - } /* end if */ + } - CATCH - - /* Unprotect the header, if an error occurred */ +done: + /* Unprotect the header if an error occurred */ if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PRIV) /* end H5EA_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_delete() */ /*------------------------------------------------------------------------- * Function: H5EA_iterate @@ -975,13 +998,14 @@ END_FUNC(PRIV) /* end H5EA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, - H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) - - /* Local variables */ +int +H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata) +{ uint8_t *elmt = NULL; hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + int ret_value = H5_ITER_CONT; + + FUNC_ENTER_NOAPI(H5_ITER_ERROR) /* Check arguments */ HDassert(ea); @@ -990,27 +1014,28 @@ BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, /* Allocate space for a native array element */ if (NULL == (elmt = H5FL_BLK_MALLOC(ea_native_elmt, ea->hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array element") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, H5_ITER_ERROR, + "memory allocation failed for extensible array element") /* Iterate over all elements in array */ - for (u = 0; u < ea->hdr->stats.stored.max_idx_set && cb_ret == H5_ITER_CONT; u++) { + for (u = 0; u < ea->hdr->stats.stored.max_idx_set && ret_value == H5_ITER_CONT; u++) { /* Get array element */ if (H5EA_get(ea, u, elmt) < 0) - H5E_THROW(H5E_CANTGET, "unable to delete fixed array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, H5_ITER_ERROR, "unable to delete fixed array") /* Make callback */ - if ((cb_ret = (*op)(u, elmt, udata)) < 0) { - H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) - } /* end if */ - } /* end for */ - - CATCH + if ((ret_value = (*op)(u, elmt, udata)) < 0) { + HERROR(H5E_EARRAY, H5E_BADITER, "iteration callback error"); + break; + } + } +done: if (elmt) elmt = H5FL_BLK_FREE(ea_native_elmt, elmt); -END_FUNC(PRIV) /* end H5EA_iterate() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA_iterate() */ /*------------------------------------------------------------------------- * Function: H5EA_patch_file @@ -1024,17 +1049,17 @@ END_FUNC(PRIV) /* end H5EA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_patch_file(H5EA_t *ea, H5F_t *f)) - - /* Local variables */ +herr_t +H5EA_patch_file(H5EA_t *ea, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(f); if (ea->f != f || ea->hdr->f != f) ea->f = ea->hdr->f = f; -END_FUNC(PRIV) /* end H5EA_patch_file() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_patch_file() */ diff --git a/src/H5EAcache.c b/src/H5EAcache.c index 2a3153c6bc9..9da960c0549 100644 --- a/src/H5EAcache.c +++ b/src/H5EAcache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -68,7 +67,7 @@ /* Metadata cache (H5AC) callbacks */ static herr_t H5EA__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5EA__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5EA__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_hdr_image_len(const void *thing, size_t *image_len); static herr_t H5EA__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *thing); @@ -76,7 +75,7 @@ static herr_t H5EA__cache_hdr_free_icr(void *thing); static herr_t H5EA__cache_iblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_iblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5EA__cache_iblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5EA__cache_iblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_iblock_image_len(const void *thing, size_t *image_len); static herr_t H5EA__cache_iblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *thing); @@ -84,7 +83,7 @@ static herr_t H5EA__cache_iblock_free_icr(void *thing); static herr_t H5EA__cache_sblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_sblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5EA__cache_sblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5EA__cache_sblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_sblock_image_len(const void *thing, size_t *image_len); static herr_t H5EA__cache_sblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *thing); @@ -92,7 +91,7 @@ static herr_t H5EA__cache_sblock_free_icr(void *thing); static herr_t H5EA__cache_dblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_dblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5EA__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5EA__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_dblock_image_len(const void *thing, size_t *image_len); static herr_t H5EA__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *thing); @@ -101,7 +100,7 @@ static herr_t H5EA__cache_dblock_fsf_size(const void *thing, hsize_t *fsf_size); static herr_t H5EA__cache_dblk_page_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5EA__cache_dblk_page_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5EA__cache_dblk_page_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5EA__cache_dblk_page_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5EA__cache_dblk_page_image_len(const void *thing, size_t *image_len); static herr_t H5EA__cache_dblk_page_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *thing); @@ -221,12 +220,13 @@ const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1] = {{ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; /* User data for callback */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->f); @@ -235,7 +235,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_HEADER_SIZE_FILE(udata->f); -END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_verify_chksum @@ -250,13 +251,15 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -267,7 +270,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5EA__cache_hdr_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_deserialize @@ -282,16 +286,17 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_cls_id_t id; /* ID of extensible array class, as found in file */ - H5EA_hdr_t * hdr = NULL; /* Extensible array info */ + H5EA_hdr_t *hdr = NULL; /* Extensible array info */ H5EA_hdr_cache_ud_t *udata = (H5EA_hdr_cache_ud_t *)_udata; - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(image); @@ -301,24 +306,25 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate space for the extensible array data structure */ if (NULL == (hdr = H5EA__hdr_alloc(udata->f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array shared header") /* Set the extensible array header's address */ hdr->addr = udata->addr; /* Magic number */ if (HDmemcmp(image, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_HDR_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array header version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array header version") /* Extensible array class */ id = (H5EA_cls_id_t)*image++; if (id >= H5EA_NUM_CLS_ID) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") hdr->cparam.cls = H5EA_client_class_g[id]; /* General array creation/configuration information */ @@ -379,20 +385,20 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Finish initializing extensible array header */ if (H5EA__hdr_init(hdr, udata->ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "initialization failed for extensible array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; - CATCH - +done: /* Release resources */ if (!ret_value) if (hdr && H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header") -END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_image_len @@ -406,12 +412,13 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_image_len(const void *_thing, size_t *image_len) +{ const H5EA_hdr_t *hdr = (const H5EA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -419,7 +426,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_serialize @@ -433,14 +441,15 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the extensible array header */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + FUNC_ENTER_STATIC_NOERR + /* check arguments */ HDassert(f); HDassert(image); @@ -488,7 +497,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_hdr_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_notify @@ -502,11 +512,13 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_hdr_t *hdr = (H5EA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(hdr); @@ -538,23 +550,24 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on object header proxy */ if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between extensible array and proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between extensible array and proxy") hdr->parent = NULL; } /* end if */ /* Detach from 'top' proxy for extensible array */ if (hdr->top_proxy) { if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between header and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between header and " + "extensible array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ @@ -563,9 +576,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, else HDassert(NULL == hdr->parent); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_hdr_free_icr @@ -580,18 +593,23 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_hdr_free_icr(void *thing)) +static herr_t +H5EA__cache_hdr_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array header */ if (H5EA__hdr_dest((H5EA_hdr_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array header") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_hdr_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_get_initial_load_size @@ -605,13 +623,14 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ - H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ +static herr_t +H5EA__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) +{ + H5EA_hdr_t *hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ H5EA_iblock_t iblock; /* Fake index block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -626,7 +645,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_IBLOCK_SIZE(&iblock); -END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_iblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_verify_chksum @@ -641,13 +661,15 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_iblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -658,7 +680,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_deserialize @@ -673,17 +696,18 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5EA__cache_iblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ H5EA_iblock_t *iblock = NULL; /* Index block info */ - H5EA_hdr_t * hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ + H5EA_hdr_t *hdr = (H5EA_hdr_t *)_udata; /* User data for callback */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ size_t u; /* Local index variable */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(image); @@ -691,28 +715,29 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array index block */ if (NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array index block") /* Set the extensible array index block's address */ iblock->addr = hdr->idx_blk_addr; /* Magic number */ if (HDmemcmp(image, H5EA_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array index block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array index block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_IBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array index block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array index block version") /* Extensible array type */ if (*image++ != (uint8_t)hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Internal information */ @@ -721,7 +746,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((hdr->cparam.cls->decode)(image, iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts, hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array index elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array index elements") image += (hdr->cparam.idx_blk_elmts * hdr->cparam.raw_elmt_size); } /* end if */ @@ -757,14 +782,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = iblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (iblock && H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block") -END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_image_len @@ -778,12 +803,13 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_iblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_iblock_t *iblock = (const H5EA_iblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(iblock); HDassert(image_len); @@ -791,7 +817,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = iblock->size; -END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_iblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_serialize @@ -805,14 +832,15 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object to serialize */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* check arguments */ HDassert(f); @@ -843,7 +871,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((iblock->hdr->cparam.cls->encode)(image, iblock->elmts, (size_t)iblock->hdr->cparam.idx_blk_elmts, iblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array index elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array index elements") image += (iblock->hdr->cparam.idx_blk_elmts * iblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -874,9 +902,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_notify @@ -890,11 +918,13 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_iblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_iblock_t *iblock = (H5EA_iblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(iblock); @@ -905,9 +935,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on extensible array header */ if (H5EA__create_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between index block and header, address = %llu", - (unsigned long long)iblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between index block and header, address = %llu", + (unsigned long long)iblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -923,30 +954,32 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on extensible array header */ if (H5EA__destroy_flush_depend((H5AC_info_t *)iblock->hdr, (H5AC_info_t *)iblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between index block and header, address = %llu", - (unsigned long long)iblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between index block and header, address = %llu", + (unsigned long long)iblock->addr) /* Detach from 'top' proxy for extensible array */ if (iblock->top_proxy) { if (H5AC_proxy_entry_remove_child(iblock->top_proxy, iblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between index block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between index block and " + "extensible array 'top' proxy") iblock->top_proxy = NULL; } /* end if */ break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_iblock_free_icr @@ -961,18 +994,23 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_iblock_free_icr(void *thing)) +static herr_t +H5EA__cache_iblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array index block */ if (H5EA__iblock_dest((H5EA_iblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array index block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_iblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_get_initial_load_size @@ -986,13 +1024,14 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ H5EA_sblock_t sblock; /* Fake super block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1026,7 +1065,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_SBLOCK_SIZE(&sblock); -END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_verify_chksum @@ -1041,13 +1081,15 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_sblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1058,7 +1100,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_deserialize @@ -1073,17 +1116,18 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ - H5EA_sblock_t * sblock = NULL; /* Super block info */ +static void * +H5EA__cache_sblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ + H5EA_sblock_t *sblock = NULL; /* Super block info */ H5EA_sblock_cache_ud_t *udata = (H5EA_sblock_cache_ud_t *)_udata; /* User data */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ size_t u; /* Local index variable */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -1094,28 +1138,29 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array super block */ if (NULL == (sblock = H5EA__sblock_alloc(udata->hdr, udata->parent, udata->sblk_idx))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array super block") /* Set the extensible array super block's address */ sblock->addr = udata->sblk_addr; /* Magic number */ if (HDmemcmp(image, H5EA_SBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array super block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array super block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_SBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array super block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array super block version") /* Extensible array type */ if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, udata->hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Offset of block within the array's address space */ UINT64DECODE_VAR(image, sblock->block_off, udata->hdr->arr_off_size); @@ -1154,14 +1199,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = sblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (sblock && H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block") -END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_image_len @@ -1175,12 +1220,13 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_sblock_t *sblock = (const H5EA_sblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(sblock); HDassert(image_len); @@ -1188,7 +1234,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = sblock->size; -END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_serialize @@ -1202,16 +1249,16 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_sblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object to serialize */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ size_t u; /* Local index variable */ + FUNC_ENTER_STATIC_NOERR + /* check arguments */ HDassert(f); HDassert(image); @@ -1260,7 +1307,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_sblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_notify @@ -1274,11 +1322,13 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_sblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_sblock_t *sblock = (H5EA_sblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(sblock); @@ -1289,8 +1339,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on index block */ if (H5EA__create_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) break; @@ -1299,8 +1349,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on extensible array header, if set */ if (sblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; @@ -1310,16 +1360,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on index block */ if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->parent, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and index block, address = %llu", (unsigned long long)sblock->addr) /* Destroy flush dependency on extensible array header, if set */ if (sblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)sblock->hdr, (H5AC_info_t *)sblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between super block and header, address = %llu", (unsigned long long)sblock->addr) sblock->has_hdr_depend = FALSE; @@ -1328,8 +1378,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for extensible array */ if (sblock->top_proxy) { if (H5AC_proxy_entry_remove_child(sblock->top_proxy, sblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between super block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between super block and " + "extensible array 'top' proxy") sblock->top_proxy = NULL; } /* end if */ break; @@ -1345,15 +1396,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_sblock_free_icr @@ -1368,18 +1419,23 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_sblock_free_icr(void *thing)) +static herr_t +H5EA__cache_sblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array super block */ if (H5EA__sblock_dest((H5EA_sblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array super block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_get_initial_load_size @@ -1393,13 +1449,14 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ H5EA_dblock_t dblock; /* Fake data block for computing size */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1434,7 +1491,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = H5EA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_verify_chksum @@ -1449,13 +1507,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1466,7 +1526,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_sblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_deserialize @@ -1481,16 +1542,18 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ - H5EA_dblock_t * dblock = NULL; /* Data block info */ +static void * +H5EA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ + H5EA_dblock_t *dblock = NULL; /* Data block info */ H5EA_dblock_cache_ud_t *udata = (H5EA_dblock_cache_ud_t *)_udata; /* User data */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(udata); @@ -1501,7 +1564,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array data block */ if (NULL == (dblock = H5EA__dblock_alloc(udata->hdr, udata->parent, udata->nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block") HDassert(((!dblock->npages) && (len == H5EA_DBLOCK_SIZE(dblock))) || (len == H5EA_DBLOCK_PREFIX_SIZE(dblock))); @@ -1511,21 +1575,21 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Magic number */ if (HDmemcmp(image, H5EA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong extensible array data block signature") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array data block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5EA_DBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong extensible array data block version") + HGOTO_ERROR(H5E_EARRAY, H5E_VERSION, NULL, "wrong extensible array data block version") /* Extensible array type */ if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect extensible array class") + HGOTO_ERROR(H5E_EARRAY, H5E_BADTYPE, NULL, "incorrect extensible array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, udata->hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong extensible array header address") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, NULL, "wrong extensible array header address") /* Offset of block within the array's address space */ UINT64DECODE_VAR(image, dblock->block_off, udata->hdr->arr_off_size); @@ -1537,7 +1601,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Decode elements in data block */ /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblock->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array data elements") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1560,14 +1624,15 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblock; - CATCH +done: /* Release resources */ if (!ret_value) if (dblock && H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block") -END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5EA__cache_dblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_image_len @@ -1581,12 +1646,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_image_len(const void *_thing, size_t *image_len) +{ const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(image_len); @@ -1597,7 +1663,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = (size_t)H5EA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_serialize @@ -1611,14 +1678,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object to serialize */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* check arguments */ HDassert(f); @@ -1651,7 +1719,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, dblock->nelmts, dblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array data elements") image += (dblock->nelmts * dblock->hdr->cparam.raw_elmt_size); } /* end if */ @@ -1664,9 +1732,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_notify @@ -1680,11 +1748,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5EA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_dblock_t *dblock = (H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Check arguments */ HDassert(dblock); @@ -1695,17 +1765,17 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5EA__create_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTDEPEND, - "unable to create flush dependency between data block and parent, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, + "unable to create flush dependency between data block and parent, address = %llu", + (unsigned long long)dblock->addr) break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: /* Destroy flush dependency on extensible array header, if set */ if (dblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between direct block and header, address = %llu", (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; @@ -1715,15 +1785,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->parent, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block and parent, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block and parent, address = %llu", + (unsigned long long)dblock->addr) /* Destroy flush dependency on extensible array header, if set */ if (dblock->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) dblock->has_hdr_depend = FALSE; @@ -1732,8 +1803,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for extensible array */ if (dblock->top_proxy) { if (H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block and " + "extensible array 'top' proxy") dblock->top_proxy = NULL; } /* end if */ break; @@ -1749,15 +1821,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_free_icr @@ -1772,18 +1844,23 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblock_free_icr(void *thing)) +static herr_t +H5EA__cache_dblock_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array data block */ if (H5EA__dblock_dest((H5EA_dblock_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array data block") - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblock_fsf_size @@ -1814,12 +1891,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) - - /* Local variables */ +static herr_t +H5EA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) +{ const H5EA_dblock_t *dblock = (const H5EA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -1828,7 +1906,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblock_fsf_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_get_initial_load_size @@ -1842,12 +1921,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_fsf_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len) +{ H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -1856,7 +1936,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5EA_DBLK_PAGE_SIZE(udata->hdr); -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblk_page_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_verify_chksum @@ -1871,13 +1952,15 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5EA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1888,7 +1971,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_deserialize @@ -1903,16 +1987,17 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ - H5EA_dblk_page_t * dblk_page = NULL; /* Data block page info */ +static void * +H5EA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ + H5EA_dblk_page_t *dblk_page = NULL; /* Data block page info */ H5EA_dblk_page_cache_ud_t *udata = (H5EA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -1922,7 +2007,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the extensible array data block page */ if (NULL == (dblk_page = H5EA__dblk_page_alloc(udata->hdr, udata->parent))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block page") /* Set the extensible array data block page's information */ dblk_page->addr = udata->dblk_page_addr; @@ -1933,7 +2019,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->hdr->dblk_page_nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDECODE, NULL, "can't decode extensible array data elements") image += (udata->hdr->dblk_page_nelmts * udata->hdr->cparam.raw_elmt_size); /* Sanity check */ @@ -1954,14 +2040,13 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblk_page; - CATCH - +done: /* Release resources */ if (!ret_value) if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_deserialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_image_len @@ -1975,12 +2060,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_image_len(const void *_thing, size_t *image_len) +{ const H5EA_dblk_page_t *dblk_page = (const H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblk_page); HDassert(image_len); @@ -1988,7 +2074,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__cache_dblk_page_image_len() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_serialize @@ -2002,14 +2089,16 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, - size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing) +{ H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(f); @@ -2024,7 +2113,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->hdr->dblk_page_nelmts, dblk_page->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode extensible array data elements") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTENCODE, FAIL, "can't encode extensible array data elements") image += (dblk_page->hdr->dblk_page_nelmts * dblk_page->hdr->cparam.raw_elmt_size); /* Compute metadata checksum */ @@ -2036,9 +2125,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_serialize() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_notify @@ -2052,11 +2141,13 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) - - /* Local variables */ +static herr_t +H5EA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing) +{ H5EA_dblk_page_t *dblk_page = (H5EA_dblk_page_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblk_page); @@ -2067,8 +2158,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5EA__create_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) break; @@ -2077,10 +2168,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on extensible array header, if set */ if (dblk_page->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and header, " - "address = %llu", - (unsigned long long)dblk_page->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and header, " + "address = %llu", + (unsigned long long)dblk_page->addr) dblk_page->has_hdr_depend = FALSE; } /* end if */ break; @@ -2088,27 +2179,27 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->parent, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between data block page and parent, address = %llu", (unsigned long long)dblk_page->addr) /* Destroy flush dependency on extensible array header, if set */ if (dblk_page->has_hdr_depend) { if (H5EA__destroy_flush_depend((H5AC_info_t *)dblk_page->hdr, (H5AC_info_t *)dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and header, " - "address = %llu", - (unsigned long long)dblk_page->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and header, " + "address = %llu", + (unsigned long long)dblk_page->addr) dblk_page->has_hdr_depend = FALSE; } /* end if */ /* Detach from 'top' proxy for extensible array */ if (dblk_page->top_proxy) { if (H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between data block page and " - "extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page and " + "extensible array 'top' proxy") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -2124,15 +2215,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_notify() */ /*------------------------------------------------------------------------- * Function: H5EA__cache_dblk_page_free_icr @@ -2147,15 +2238,20 @@ END_FUNC(STATIC) /* end H5EA__cache_dblk_page_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5EA__cache_dblk_page_free_icr(void *thing)) +static herr_t +H5EA__cache_dblk_page_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array data block page */ if (H5EA__dblk_page_dest((H5EA_dblk_page_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free extensible array data block page") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, "can't free extensible array data block page") -END_FUNC(STATIC) /* end H5EA__cache_dblk_page_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cache_dblk_page_free_icr() */ diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index 72d2f38cb04..c881582ee2f 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -79,13 +78,16 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t obj_addr)) - +herr_t +H5EA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ - void * dbg_ctx = NULL; /* Extensible array debugging context */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + void *dbg_ctx = NULL; /* Extensible array debugging context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -100,11 +102,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Header...\n", indent, ""); @@ -137,13 +139,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Index Block Address:", hdr->idx_blk_addr); - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_debug @@ -157,14 +160,17 @@ END_FUNC(PKG) /* end H5EA__hdr_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) - +herr_t +H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, + const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ - void * dbg_ctx = NULL; /* Extensible array context */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + void *dbg_ctx = NULL; /* Extensible array context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -180,19 +186,20 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Sanity check */ HDassert(H5F_addr_eq(hdr->idx_blk_addr, addr)); /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Index Block...\n", indent, ""); @@ -216,7 +223,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)iblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ } /* end if */ @@ -229,7 +236,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*sData Block Addresses in Index Block:\n", indent, ""); for (u = 0; u < iblock->ndblk_addrs; u++) { /* Print address */ - HDsprintf(temp_str, "Address #%u:", u); + HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, iblock->dblk_addrs[u]); } /* end for */ @@ -244,21 +251,22 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*sSuper Block Addresses in Index Block:\n", indent, ""); for (u = 0; u < iblock->nsblk_addrs; u++) { /* Print address */ - HDsprintf(temp_str, "Address #%u:", u); + HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, iblock->sblk_addrs[u]); } /* end for */ } /* end if */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (iblock && H5EA__iblock_unprotect(iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__iblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_debug @@ -272,14 +280,17 @@ END_FUNC(PKG) /* end H5EA__iblock_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr)) - +herr_t +H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ - void * dbg_ctx = NULL; /* Extensible array context */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + void *dbg_ctx = NULL; /* Extensible array context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -295,18 +306,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Protect super block */ /* (Note: setting parent of super block to 'hdr' for this operation should be OK -QAK) */ if (NULL == (sblock = H5EA__sblock_protect(hdr, (H5EA_iblock_t *)hdr, addr, sblk_idx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array Super Block...\n", indent, ""); @@ -328,21 +340,22 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*sData Block Addresses in Super Block:\n", indent, ""); for (u = 0; u < sblock->ndblks; u++) { /* Print address */ - HDsprintf(temp_str, "Address #%u:", u); + HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, sblock->dblk_addrs[u]); } /* end for */ } /* end if */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (sblock && H5EA__sblock_unprotect(sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__sblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_debug @@ -356,16 +369,18 @@ END_FUNC(PKG) /* end H5EA__sblock_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5EA_class_t *cls, haddr_t hdr_addr, size_t dblk_nelmts, - haddr_t obj_addr)) - +herr_t +H5EA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, + haddr_t hdr_addr, size_t dblk_nelmts, haddr_t obj_addr) +{ /* Local variables */ - H5EA_hdr_t * hdr = NULL; /* Shared extensible array header */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ - void * dbg_ctx = NULL; /* Extensible array context */ - size_t u; /* Local index variable */ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + void *dbg_ctx = NULL; /* Extensible array context */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -382,17 +397,17 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to create extensible array debugging context") /* Load the extensible array header */ if (NULL == (hdr = H5EA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, "unable to load extensible array header") /* Protect data block */ /* (Note: setting parent of data block to 'hdr' for this operation should be OK -QAK) */ if (NULL == (dblock = H5EA__dblock_protect(hdr, hdr, addr, dblk_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %" PRIuHADDR, - addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %" PRIuHADDR, addr) /* Print opening message */ HDfprintf(stream, "%*sExtensible Array data Block...\n", indent, ""); @@ -407,15 +422,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Call the class's 'debug' callback */ if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context") + HDONE_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to release extensible array debugging context") if (dblock && H5EA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") if (hdr && H5EA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__dblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_debug() */ diff --git a/src/H5EAdblkpage.c b/src/H5EAdblkpage.c index b42599c420a..c6d4fbb6857 100644 --- a/src/H5EAdblkpage.c +++ b/src/H5EAdblkpage.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -84,22 +83,25 @@ H5FL_DEFINE_STATIC(H5EA_dblk_page_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, - H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent)) - - /* Local variables */ +H5EA_dblk_page_t * +H5EA__dblk_page_alloc(H5EA_hdr_t *hdr, H5EA_sblock_t *parent) +{ H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ + H5EA_dblk_page_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the data block */ if (NULL == (dblk_page = H5FL_CALLOC(H5EA_dblk_page_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block page") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblk_page->hdr = hdr; /* Set non-zero internal fields */ @@ -107,17 +109,19 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, /* Allocate buffer for elements in data block page */ if (NULL == (dblk_page->elmts = H5EA__hdr_alloc_elmts(hdr, hdr->dblk_page_nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block page element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block page element buffer") /* Set the return value */ ret_value = dblk_page; - CATCH +done: if (!ret_value) if (dblk_page && H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block page") -END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_create @@ -131,19 +135,22 @@ END_FUNC(PKG) /* end H5EA__dblk_page_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr)) - - /* Local variables */ +herr_t +H5EA__dblk_page_create(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t addr) +{ H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Allocate the data block page */ if (NULL == (dblk_page = H5EA__dblk_page_alloc(hdr, parent))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block page") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, FAIL, + "memory allocation failed for extensible array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; @@ -151,34 +158,39 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Clear any elements in data block page to fill value */ if ((hdr->cparam.cls->fill)(dblk_page->elmts, (size_t)hdr->dblk_page_nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array data block page elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, + "can't set extensible array data block page elements to class's fill value") /* Cache the new extensible array data block page */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block page to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, FAIL, "can't add extensible array data block page to cache") inserted = TRUE; /* Add data block page as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, FAIL, + "unable to add extensible array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ - CATCH +done: if (ret_value < 0) if (dblk_page) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblk_page) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block page from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, FAIL, + "unable to remove extensible array data block page from cache") /* Destroy data block page */ if (H5EA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block page") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to destroy extensible array data block page") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblk_page_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_create() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_protect @@ -193,13 +205,14 @@ END_FUNC(PKG) /* end H5EA__dblk_page_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, - H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t dblk_page_addr, - unsigned flags)) - - /* Local variables */ - H5EA_dblk_page_t * dblk_page = NULL; /* Extensible array data block page */ +H5EA_dblk_page_t * +H5EA__dblk_page_protect(H5EA_hdr_t *hdr, H5EA_sblock_t *parent, haddr_t dblk_page_addr, unsigned flags) +{ + H5EA_dblk_page_t *dblk_page = NULL; /* Extensible array data block page */ H5EA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ + H5EA_dblk_page_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -216,32 +229,34 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblk_page_t *, NULL, NULL, /* Protect the data block page */ if (NULL == (dblk_page = (H5EA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblk_page->top_proxy) { /* Add data block page as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block page, if it was protected */ if (dblk_page && H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, - "unable to unprotect extensible array data block page, address = %llu", - (unsigned long long)dblk_page->addr) + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array data block page, address = %llu", + (unsigned long long)dblk_page->addr) } /* end if */ - -END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_unprotect @@ -256,22 +271,25 @@ END_FUNC(PKG) /* end H5EA__dblk_page_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags)) +herr_t +H5EA__dblk_page_unprotect(H5EA_dblk_page_t *dblk_page, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); /* Unprotect the data block page */ if (H5AC_unprotect(dblk_page->hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block page, address = %llu", - (unsigned long long)dblk_page->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array data block page, address = %llu", + (unsigned long long)dblk_page->addr) -END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblk_page_dest @@ -285,7 +303,12 @@ END_FUNC(PKG) /* end H5EA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page)) +herr_t +H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); @@ -297,13 +320,15 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_ if (dblk_page->elmts) { /* Free buffer for data block page elements */ if (H5EA__hdr_free_elmts(dblk_page->hdr, dblk_page->hdr->dblk_page_nelmts, dblk_page->elmts) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to free extensible array data block element buffer") dblk_page->elmts = NULL; } /* end if */ /* Decrement reference count on shared info */ if (H5EA__hdr_decr(dblk_page->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -313,6 +338,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblk_page_dest(H5EA_dblk_page_ /* Free the data block page itself */ dblk_page = H5FL_FREE(H5EA_dblk_page_t, dblk_page); - CATCH - -END_FUNC(PKG) /* end H5EA__dblk_page_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblk_page_dest() */ diff --git a/src/H5EAdblock.c b/src/H5EAdblock.c index 45696c7c3b0..005de764ef7 100644 --- a/src/H5EAdblock.c +++ b/src/H5EAdblock.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -85,11 +84,13 @@ H5FL_DEFINE_STATIC(H5EA_dblock_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, - H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts)) +H5EA_dblock_t * +H5EA__dblock_alloc(H5EA_hdr_t *hdr, void *parent, size_t nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + H5EA_dblock_t *ret_value = NULL; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -98,11 +99,12 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, /* Allocate memory for the data block */ if (NULL == (dblock = H5FL_CALLOC(H5EA_dblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array data block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblock->hdr = hdr; /* Set non-zero internal fields */ @@ -118,18 +120,20 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, else { /* Allocate buffer for elements in data block */ if (NULL == (dblock->elmts = H5EA__hdr_alloc_elmts(hdr, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; - CATCH +done: if (!ret_value) if (dblock && H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_create @@ -143,14 +147,15 @@ END_FUNC(PKG) /* end H5EA__dblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, - size_t nelmts)) +haddr_t +H5EA__dblock_create(H5EA_hdr_t *hdr, void *parent, hbool_t *stats_changed, hsize_t dblk_off, size_t nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ + haddr_t dblock_addr; /* Extensible array data block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Extensible array data block */ - haddr_t dblock_addr; /* Extensible array data block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -159,7 +164,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the data block */ if (NULL == (dblock = H5EA__dblock_alloc(hdr, parent, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array data block") /* Set size of data block on disk */ dblock->size = H5EA_DBLOCK_SIZE(dblock); @@ -169,24 +175,27 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate space for the data block on disk */ if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_DBLOCK, (hsize_t)dblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array data block") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ if (!dblock->npages) /* Clear any elements in data block to fill value */ if ((hdr->cparam.cls->fill)(dblock->elmts, (size_t)dblock->nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array data block elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set extensible array data block elements to class's fill value") /* Cache the new extensible array data block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array data block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add extensible array data block to cache") inserted = TRUE; /* Add data block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -203,25 +212,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of data block to return */ ret_value = dblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (dblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array data block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array data block from cache") /* Release data block's disk space */ if (H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release extensible array data block") /* Destroy data block */ if (H5EA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array data block") } /* end if */ -END_FUNC(PKG) /* end H5EA__dblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_sblk_idx @@ -236,10 +249,12 @@ END_FUNC(PKG) /* end H5EA__dblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, unsigned, 0, -, H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx)) +unsigned +H5EA__dblock_sblk_idx(const H5EA_hdr_t *hdr, hsize_t idx) +{ + unsigned sblk_idx = 0; /* Which superblock does this index fall in? */ - /* Local variables */ - unsigned sblk_idx; /* Which superblock does this index fall in? */ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -252,10 +267,8 @@ BEGIN_FUNC(PKG, NOERR, unsigned, 0, -, H5EA__dblock_sblk_idx(const H5EA_hdr_t *h H5_CHECK_OVERFLOW(idx, /*From:*/ hsize_t, /*To:*/ uint64_t); sblk_idx = H5VM_log2_gen((uint64_t)((idx / hdr->cparam.data_blk_min_elmts) + 1)); - /* Set return value */ - ret_value = sblk_idx; - -END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ + FUNC_LEAVE_NOAPI(sblk_idx) +} /* end H5EA__dblock_sblk_idx() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_protect @@ -269,13 +282,14 @@ END_FUNC(PKG) /* end H5EA__dblock_sblk_idx() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, - H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts, - unsigned flags)) - - /* Local variables */ - H5EA_dblock_t * dblock; /* Extensible array data block */ +H5EA_dblock_t * +H5EA__dblock_protect(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts, unsigned flags) +{ + H5EA_dblock_t *dblock; /* Extensible array data block */ H5EA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5EA_dblock_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -294,32 +308,36 @@ BEGIN_FUNC(PKG, ERR, H5EA_dblock_t *, NULL, NULL, /* Protect the data block */ if (NULL == (dblock = (H5EA_dblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_DBLOCK, dblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)dblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblock->top_proxy) { /* Add data block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; - } /* end if */ + } /* Set return value */ ret_value = dblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block, if it was protected */ if (dblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", - (unsigned long long)dblock->addr) - } /* end if */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array data block, address = %llu", + (unsigned long long)dblock->addr) + } -END_FUNC(PKG) /* end H5EA__dblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_unprotect @@ -333,22 +351,26 @@ END_FUNC(PKG) /* end H5EA__dblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags)) +herr_t +H5EA__dblock_unprotect(H5EA_dblock_t *dblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); /* Unprotect the data block */ if (H5AC_unprotect(dblock->hdr->f, H5AC_EARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array data block, address = %llu", - (unsigned long long)dblock->addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array data block, address = %llu", + (unsigned long long)dblock->addr) - CATCH +done: -END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_delete @@ -362,11 +384,13 @@ END_FUNC(PKG) /* end H5EA__dblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts)) +herr_t +H5EA__dblock_delete(H5EA_hdr_t *hdr, void *parent, haddr_t dblk_addr, size_t dblk_nelmts) +{ + H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_dblock_t *dblock = NULL; /* Pointer to data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -376,8 +400,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Protect data block */ if (NULL == (dblock = H5EA__dblock_protect(hdr, parent, dblk_addr, dblk_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array data block, address = %llu", + (unsigned long long)dblk_addr) /* Check if this is a paged data block */ if (dblk_nelmts > hdr->dblk_page_nelmts) { @@ -395,20 +420,22 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Evict the data block page from the metadata cache */ /* (OK to call if it doesn't exist in the cache) */ if (H5AC_expunge_entry(hdr->f, H5AC_EARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTEXPUNGE, "unable to remove array data block page from metadata cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTEXPUNGE, FAIL, + "unable to remove array data block page from metadata cache") /* Advance to next page address */ dblk_page_addr += dblk_page_size; } /* end for */ } /* end if */ - CATCH +done: /* Finished deleting data block in metadata cache */ if (dblock && H5EA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array data block") -END_FUNC(PKG) /* end H5EA__dblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__dblock_dest @@ -422,7 +449,12 @@ END_FUNC(PKG) /* end H5EA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dblock)) +herr_t +H5EA__dblock_dest(H5EA_dblock_t *dblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); @@ -435,14 +467,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dbl /* Free buffer for data block elements */ HDassert(dblock->nelmts > 0); if (H5EA__hdr_free_elmts(dblock->hdr, dblock->nelmts, dblock->elmts) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array data block element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTFREE, FAIL, + "unable to free extensible array data block element buffer") dblock->elmts = NULL; dblock->nelmts = 0; } /* end if */ /* Decrement reference count on shared info */ if (H5EA__hdr_decr(dblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -452,6 +486,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__dblock_dest(H5EA_dblock_t *dbl /* Free the data block itself */ dblock = H5FL_FREE(H5EA_dblock_t, dblock); - CATCH - -END_FUNC(PKG) /* end H5EA__dblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__dblock_dest() */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index 7f142af3684..7b5aff5a3bf 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -102,17 +101,21 @@ H5FL_SEQ_DEFINE_STATIC(H5EA_sblk_info_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__hdr_alloc(H5F_t *f)) +H5EA_hdr_t * +H5EA__hdr_alloc(H5F_t *f) +{ + H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + H5EA_hdr_t *ret_value = NULL; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ if (NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -126,12 +129,13 @@ BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, H5EA__hdr_alloc(H5F_t *f)) /* Set the return value */ ret_value = hdr; - CATCH +done: if (!ret_value) if (hdr && H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_init @@ -168,12 +172,15 @@ END_FUNC(PKG) /* end H5EA__hdr_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata)) - - /* Local variables */ +herr_t +H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata) +{ hsize_t start_idx; /* First element index for each super block */ hsize_t start_dblk; /* First data block index for each super block */ size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -188,7 +195,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Allocate information for each super block */ if (NULL == (hdr->sblk_info = H5FL_SEQ_MALLOC(H5EA_sblk_info_t, hdr->nsblks))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block info array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, FAIL, "memory allocation failed for super block info array") /* Compute information about each super block */ start_idx = 0; @@ -202,7 +209,7 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Advance starting indices for next super block */ start_idx += (hsize_t)hdr->sblk_info[u].ndblks * (hsize_t)hdr->sblk_info[u].dblk_nelmts; start_dblk += (hsize_t)hdr->sblk_info[u].ndblks; - } /* end for */ + } /* Set size of header on disk (locally and in statistics) */ hdr->stats.computed.hdr_size = hdr->size = H5EA_HEADER_SIZE_HDR(hdr); @@ -210,12 +217,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_init(H5EA_hdr_t *hdr, void /* Create the callback context, if there's one */ if (hdr->cparam.cls->crt_context) { if (NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) - H5E_THROW(H5E_CANTCREATE, "unable to create extensible array client callback context") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, FAIL, + "unable to create extensible array client callback context") + } -END_FUNC(PKG) /* end H5EA__hdr_init() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_init() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_alloc_elmts @@ -229,11 +237,14 @@ END_FUNC(PKG) /* end H5EA__hdr_init() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts)) - - /* Local variables */ - void * elmts = NULL; /* Element buffer allocated */ +void * +H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts) +{ + void *elmts = NULL; /* Element buffer allocated */ unsigned idx; /* Index of element buffer factory in header */ + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -251,8 +262,8 @@ BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, /* Re-allocate array of element factories */ if (NULL == (new_fac = H5FL_SEQ_REALLOC(H5FL_fac_head_ptr_t, hdr->elmt_fac.fac, new_nalloc))) - H5E_THROW(H5E_CANTALLOC, - "memory allocation failed for data block data element buffer factory array") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block data element buffer factory array") /* Zero out new elements allocated */ HDmemset(new_fac + hdr->elmt_fac.nalloc, 0, @@ -266,22 +277,24 @@ BEGIN_FUNC(PKG, ERR, void *, NULL, NULL, H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, /* Check for un-initialized factory at index */ if (NULL == hdr->elmt_fac.fac[idx]) { if (NULL == (hdr->elmt_fac.fac[idx] = H5FL_fac_init(nelmts * (size_t)hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTINIT, "can't create data block data element buffer factory") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, NULL, "can't create data block data element buffer factory") } /* end if */ /* Allocate buffer for elements in index block */ if (NULL == (elmts = H5FL_FAC_MALLOC(hdr->elmt_fac.fac[idx]))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block data element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block data element buffer") /* Set the return value */ ret_value = elmts; - CATCH +done: if (!ret_value) if (elmts) elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_alloc_elmts() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_free_elmts @@ -295,11 +308,13 @@ END_FUNC(PKG) /* end H5EA__hdr_alloc_elmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts)) - - /* Local variables */ +herr_t +H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts) +{ unsigned idx; /* Index of element buffer factory in header */ + FUNC_ENTER_PACKAGE_NOERR + /* Check arguments */ HDassert(hdr); HDassert(nelmts > 0); @@ -314,26 +329,30 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, HDassert(hdr->elmt_fac.fac[idx]); elmts = H5FL_FAC_FREE(hdr->elmt_fac.fac[idx], elmts); -END_FUNC(PKG) /* end H5EA__hdr_free_elmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__hdr_free_elmts() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_create * * Purpose: Creates a new extensible array header in the file * - * Return: SUCCEED/FAIL + * Return: Success: Address of new header in the file + * Failure: HADDR_UNDEF * * Programmer: Quincey Koziol * Jun 17 2008 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata)) +haddr_t +H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata) +{ + H5EA_hdr_t *hdr = NULL; /* Extensible array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_hdr_t *hdr = NULL; /* Extensible array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -347,39 +366,45 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Check for valid parameters */ if (cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, "element size must be greater than zero") if (cparam->max_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements bits must be greater than zero") if (cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", - (unsigned)H5EA_MAX_NELMTS_IDX_MAX) + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, "max. # of elements bits must be <= %u", + (unsigned)H5EA_MAX_NELMTS_IDX_MAX) if (cparam->sup_blk_min_data_ptrs < 2) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of data block pointers in super block must be >= two") if (!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs)) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of data block pointers in super block must be power of two") if (!POWER_OF_TWO(cparam->data_blk_min_elmts)) - H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "min # of elements per data block must be power of two") dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; if (dblk_page_nelmts < cparam->idx_blk_elmts) - H5E_THROW(H5E_BADVALUE, - "# of elements per data block page must be greater than # of elements in index block") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "# of elements per data block page must be greater than # of elements in index block") /* Compute the number of elements in data blocks for first actual super block */ sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs); dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts); if (dblk_page_nelmts < dblk_nelmts) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in " - "first data block from super block") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements per data block page bits must be > # of elements in " + "first data block from super block") if (cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits) - H5E_THROW(H5E_BADVALUE, - "max. # of elements per data block page bits must be <= max. # of elements bits") + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements per data block page bits must be <= max. # of elements bits") } #endif /* NDEBUG */ /* Allocate space for the shared information */ if (NULL == (hdr = H5EA__hdr_alloc(f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ hdr->idx_blk_addr = HADDR_UNDEF; @@ -389,49 +414,55 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Finish initializing extensible array header */ if (H5EA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINIT, HADDR_UNDEF, + "initialization failed for extensible array header") /* Allocate space for the header on disk */ if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array header") /* Create 'top' proxy for extensible array entries */ if (hdr->swmr_write) if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create extensible array entry proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, HADDR_UNDEF, "can't create extensible array entry proxy") /* Cache the new extensible array header */ if (H5AC_insert_entry(f, H5AC_EARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add extensible array header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ if (hdr->top_proxy) if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") /* Set address of array header to return */ ret_value = hdr->addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (hdr) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(hdr) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array header from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array header from cache") /* Release header's disk space */ if (H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_EARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free extensible array header") /* Destroy header */ if (H5EA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array header") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array header") } /* end if */ -END_FUNC(PKG) /* end H5EA__hdr_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_create() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_incr @@ -445,7 +476,12 @@ END_FUNC(PKG) /* end H5EA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_incr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_incr(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -453,14 +489,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_incr(H5EA_hdr_t *hdr)) /* Mark header as un-evictable when something is depending on it */ if (hdr->rc == 0) if (H5AC_pin_protected_entry(hdr) < 0) - H5E_THROW(H5E_CANTPIN, "unable to pin extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPIN, FAIL, "unable to pin extensible array header") /* Increment reference count on shared header */ hdr->rc++; - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_incr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_incr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_decr @@ -474,7 +510,12 @@ END_FUNC(PKG) /* end H5EA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_decr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_decr(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -487,12 +528,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_decr(H5EA_hdr_t *hdr)) if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); if (H5AC_unpin_entry(hdr) < 0) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin extensible array header") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPIN, FAIL, "unable to unpin extensible array header") + } -END_FUNC(PKG) /* end H5EA__hdr_decr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_decr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_incr @@ -506,7 +547,10 @@ END_FUNC(PKG) /* end H5EA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr) +{ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -514,21 +558,28 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__hdr_fuse_incr(H5EA_hdr_t *hdr)) /* Increment file reference count on shared header */ hdr->file_rc++; -END_FUNC(PKG) /* end H5EA__hdr_fuse_incr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__hdr_fuse_incr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_fuse_decr * * Purpose: Decrement file reference count on shared array header * - * Return: Non-negative on success/Negative on failure + * Return: Success: The reference count of the header + * Failure: Can't fail * * Programmer: Quincey Koziol * Aug 26 2008 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) +size_t +H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr) +{ + size_t ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -540,7 +591,8 @@ BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5EA__hdr_fuse_decr(H5EA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_fuse_decr() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_modified @@ -554,7 +606,12 @@ END_FUNC(PKG) /* end H5EA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_modified(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_modified(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -562,11 +619,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_modified(H5EA_hdr_t *hdr)) /* Mark header as dirty in cache */ if (H5AC_mark_entry_dirty(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark extensible array header as dirty") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark extensible array header as dirty") -END_FUNC(PKG) /* end H5EA__hdr_modified() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_modified() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_protect @@ -580,12 +637,14 @@ END_FUNC(PKG) /* end H5EA__hdr_modified() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, - H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags)) - - /* Local variables */ - H5EA_hdr_t * hdr; /* Extensible array header */ +H5EA_hdr_t * +H5EA__hdr_protect(H5F_t *f, haddr_t ea_addr, void *ctx_udata, unsigned flags) +{ + H5EA_hdr_t *hdr; /* Extensible array header */ H5EA_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5EA_hdr_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(f); @@ -601,27 +660,28 @@ BEGIN_FUNC(PKG, ERR, H5EA_hdr_t *, NULL, NULL, /* Protect the header */ if (NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", - (unsigned long long)ea_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for extensible array entries */ if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create extensible array entry proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTCREATE, NULL, "can't create extensible array entry proxy") /* Add header as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") } /* end if */ /* Set return value */ ret_value = hdr; - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_protect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_unprotect @@ -635,21 +695,24 @@ END_FUNC(PKG) /* end H5EA__hdr_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags)) +herr_t +H5EA__hdr_unprotect(H5EA_hdr_t *hdr, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Unprotect the header */ if (H5AC_unprotect(hdr->f, H5AC_EARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array hdr, address = %llu", - (unsigned long long)hdr->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array hdr, address = %llu", (unsigned long long)hdr->addr) -END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_delete @@ -663,46 +726,48 @@ END_FUNC(PKG) /* end H5EA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_delete(H5EA_hdr_t *hdr)) - - /* Local variables */ +herr_t +H5EA__hdr_delete(H5EA_hdr_t *hdr) +{ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); HDassert(!hdr->file_rc); #ifndef NDEBUG - { - unsigned hdr_status = 0; /* Array header's status in the metadata cache */ + unsigned hdr_status = 0; /* Array header's status in the metadata cache */ - /* Check the array header's status in the metadata cache */ - if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") + /* Check the array header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTGET, FAIL, "unable to check metadata cache status for array header") - /* Sanity checks on array header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - } /* end block */ + /* Sanity checks on array header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); #endif /* NDEBUG */ /* Check for index block */ if (H5F_addr_defined(hdr->idx_blk_addr)) { /* Delete index block */ if (H5EA__iblock_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array index block") } /* end if */ /* Set flags to finish deleting header on unprotect */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH +done: /* Unprotect the header, deleting it if an error hasn't occurred */ if (H5EA__hdr_unprotect(hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array header") -END_FUNC(PKG) /* end H5EA__hdr_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__hdr_dest @@ -716,7 +781,12 @@ END_FUNC(PKG) /* end H5EA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) +herr_t +H5EA__hdr_dest(H5EA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -725,7 +795,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Destroy the callback context */ if (hdr->cb_ctx) { if ((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy extensible array client callback context") } /* end if */ hdr->cb_ctx = NULL; @@ -741,7 +812,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Check if this factory has been initialized */ if (hdr->elmt_fac.fac[u]) { if (H5FL_fac_term(hdr->elmt_fac.fac[u]) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array header factory") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy extensible array header factory") hdr->elmt_fac.fac[u] = NULL; } /* end if */ } /* end for */ @@ -757,13 +829,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__hdr_dest(H5EA_hdr_t *hdr)) /* Destroy the 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy extensible array 'top' proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTRELEASE, FAIL, "unable to destroy extensible array 'top' proxy") hdr->top_proxy = NULL; } /* end if */ /* Free the shared info itself */ hdr = H5FL_FREE(H5EA_hdr_t, hdr); - CATCH - -END_FUNC(PKG) /* end H5EA__hdr_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__hdr_dest() */ diff --git a/src/H5EAiblock.c b/src/H5EAiblock.c index 1ef7980ad25..d0cdb7ee391 100644 --- a/src/H5EAiblock.c +++ b/src/H5EAiblock.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -91,21 +90,25 @@ H5FL_SEQ_DEFINE_STATIC(haddr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_alloc(H5EA_hdr_t *hdr)) +H5EA_iblock_t * +H5EA__iblock_alloc(H5EA_hdr_t *hdr) +{ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + H5EA_iblock_t *ret_value = NULL; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the index block */ if (NULL == (iblock = H5FL_CALLOC(H5EA_iblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array index block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") iblock->hdr = hdr; /* Set non-zero internal fields */ @@ -121,27 +124,30 @@ BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_alloc(H5EA_hdr_t if (NULL == (iblock->elmts = H5FL_BLK_MALLOC( idx_blk_elmt_buf, (size_t)(hdr->cparam.idx_blk_elmts * hdr->cparam.cls->nat_elmt_size)))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data element buffer") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block data element buffer") /* Allocate buffer for data block addresses in index block */ if (iblock->ndblk_addrs > 0) if (NULL == (iblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->ndblk_addrs))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block data block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block data block addresses") /* Allocate buffer for super block addresses in index block */ if (iblock->nsblk_addrs > 0) if (NULL == (iblock->sblk_addrs = H5FL_SEQ_MALLOC(haddr_t, iblock->nsblk_addrs))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for index block super block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for index block super block addresses") /* Set the return value */ ret_value = iblock; - CATCH +done: if (!ret_value) if (iblock && H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") - -END_FUNC(PKG) /* end H5EA__iblock_alloc() */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array index block") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_create @@ -155,13 +161,15 @@ END_FUNC(PKG) /* end H5EA__iblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed)) +haddr_t +H5EA__iblock_create(H5EA_hdr_t *hdr, hbool_t *stats_changed) +{ + H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ + haddr_t iblock_addr; /* Extensible array index block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Extensible array index block */ - haddr_t iblock_addr; /* Extensible array index block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -169,21 +177,24 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the index block */ if (NULL == (iblock = H5EA__iblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array index block") /* Set size of index block on disk */ iblock->size = H5EA_IBLOCK_SIZE(iblock); /* Allocate space for the index block on disk */ if (HADDR_UNDEF == (iblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_IBLOCK, (hsize_t)iblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array index block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array index block") iblock->addr = iblock_addr; /* Clear any elements in index block to fill value */ if (hdr->cparam.idx_blk_elmts > 0) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(iblock->elmts, (size_t)hdr->cparam.idx_blk_elmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set extensible array index block elements to class's fill value") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set extensible array index block elements to class's fill value") } /* end if */ /* Reset any data block addresses in the index block */ @@ -204,13 +215,15 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Cache the new extensible array index block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_IBLOCK, iblock_addr, iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array index block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, + "can't add extensible array index block to cache") inserted = TRUE; /* Add index block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") iblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -229,25 +242,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of index block to return */ ret_value = iblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (iblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(iblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array index block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array index block from cache") /* Release index block's disk space */ if (H5F_addr_defined(iblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_IBLOCK, iblock->addr, (hsize_t)iblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release file space for extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release file space for extensible array index block") /* Destroy index block */ if (H5EA__iblock_dest(iblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array index block") } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_protect @@ -261,10 +278,13 @@ END_FUNC(PKG) /* end H5EA__iblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags)) +H5EA_iblock_t * +H5EA__iblock_protect(H5EA_hdr_t *hdr, unsigned flags) +{ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + H5EA_iblock_t *ret_value = NULL; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -275,31 +295,35 @@ BEGIN_FUNC(PKG, ERR, H5EA_iblock_t *, NULL, NULL, H5EA__iblock_protect(H5EA_hdr_ /* Protect the index block */ if (NULL == (iblock = (H5EA_iblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_IBLOCK, hdr->idx_blk_addr, hdr, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == iblock->top_proxy) { /* Add index block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, iblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") iblock->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = iblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the index block, if it was protected */ if (iblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", - (unsigned long long)iblock->addr) + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array index block, address = %llu", + (unsigned long long)iblock->addr) } /* end if */ -END_FUNC(PKG) /* end H5EA__iblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_unprotect @@ -313,22 +337,25 @@ END_FUNC(PKG) /* end H5EA__iblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags)) +herr_t +H5EA__iblock_unprotect(H5EA_iblock_t *iblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(iblock); /* Unprotect the index block */ if (H5AC_unprotect(iblock->hdr->f, H5AC_EARRAY_IBLOCK, iblock->addr, iblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array index block, address = %llu", - (unsigned long long)iblock->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array index block, address = %llu", + (unsigned long long)iblock->addr) -END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_delete @@ -342,10 +369,13 @@ END_FUNC(PKG) /* end H5EA__iblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr)) +herr_t +H5EA__iblock_delete(H5EA_hdr_t *hdr) +{ + H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA_iblock_t *iblock = NULL; /* Pointer to index block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -353,8 +383,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Protect index block */ if (NULL == (iblock = H5EA__iblock_protect(hdr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array index block, address = %llu", - (unsigned long long)hdr->idx_blk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array index block, address = %llu", + (unsigned long long)hdr->idx_blk_addr) /* Check for index block having data block pointers */ if (iblock->ndblk_addrs > 0) { @@ -370,7 +401,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Delete data block */ if (H5EA__dblock_delete(hdr, iblock, iblock->dblk_addrs[u], hdr->sblk_info[sblk_idx].dblk_nelmts) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, + "unable to delete extensible array data block") iblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ @@ -396,19 +428,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_delete(H5EA_hdr_t *hdr) /* Delete super block */ if (H5EA__sblock_delete(hdr, iblock, iblock->sblk_addrs[u], (unsigned)(u + iblock->nsblks)) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, + "unable to delete extensible array super block") iblock->sblk_addrs[u] = HADDR_UNDEF; - } /* end if */ - } /* end for */ - } /* end if */ + } + } + } - CATCH +done: /* Finished deleting index block in metadata cache */ if (iblock && H5EA__iblock_unprotect(iblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array index block") -END_FUNC(PKG) /* end H5EA__iblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__iblock_dest @@ -422,7 +456,12 @@ END_FUNC(PKG) /* end H5EA__iblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *iblock)) +herr_t +H5EA__iblock_dest(H5EA_iblock_t *iblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(iblock); @@ -454,7 +493,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *ibl /* Decrement reference count on shared info */ if (H5EA__hdr_decr(iblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") iblock->hdr = NULL; } /* end if */ @@ -464,6 +504,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__iblock_dest(H5EA_iblock_t *ibl /* Free the index block itself */ iblock = H5FL_FREE(H5EA_iblock_t, iblock); - CATCH - -END_FUNC(PKG) /* end H5EA__iblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__iblock_dest() */ diff --git a/src/H5EAint.c b/src/H5EAint.c index 472cfb4e617..6dabeeb946e 100644 --- a/src/H5EAint.c +++ b/src/H5EAint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -79,8 +78,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5EA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -88,11 +91,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Create a flush dependency between parent and child entry */ if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") -END_FUNC(PKG) /* end H5EA__create_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__create_flush_depend() */ /*------------------------------------------------------------------------- * Function: H5EA__destroy_flush_depend @@ -106,8 +109,12 @@ END_FUNC(PKG) /* end H5EA__create_flush_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -115,8 +122,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Destroy a flush dependency between parent and child entry */ if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") -END_FUNC(PKG) /* end H5EA__destroy_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__destroy_flush_depend() */ diff --git a/src/H5EApkg.h b/src/H5EApkg.h index bfa85885dc5..272f1b827f7 100644 --- a/src/H5EApkg.h +++ b/src/H5EApkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -187,7 +186,7 @@ typedef struct H5EA_hdr_t { size_t rc; /* Reference count of heap's components using heap header */ haddr_t addr; /* Address of header in file */ size_t size; /* Size of header in file */ - H5F_t * f; /* Pointer to file for extensible array */ + H5F_t *f; /* Pointer to file for extensible array */ size_t file_rc; /* Reference count of files using array header */ hbool_t pending_delete; /* Array is pending deletion */ size_t sizeof_addr; /* Size of file addresses */ @@ -207,7 +206,7 @@ typedef struct H5EA_hdr_t { /* SWMR / Flush dependency information (not stored) */ hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ - void * parent; /* Pointer to 'top' proxy flush dependency + void *parent; /* Pointer to 'top' proxy flush dependency * parent, if it exists, otherwise NULL. * If the extensible array is being used * to index a chunked dataset and the @@ -233,7 +232,7 @@ typedef struct H5EA_iblock_t { H5AC_info_t cache_info; /* Extensible array information (stored) */ - void * elmts; /* Buffer for elements stored in index block */ + void *elmts; /* Buffer for elements stored in index block */ haddr_t *dblk_addrs; /* Buffer for addresses of data blocks in index block */ haddr_t *sblk_addrs; /* Buffer for addresses of super blocks in index block */ @@ -269,7 +268,7 @@ typedef struct H5EA_sblock_t { /* SWMR / Flush dependency information (not stored) */ hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ H5AC_proxy_entry_t *top_proxy; /* "Top" proxy cache entry for all array entries */ - H5EA_iblock_t * parent; /* Parent object for super block (index block) */ + H5EA_iblock_t *parent; /* Parent object for super block (index block) */ /* Computed/cached values (not stored) */ unsigned idx; /* Super block index within the extensible array */ @@ -287,7 +286,7 @@ typedef struct H5EA_dblock_t { /* Extensible array information (stored) */ hsize_t block_off; /* Offset of the block within the array's address space */ - void * elmts; /* Buffer for elements stored in data block */ + void *elmts; /* Buffer for elements stored in data block */ /* Internal array information (not stored) */ H5EA_hdr_t *hdr; /* Shared array header info */ @@ -297,11 +296,11 @@ typedef struct H5EA_dblock_t { /* SWMR / Flush dependency information (not stored) */ hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ - void * parent; /* Parent object for data block (index or super block) */ + void *parent; /* Parent object for data block (index or super block) */ /* Computed/cached values (not stored) */ size_t nelmts; /* Number of elements in block */ - size_t npages; /* Nummber of pages in a block (zero if not paged) */ + size_t npages; /* Number of pages in a block (zero if not paged) */ } H5EA_dblock_t; /* The extensible array data block page information */ @@ -320,7 +319,7 @@ typedef struct H5EA_dbk_page_t { /* SWMR / Flush dependency information (not stored) */ hbool_t has_hdr_depend; /* Whether this object has a flush dependency on the header */ H5AC_proxy_entry_t *top_proxy; /* "Top" proxy cache entry for all array entries */ - H5EA_sblock_t * parent; /* Parent object for data block page (super block) */ + H5EA_sblock_t *parent; /* Parent object for data block page (super block) */ /* Computed/cached values (not stored) */ /* */ @@ -329,21 +328,21 @@ typedef struct H5EA_dbk_page_t { /* Extensible array */ struct H5EA_t { H5EA_hdr_t *hdr; /* Pointer to internal extensible array header info */ - H5F_t * f; /* Pointer to file for extensible array */ + H5F_t *f; /* Pointer to file for extensible array */ }; /* Metadata cache callback user data types */ /* Info needed for loading header */ typedef struct H5EA_hdr_cache_ud_t { - H5F_t * f; /* Pointer to file for extensible array */ + H5F_t *f; /* Pointer to file for extensible array */ haddr_t addr; /* Address of header on disk */ - void * ctx_udata; /* User context for class */ + void *ctx_udata; /* User context for class */ } H5EA_hdr_cache_ud_t; /* Info needed for loading super block */ typedef struct H5EA_sblock_cache_ud_t { - H5EA_hdr_t * hdr; /* Shared extensible array information */ + H5EA_hdr_t *hdr; /* Shared extensible array information */ H5EA_iblock_t *parent; /* Pointer to parent object for super block (index block) */ unsigned sblk_idx; /* Index of super block */ haddr_t sblk_addr; /* Address of super block */ @@ -352,14 +351,14 @@ typedef struct H5EA_sblock_cache_ud_t { /* Info needed for loading data block */ typedef struct H5EA_dblock_cache_ud_t { H5EA_hdr_t *hdr; /* Shared extensible array information */ - void * parent; /* Pointer to parent object for data block (index or super block) */ + void *parent; /* Pointer to parent object for data block (index or super block) */ size_t nelmts; /* Number of elements in data block */ haddr_t dblk_addr; /* Address of data block */ } H5EA_dblock_cache_ud_t; /* Info needed for loading data block page */ typedef struct H5EA_dblk_page_cache_ud_t { - H5EA_hdr_t * hdr; /* Shared extensible array information */ + H5EA_hdr_t *hdr; /* Shared extensible array information */ H5EA_sblock_t *parent; /* Pointer to parent object for data block page (super block) */ haddr_t dblk_page_addr; /* Address of data block page */ } H5EA_dblk_page_cache_ud_t; @@ -393,7 +392,7 @@ H5_DLL herr_t H5EA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t H5_DLL H5EA_hdr_t *H5EA__hdr_alloc(H5F_t *f); H5_DLL herr_t H5EA__hdr_init(H5EA_hdr_t *hdr, void *ctx_udata); H5_DLL haddr_t H5EA__hdr_create(H5F_t *f, const H5EA_create_t *cparam, void *ctx_udata); -H5_DLL void * H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts); +H5_DLL void *H5EA__hdr_alloc_elmts(H5EA_hdr_t *hdr, size_t nelmts); H5_DLL herr_t H5EA__hdr_free_elmts(H5EA_hdr_t *hdr, size_t nelmts, void *elmts); H5_DLL herr_t H5EA__hdr_incr(H5EA_hdr_t *hdr); H5_DLL herr_t H5EA__hdr_decr(H5EA_hdr_t *hdr); diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h index 19dabd9ecfd..929108b7b25 100644 --- a/src/H5EAprivate.h +++ b/src/H5EAprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -26,11 +25,6 @@ #ifndef H5EAprivate_H #define H5EAprivate_H -/* Include package's public header */ -#ifdef NOT_YET -#include "H5EApublic.h" -#endif /* NOT_YET */ - /* Private headers needed by this file */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Fprivate.h" /* File access */ @@ -60,13 +54,13 @@ typedef enum H5EA_cls_id_t { */ typedef struct H5EA_class_t { H5EA_cls_id_t id; /* ID of Extensible Array class, as found in file */ - const char * name; /* Name of class (for debugging) */ + const char *name; /* Name of class (for debugging) */ size_t nat_elmt_size; /* Size of native (memory) element */ /* Extensible array client callback methods */ void *(*crt_context)(void *udata); /* Create context for other callbacks */ herr_t (*dst_context)(void *ctx); /* Destroy context */ - herr_t (*fill)(void * nat_blk, + herr_t (*fill)(void *nat_blk, size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, void *ctx); /* Encode elements from native form to disk storage form */ diff --git a/src/H5EAsblock.c b/src/H5EAsblock.c index 86392179674..0ba1fca2da9 100644 --- a/src/H5EAsblock.c +++ b/src/H5EAsblock.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -91,22 +90,25 @@ H5FL_BLK_DEFINE(page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, - H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx)) +H5EA_sblock_t * +H5EA__sblock_alloc(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, unsigned sblk_idx) +{ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + H5EA_sblock_t *ret_value = NULL; - /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the index block */ if (NULL == (sblock = H5FL_CALLOC(H5EA_sblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for extensible array super block") /* Share common array information */ if (H5EA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") sblock->hdr = hdr; /* Set non-zero internal fields */ @@ -121,7 +123,8 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Allocate buffer for data block addresses in super block */ if (NULL == (sblock->dblk_addrs = H5FL_SEQ_MALLOC(haddr_t, sblock->ndblks))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block data block addresses") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for super block data block addresses") /* Check if # of elements in data blocks requires paging */ if (sblock->dblk_nelmts > hdr->dblk_page_nelmts) { @@ -141,7 +144,8 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Allocate buffer for all 'page init' bitmasks in super block */ if (NULL == (sblock->page_init = H5FL_BLK_CALLOC(page_init, sblock->ndblks * sblock->dblk_page_init_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for super block page init bitmask") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for super block page init bitmask") /* Compute data block page size */ sblock->dblk_page_size = (hdr->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5EA_SIZEOF_CHKSUM; @@ -150,12 +154,13 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Set the return value */ ret_value = sblock; - CATCH +done: if (!ret_value) if (sblock && H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, NULL, "unable to destroy extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_create @@ -169,15 +174,16 @@ END_FUNC(PKG) /* end H5EA__sblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, - unsigned sblk_idx)) +haddr_t +H5EA__sblock_create(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, hbool_t *stats_changed, unsigned sblk_idx) +{ + H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ + haddr_t sblock_addr; /* Extensible array super block address */ + haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5EA_sblock_t *sblock = NULL; /* Extensible array super block */ - haddr_t sblock_addr; /* Extensible array super block address */ - haddr_t tmp_addr = HADDR_UNDEF; /* Address value to fill data block addresses with */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -185,7 +191,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the super block */ if (NULL == (sblock = H5EA__sblock_alloc(hdr, parent, sblk_idx))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for extensible array super block") /* Set size of super block on disk */ sblock->size = H5EA_SBLOCK_SIZE(sblock); @@ -195,7 +202,8 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate space for the super block on disk */ if (HADDR_UNDEF == (sblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_EARRAY_SBLOCK, (hsize_t)sblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array super block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for extensible array super block") sblock->addr = sblock_addr; /* Reset data block addresses to "undefined" address value */ @@ -203,13 +211,15 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Cache the new extensible array super block */ if (H5AC_insert_entry(hdr->f, H5AC_EARRAY_SBLOCK, sblock_addr, sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array super block to cache") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTINSERT, HADDR_UNDEF, + "can't add extensible array super block to cache") inserted = TRUE; /* Add super block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add extensible array entry as child of array proxy") sblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -223,25 +233,29 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of super block to return */ ret_value = sblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (sblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(sblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove extensible array super block from cache") + HDONE_ERROR(H5E_EARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove extensible array super block from cache") /* Release super block's disk space */ if (H5F_addr_defined(sblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_EARRAY_SBLOCK, sblock->addr, (hsize_t)sblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to release extensible array super block") /* Destroy super block */ if (H5EA__sblock_dest(sblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTFREE, HADDR_UNDEF, + "unable to destroy extensible array super block") } /* end if */ -END_FUNC(PKG) /* end H5EA__sblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_create() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_protect @@ -255,13 +269,15 @@ END_FUNC(PKG) /* end H5EA__sblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, - H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx, - unsigned flags)) - - /* Local variables */ - H5EA_sblock_t * sblock = NULL; /* Pointer to super block */ +H5EA_sblock_t * +H5EA__sblock_protect(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx, + unsigned flags) +{ + H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ H5EA_sblock_cache_ud_t udata; /* Information needed for loading super block */ + H5EA_sblock_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -279,31 +295,35 @@ BEGIN_FUNC(PKG, ERR, H5EA_sblock_t *, NULL, NULL, /* Protect the super block */ if (NULL == (sblock = (H5EA_sblock_t *)H5AC_protect(hdr->f, H5AC_EARRAY_SBLOCK, sblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)sblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, NULL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)sblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == sblock->top_proxy) { /* Add super block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, sblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add extensible array entry as child of array proxy") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTSET, NULL, + "unable to add extensible array entry as child of array proxy") sblock->top_proxy = hdr->top_proxy; - } /* end if */ + } /* Set return value */ ret_value = sblock; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the super block, if it was protected */ if (sblock && H5AC_unprotect(hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", - (unsigned long long)sblock->addr) - } /* end if */ + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect extensible array super block, address = %llu", + (unsigned long long)sblock->addr) + } -END_FUNC(PKG) /* end H5EA__sblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_protect() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_unprotect @@ -317,22 +337,25 @@ END_FUNC(PKG) /* end H5EA__sblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags)) +herr_t +H5EA__sblock_unprotect(H5EA_sblock_t *sblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(sblock); /* Unprotect the super block */ if (H5AC_unprotect(sblock->hdr->f, H5AC_EARRAY_SBLOCK, sblock->addr, sblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect extensible array super block, address = %llu", - (unsigned long long)sblock->addr) - - CATCH + HGOTO_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect extensible array super block, address = %llu", + (unsigned long long)sblock->addr) -END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_delete @@ -346,12 +369,14 @@ END_FUNC(PKG) /* end H5EA__sblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx)) - - /* Local variables */ +herr_t +H5EA__sblock_delete(H5EA_hdr_t *hdr, H5EA_iblock_t *parent, haddr_t sblk_addr, unsigned sblk_idx) +{ H5EA_sblock_t *sblock = NULL; /* Pointer to super block */ size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -359,8 +384,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Protect super block */ if (NULL == (sblock = H5EA__sblock_protect(hdr, parent, sblk_addr, sblk_idx, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array super block, address = %llu", - (unsigned long long)sblk_addr) + HGOTO_ERROR(H5E_EARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect extensible array super block, address = %llu", + (unsigned long long)sblk_addr) /* Iterate over data blocks */ for (u = 0; u < sblock->ndblks; u++) { @@ -368,18 +394,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (H5F_addr_defined(sblock->dblk_addrs[u])) { /* Delete data block */ if (H5EA__dblock_delete(hdr, sblock, sblock->dblk_addrs[u], sblock->dblk_nelmts) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete extensible array data block") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDELETE, FAIL, "unable to delete extensible array data block") sblock->dblk_addrs[u] = HADDR_UNDEF; } /* end if */ } /* end for */ - CATCH +done: /* Finished deleting super block in metadata cache */ if (sblock && H5EA__sblock_unprotect(sblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block") + HDONE_ERROR(H5E_EARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release extensible array super block") -END_FUNC(PKG) /* end H5EA__sblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_delete() */ /*------------------------------------------------------------------------- * Function: H5EA__sblock_dest @@ -393,7 +420,12 @@ END_FUNC(PKG) /* end H5EA__sblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sblock)) +herr_t +H5EA__sblock_dest(H5EA_sblock_t *sblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(sblock); @@ -413,7 +445,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sbl /* Decrement reference count on shared info */ if (H5EA__hdr_decr(sblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") sblock->hdr = NULL; } /* end if */ @@ -423,6 +456,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5EA__sblock_dest(H5EA_sblock_t *sbl /* Free the super block itself */ sblock = H5FL_FREE(H5EA_sblock_t, sblock); - CATCH - -END_FUNC(PKG) /* end H5EA__sblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__sblock_dest() */ diff --git a/src/H5EAstat.c b/src/H5EAstat.c index 47b9a869dbe..2f955ff604f 100644 --- a/src/H5EAstat.c +++ b/src/H5EAstat.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -80,17 +79,17 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats)) +herr_t +H5EA_get_stats(const H5EA_t *ea, H5EA_stat_t *stats) +{ + FUNC_ENTER_NOAPI_NOERR - /* Local variables */ - - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(stats); /* Copy extensible array statistics */ H5MM_memcpy(stats, &ea->hdr->stats, sizeof(ea->hdr->stats)); -END_FUNC(PRIV) /* end H5EA_get_stats() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA_get_stats() */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index dd669fc44d7..205981b94fc 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -64,13 +63,13 @@ typedef struct H5EA__test_ctx_t { /********************/ /* Extensible array class callbacks */ -static void * H5EA__test_crt_context(void *udata); +static void *H5EA__test_crt_context(void *udata); static herr_t H5EA__test_dst_context(void *ctx); static herr_t H5EA__test_fill(void *nat_blk, size_t nelmts); static herr_t H5EA__test_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); static herr_t H5EA__test_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); static herr_t H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); -static void * H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr); +static void *H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr); static herr_t H5EA__test_dst_dbg_context(void *_ctx); /*********************/ @@ -119,17 +118,19 @@ H5FL_DEFINE_STATIC(H5EA__ctx_cb_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5EA__test_crt_context(void *_udata)) +static void * +H5EA__test_crt_context(void *_udata) +{ + H5EA__test_ctx_t *ctx; /* Context for callbacks */ + H5EA__ctx_cb_t *udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ + void *ret_value = NULL; - /* Local variables */ - H5EA__test_ctx_t *ctx; /* Context for callbacks */ - H5EA__ctx_cb_t * udata = (H5EA__ctx_cb_t *)_udata; /* User data for context */ - - /* Sanity checks */ + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5EA__test_ctx_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Initialize the context */ ctx->bogus = H5EA__TEST_BOGUS_VAL; @@ -138,9 +139,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5EA__test_crt_context(void *_udata) /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5EA__test_crt_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_crt_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_dst_context @@ -155,18 +156,21 @@ END_FUNC(STATIC) /* end H5EA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5EA__test_dst_context(void *_ctx) +{ H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(H5EA__TEST_BOGUS_VAL == ctx->bogus); /* Release context structure */ ctx = H5FL_FREE(H5EA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_dst_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_fill @@ -181,18 +185,21 @@ END_FUNC(STATIC) /* end H5EA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_fill(void *nat_blk, size_t nelmts)) - - /* Local variables */ +static herr_t +H5EA__test_fill(void *nat_blk, size_t nelmts) +{ uint64_t fill_val = H5EA_TEST_FILL; /* Value to fill elements with */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(nat_blk); HDassert(nelmts); H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5EA__test_fill() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_fill() */ /*------------------------------------------------------------------------- * Function: H5EA__test_encode @@ -207,12 +214,14 @@ END_FUNC(STATIC) /* end H5EA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx)) +static herr_t +H5EA__test_encode(void *raw, const void *_elmt, size_t nelmts, void *_ctx) +{ + H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ + const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ - const uint64_t * elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + FUNC_ENTER_STATIC /* Sanity checks */ HDassert(raw); @@ -223,13 +232,12 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Check for callback action */ if (ctx->cb) { if ((*ctx->cb->encode)(elmt, nelmts, ctx->cb->udata) < 0) - H5E_THROW(H5E_BADVALUE, "extensible array testing callback action failed") - } /* end if */ + HGOTO_ERROR(H5E_EARRAY, H5E_BADVALUE, FAIL, "extensible array testing callback action failed") + } /* Encode native elements into raw elements */ while (nelmts) { - /* Encode element */ - /* (advances 'raw' pointer) */ + /* Encode element - advances 'raw' pointer */ UINT64ENCODE(raw, *elmt); /* Advance native element pointer */ @@ -237,11 +245,11 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Decrement # of elements to encode */ nelmts--; - } /* end while */ + } - CATCH - -END_FUNC(STATIC) /* end H5EA__test_encode() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_encode() */ /*------------------------------------------------------------------------- * Function: H5EA__test_decode @@ -256,16 +264,17 @@ END_FUNC(STATIC) /* end H5EA__test_encode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5EA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_NDEBUG_UNUSED *_ctx) +{ #ifndef NDEBUG H5EA__test_ctx_t *ctx = (H5EA__test_ctx_t *)_ctx; /* Callback context to destroy */ #endif /* NDEBUG */ - uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ + uint64_t *elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(raw); HDassert(elmt); @@ -274,8 +283,7 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Decode raw elements into native elements */ while (nelmts) { - /* Decode element */ - /* (advances 'raw' pointer) */ + /* Decode element - advances 'raw' pointer */ UINT64DECODE(raw, *elmt); /* Advance native element pointer */ @@ -283,9 +291,10 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Decrement # of elements to decode */ nelmts--; - } /* end while */ + } -END_FUNC(STATIC) /* end H5EA__test_decode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_decode() */ /*------------------------------------------------------------------------- * Function: H5EA__test_debug @@ -300,22 +309,24 @@ END_FUNC(STATIC) /* end H5EA__test_decode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) - - /* Local variables */ +static herr_t +H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) +{ char temp_str[128]; /* Temporary string, for formatting */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(stream); HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%llu:", (unsigned long long)idx); HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5EA__test_debug() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_debug() */ /*------------------------------------------------------------------------- * Function: H5EA__test_crt_dbg_context @@ -329,22 +340,25 @@ END_FUNC(STATIC) /* end H5EA__test_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) - - /* Local variables */ +static void * +H5EA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr) +{ H5EA__ctx_cb_t *ctx; /* Context for callbacks */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5EA__ctx_cb_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context") + HGOTO_ERROR(H5E_EARRAY, H5E_CANTALLOC, NULL, + "can't allocate extensible array client callback context") /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__test_crt_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5EA__test_dst_dbg_context @@ -358,17 +372,20 @@ END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5EA__test_dst_dbg_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5EA__test_dst_dbg_context(void *_ctx) +{ H5EA__ctx_cb_t *ctx = (H5EA__ctx_cb_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + HDassert(_ctx); /* Release context structure */ ctx = H5FL_FREE(H5EA__ctx_cb_t, ctx); -END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__test_dst_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5EA__get_cparam_test @@ -383,7 +400,10 @@ END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam)) +herr_t +H5EA__get_cparam_test(const H5EA_t *ea, H5EA_create_t *cparam) +{ + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(ea); @@ -397,7 +417,8 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5EA__get_cparam_test(const H5EA_t *e cparam->data_blk_min_elmts = ea->hdr->cparam.data_blk_min_elmts; cparam->max_dblk_page_nelmts_bits = ea->hdr->cparam.max_dblk_page_nelmts_bits; -END_FUNC(PKG) /* end H5EA__get_cparam_test() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5EA__get_cparam_test() */ /*------------------------------------------------------------------------- * Function: H5EA__cmp_cparam_test @@ -412,39 +433,48 @@ END_FUNC(PKG) /* end H5EA__get_cparam_test() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, - H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2)) +int +H5EA__cmp_cparam_test(const H5EA_create_t *cparam1, const H5EA_create_t *cparam2) +{ + int ret_value = 0; - /* Check arguments. */ + FUNC_ENTER_PACKAGE_NOERR + + /* Check arguments */ HDassert(cparam1); HDassert(cparam2); /* Compare creation parameters for array */ if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->max_nelmts_bits < cparam2->max_nelmts_bits) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->max_nelmts_bits > cparam2->max_nelmts_bits) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->idx_blk_elmts < cparam2->idx_blk_elmts) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->idx_blk_elmts > cparam2->idx_blk_elmts) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->sup_blk_min_data_ptrs < cparam2->sup_blk_min_data_ptrs) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->sup_blk_min_data_ptrs > cparam2->sup_blk_min_data_ptrs) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->data_blk_min_elmts < cparam2->data_blk_min_elmts) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->data_blk_min_elmts > cparam2->data_blk_min_elmts) - H5_LEAVE(1) + HGOTO_DONE(1) + if (cparam1->max_dblk_page_nelmts_bits < cparam2->max_dblk_page_nelmts_bits) - H5_LEAVE(-1) + HGOTO_DONE(-1) else if (cparam1->max_dblk_page_nelmts_bits > cparam2->max_dblk_page_nelmts_bits) - H5_LEAVE(1) - - CATCH + HGOTO_DONE(1) -END_FUNC(PKG) /* end H5EA__cmp_cparam_test() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5EA__cmp_cparam_test() */ diff --git a/src/H5ESpublic.h b/src/H5ESpublic.h index 28b41fa6d5f..d148e4e6e01 100644 --- a/src/H5ESpublic.h +++ b/src/H5ESpublic.h @@ -2,7 +2,7 @@ * Copyright by The HDF Group. * * All rights reserved. * * * - * This file is part of HDF5. The full HDF5 copyright notice, including * + * 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. * @@ -28,12 +28,14 @@ /* Public Typedefs */ /*******************/ -/* Asynchronous operation status */ +/** + * Asynchronous operation status + */ typedef enum H5ES_status_t { - H5ES_STATUS_IN_PROGRESS, /* Operation has not yet completed */ - H5ES_STATUS_SUCCEED, /* Operation has completed, successfully */ - H5ES_STATUS_FAIL, /* Operation has completed, but failed */ - H5ES_STATUS_CANCELED /* Operation has not completed and was canceled */ + H5ES_STATUS_IN_PROGRESS, /**< Operation(s) have not yet completed */ + H5ES_STATUS_SUCCEED, /**< Operation(s) have completed, successfully */ + H5ES_STATUS_FAIL, /**< An operation has completed, but failed */ + H5ES_STATUS_CANCELED /**< Operation(s) has been canceled */ } H5ES_status_t; /********************/ diff --git a/src/H5Edefin.h b/src/H5Edefin.h index f9c9196cc1d..a0b21e64e08 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index 9431089ea27..b7bd6964724 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -88,8 +87,8 @@ H5Eget_major(H5E_major_t maj) H5E_msg_t *msg; /* Pointer to error message */ ssize_t size; H5E_type_t type; - char * msg_str = NULL; - char * ret_value; /* Return value */ + char *msg_str = NULL; + char *ret_value; /* Return value */ FUNC_ENTER_API_NOCLEAR(NULL) H5TRACE1("*s", "i", maj); @@ -140,8 +139,8 @@ H5Eget_minor(H5E_minor_t min) H5E_msg_t *msg; /* Pointer to error message */ ssize_t size; H5E_type_t type; - char * msg_str = NULL; - char * ret_value; /* Return value */ + char *msg_str = NULL; + char *ret_value; /* Return value */ FUNC_ENTER_API_NOCLEAR(NULL) H5TRACE1("*s", "i", min); @@ -295,7 +294,7 @@ H5Eprint1(FILE *stream) herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data) { - H5E_t * estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ H5E_walk_op_t walk_op; /* Error stack walking callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -336,7 +335,7 @@ H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data) herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data) { - H5E_t * estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ H5E_auto_op_t auto_op; /* Error stack operator */ herr_t ret_value = SUCCEED; /* Return value */ @@ -389,7 +388,7 @@ H5Eget_auto1(H5E_auto1_t *func, void **client_data) herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data) { - H5E_t * estack; /* Error stack to operate on */ + H5E_t *estack; /* Error stack to operate on */ H5E_auto_op_t auto_op; /* Error stack operator */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Einit.h b/src/H5Einit.h index d27e550e8c5..f871d9c48c8 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Eint.c b/src/H5Eint.c index 3fd4099ec60..4039e706445 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -47,7 +46,7 @@ /* Printing information */ typedef struct H5E_print_t { - FILE * stream; + FILE *stream; H5E_cls_t cls; } H5E_print_t; @@ -129,7 +128,7 @@ H5E__get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) /* Copy the message into the user's buffer, if given */ if (msg_str) { - HDstrncpy(msg_str, msg->msg, MIN((size_t)(len + 1), size)); + HDstrncpy(msg_str, msg->msg, size); if ((size_t)len >= size) msg_str[size - 1] = '\0'; } /* end if */ @@ -181,12 +180,12 @@ static herr_t H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) { H5E_print_t *eprint = (H5E_print_t *)client_data; - FILE * stream; /* I/O stream to print output to */ - H5E_cls_t * cls_ptr; /* Pointer to error class */ - H5E_msg_t * maj_ptr; /* Pointer to major error info */ - H5E_msg_t * min_ptr; /* Pointer to minor error info */ - const char * maj_str = "No major description"; /* Major error description */ - const char * min_str = "No minor description"; /* Minor error description */ + FILE *stream; /* I/O stream to print output to */ + H5E_cls_t *cls_ptr; /* Pointer to error class */ + H5E_msg_t *maj_ptr; /* Pointer to major error info */ + H5E_msg_t *min_ptr; /* Pointer to minor error info */ + const char *maj_str = "No major description"; /* Major error description */ + const char *min_str = "No minor description"; /* Minor error description */ unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ herr_t ret_value = SUCCEED; @@ -304,12 +303,12 @@ static herr_t H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) { H5E_print_t *eprint = (H5E_print_t *)client_data; - FILE * stream; /* I/O stream to print output to */ - H5E_cls_t * cls_ptr; /* Pointer to error class */ - H5E_msg_t * maj_ptr; /* Pointer to major error info */ - H5E_msg_t * min_ptr; /* Pointer to minor error info */ - const char * maj_str = "No major description"; /* Major error description */ - const char * min_str = "No minor description"; /* Minor error description */ + FILE *stream; /* I/O stream to print output to */ + H5E_cls_t *cls_ptr; /* Pointer to error class */ + H5E_msg_t *maj_ptr; /* Pointer to major error info */ + H5E_msg_t *min_ptr; /* Pointer to minor error info */ + const char *maj_str = "No major description"; /* Major error description */ + const char *min_str = "No minor description"; /* Minor error description */ unsigned have_desc = 1; /* Flag to indicate whether the error has a "real" description */ herr_t ret_value = SUCCEED; @@ -651,7 +650,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin hid_t min_id, const char *fmt, ...) { va_list ap; /* Varargs info */ - char * tmp = NULL; /* Buffer to place formatted description in */ + char *tmp = NULL; /* Buffer to place formatted description in */ hbool_t va_started = FALSE; /* Whether the variable argument list is open */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Emodule.h b/src/H5Emodule.h index 43d5d36e431..c827d70f9ce 100644 --- a/src/H5Emodule.h +++ b/src/H5Emodule.h @@ -29,33 +29,528 @@ #define H5_MY_PKG_ERR H5E_ERROR #define H5_MY_PKG_INIT YES -/** - * \defgroup H5E H5E - * \brief Error Handling Interface - * - * \details The Error interface provides error handling in the form of a stack. - * The \Code{FUNC_ENTER} macro clears the error stack whenever an - * interface function is entered. When an error is detected, an entry - * is pushed onto the stack. As the functions unwind, additional - * entries are pushed onto the stack. The API function will return some - * indication that an error occurred and the application can print the - * error stack. - * - * Certain API functions in the \c H5E package, such as H5Eprint1(), do - * not clear the error stack. Otherwise, any function which does not - * have an underscore immediately after the package name will clear the - * error stack. For instance, H5Fopen() clears the error stack while - * \Code{H5F_open} does not. - * - * An error stack has a fixed maximum size. If this size is exceeded - * then the stack will be truncated and only the inner-most functions - * will have entries on the stack. This is expected to be a rare - * condition. - * - * Each thread has its own error stack, but since multi-threading has - * not been added to the library yet, this package maintains a single - * error stack. The error stack is statically allocated to reduce the - * complexity of handling errors within the \c H5E package. +/** \page H5E_UG HDF5 Error Handling + * + * \section sec_error HDF5 Error Handling + * + * The HDF5 library provides an error reporting mechanism for both the library itself and for user + * application programs. It can trace errors through function stack and error information like file + * name, function name, line number, and error description. + * + * \subsection subsec_error_intro Introduction + * The HDF5 Library provides an error reporting mechanism for both the library itself and for user application + * programs. It can trace errors through function stack and error information like file name, function name, + * line number, and error description. + * + * \ref subsec_error_ops discusses the basic error concepts such as error stack, error record, and error + * message and describes the related API functions. These concepts and functions are sufficient for + * application programs to trace errors inside the HDF5 Library. + * + * \ref subsec_error_adv talks about the advanced concepts of error + * class and error stack handle and talks about the related functions. With these concepts and functions, an + * application library or program using the HDF5 Library can have its own error report blended with HDF5’s + * error report. + * + * Starting with Release 1.8, we have a new set of Error Handling API functions. For the purpose of backward + * compatibility with version 1.6 and before, we still keep the old API functions, \ref H5Epush1, + * \ref H5Eprint1, \ref H5Ewalk1, \ref H5Eclear1, \ref H5Eget_auto1, \ref H5Eset_auto1. These functions do + * not have the error stack as a parameter. The library allows them to operate on the default error stack. + * (The H5E compatibility macros will choose the correct function based on the parameters) + * + * The old API is similar to functionality discussed in \ref subsec_error_ops. The functionality discussed in + * \ref subsec_error_adv,the ability of allowing applications to add their own error records, is the new + * design for the Error Handling API. + * + * \subsection subsec_error_H5E Error Handling Function Summaries + * @see H5E reference manual + * + * \subsection subsec_error_program Programming Model for Error Handling + * This section is under construction. + * + * \subsection subsec_error_ops Basic Error Handling Operations + * Let us first try to understand the error stack. An error stack is a collection of error records. Error + * records can be pushed onto or popped off the error stack. By default, when an error occurs deep within + * the HDF5 Library, an error record is pushed onto an error stack and that function returns a failure + * indication. + * Its caller detects the failure, pushes another record onto the stack, and returns a failure indication. + * This continues until the API function called by the application returns a failure indication. The next + * API function being called will reset the error stack. All HDF5 Library error records belong to the same + * error class. For more information, see \ref subsec_error_adv. + * + * \subsubsection subsubsec_error_ops_stack Error Stack and Error Message + * In normal circumstances, an error causes the stack to be printed on the standard error stream + * automatically. + * This automatic error stack is the library’s default stack. For all the functions in this section, whenever + * an error stack ID is needed as a parameter, \ref H5E_DEFAULT can be used to indicate the library’s default + * stack. The first error record of the error stack, number #000, is produced by the API function itself and + * is usually sufficient to indicate to the application what went wrong. + * + * + * + * + * + *
Example: An Error Message
+ *

If an application calls \ref H5Tclose on a + * predefined datatype then the following message is + * printed on the standard error stream. This is a + * simple error that has only one component, the API + * function; other errors may have many components. + *

+ * HDF5-DIAG: Error detected in HDF5 (1.10.9) thread 0.
+ *    #000: H5T.c line ### in H5Tclose(): predefined datatype
+ *       major: Function argument
+ *       minor: Bad value
+ *         
+ *
+ * In the example above, we can see that an error record has a major message and a minor message. A major + * message generally indicates where the error happens. The location can be a dataset or a dataspace, for + * example. A minor message explains further details of the error. An example is “unable to open fileâ€. + * Another specific detail about the error can be found at the end of the first line of each error record. + * This error description is usually added by the library designer to tell what exactly goes wrong. In the + * example above, the “predefined datatype†is an error description. + * + * \subsubsection subsubsec_error_ops_print Print and Clear an Error Stack + * Besides the automatic error report, the error stack can also be printed and cleared by the functions + * \ref H5Eprint2 and \ref H5Eclear2. If an application wishes to make explicit + * calls to \ref H5Eprint2 to print the error stack, the automatic printing should be turned off + * to prevent error messages from being displayed twice (see \ref H5Eset_auto2). + * + * To print an error stack: + * \code + * herr_t H5Eprint2(hid_t error_stack, FILE * stream) + * \endcode + * This function prints the error stack specified by error_stack on the specified stream, stream. If the + * error stack is empty, a oneâ€line message will be printed. The following is an example of such a message. + * This message would be generated if the error was in the HDF5 Library. + * \code + * HDF5-DIAG: Error detected in HDF5 Library version: 1.10.9 thread 0. + * \endcode + * + * To clear an error stack: + * \code + * herr_t H5Eclear2(hid_t error_stack) + * \endcode + * The \ref H5Eclear2 function shown above clears the error stack specified by error_stack. + * \ref H5E_DEFAULT can be passed in to clear the current error stack. The current stack is also cleared + * whenever an API function is called; there are certain exceptions to this rule such as \ref H5Eprint2. + * + * \subsubsection subsubsec_error_ops_mute Mute Error Stack + * Sometimes an application calls a function for the sake of its return value, fully expecting the function + * to fail; sometimes the application wants to call \ref H5Eprint2 explicitly. In these situations, + * it would be misleading if an error message were still automatically printed. Using the + * \ref H5Eset_auto2 function can control the automatic printing of error messages. + * + * To enable or disable automatic printing of errors: + * \code + * herr_t H5Eset_auto2(hid_t error_stack, H5E_auto_t func, void *client_data) + * \endcode + * The \ref H5Eset_auto2 function can be used to turn on or off the automatic printing of errors + * for the error stack specified by error_stack. When turned on (nonâ€null func pointer), any API function + * which returns an error indication will first call func, passing it client_data as an argument. When the + * library is first initialized the auto printing function is set to \ref H5Eprint2 and client_data + * is the standard error stream pointer, stderr. + * + * To see the current settings: + * \code + * herr_t H5Eget_auto(hid_t error_stack, H5E_auto_t * func, void **client_data) + * \endcode + * The function above returns the current settings for the automatic error stack traversal function, func, and + * its data, client_data. If either or both of the arguments are null, then the value is not returned. + * + * An application can temporarily turn off error messages while “probing†a function. See the + * example below. + * + * Example: Turn off error messages while probing a function + * \code + * *** Save old error handler *** + * H5E_auto2_t oldfunc; + * void *old_client_data; + * H5Eget_auto2(error_stack, &old_func, &old_client_data); + * *** Turn off error handling *** + * H5Eset_auto2(error_stack, NULL, NULL); + * *** Probe. Likely to fail, but that’s okay *** + * status = H5Fopen (......); + * *** Restore previous error handler *** + * H5Eset_auto2(error_stack, old_func, old_client_data); + * \endcode + * + * Or automatic printing can be disabled altogether and error messages can be explicitly printed. + * + * Example: Disable automatic printing and explicitly print error messages + * \code + * *** Turn off error handling permanently *** + * H5Eset_auto2(error_stack, NULL, NULL); + * *** If failure, print error message *** + * if (H5Fopen (....)<0) { + * H5Eprint2(H5E_DEFAULT, stderr); + * exit (1); + * } + * \endcode + * + * \subsubsection subsubsec_error_ops_custom_print Customized Printing of an Error Stack + * Applications are allowed to define an automatic error traversal function other than the default + * \ref H5Eprint(). For instance, one can define a function that prints a simple, oneâ€line error message to + * the standard error stream and then exits. The first example below defines a such a function. The second + * example below installs the function as the error handler. + * + * Example: Defining a function to print a simple error message + * \code + * herr_t + * my_hdf5_error_handler(void *unused) + * { + * fprintf (stderr, “An HDF5 error was detected. Bye.\\nâ€); + * exit (1); + * } + * \endcode + * + * Example: The userâ€defined error handler + * \code + * H5Eset_auto2(H5E_DEFAULT, my_hdf5_error_handler, NULL); + * \endcode + * + * \subsubsection subsubsec_error_ops_walk Walk through the Error Stack + * The \ref H5Eprint2 function is actually just a wrapper around the more complex \ref H5Ewalk function + * which traverses an error stack and calls a userâ€defined function for each member of the stack. The example + * below shows how \ref H5Ewalk is used. + * \code + * herr_t H5Ewalk(hid_t err_stack, H5E_direction_t direction, + * H5E_walk_t func, void *client_data) + * \endcode + * The error stack err_stack is traversed and func is called for each member of the stack. Its arguments + * are an integer sequence number beginning at zero (regardless of direction) and the client_data + * pointer. If direction is \ref H5E_WALK_UPWARD, then traversal begins at the innerâ€most function that + * detected the error and concludes with the API function. Use \ref H5E_WALK_DOWNWARD for the opposite + * order. + * + * \subsubsection subsubsec_error_ops_travers Traverse an Error Stack with a Callback Function + * An error stack traversal callback function takes three arguments: n is a sequence number beginning at + * zero for each traversal, eptr is a pointer to an error stack member, and client_data is the same pointer + * used in the example above passed to \ref H5Ewalk. See the example below. + * \code + * typedef herr_t (*H5E_walk_t)(unsigned n, H5E_error2_t *eptr, void *client_data) + * \endcode + * The H5E_error2_t structure is shown below. + * \code + * typedef struct { + * hid_t cls_id; + * hid_t maj_num; + * hid_t min_num; + * unsigned line; + * const char *func_name; + * const char *file_name; + * const char *desc; + * } H5E_error2_t; + * \endcode + * The maj_num and min_num are major and minor error IDs, func_name is the name of the function where + * the error was detected, file_name and line locate the error within the HDF5 Library source code, and + * desc points to a description of the error. + * + * The following example shows a userâ€defined callback function. + * + * Example: A userâ€defined callback function + * \code + * \#define MSG_SIZE 64 + * herr_t + * custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) + * { + * FILE *stream = (FILE *)client_data; + * char maj[MSG_SIZE]; + * char min[MSG_SIZE]; + * char cls[MSG_SIZE]; + * const int indent = 4; + * + * *** Get descriptions for the major and minor error numbers *** + * if(H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE) < 0) + * TEST_ERROR; + * if(H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE) < 0) + * TEST_ERROR; + * if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE) < 0) + * TEST_ERROR; + * fprintf (stream, “%*serror #%03d: %s in %s(): + * line %u\\nâ€, + * indent, “â€, n, err_desc->file_name, + * err_desc->func_name, err_desc->line); + * fprintf (stream, “%*sclass: %s\\nâ€, indent*2, “â€, cls); + * fprintf (stream, “%*smajor: %s\\nâ€, indent*2, “â€, maj); + * fprintf (stream, “%*sminor: %s\\nâ€, indent*2, “â€, min); + * return 0; + * error: + * return -1; + * } + * \endcode + * + *

Programming Note for C++ Developers Using C Functions

+ * If a C routine that takes a function pointer as an argument is called from within C++ code, the C routine + * should be returned from normally. + * + * Examples of this kind of routine include callbacks such as \ref H5Pset_elink_cb and + * \ref H5Pset_type_conv_cb and + * functions such as \ref H5Tconvert and \ref H5Ewalk2. + * + * Exiting the routine in its normal fashion allows the HDF5 C Library to clean up its work properly. In other + * words, if the C++ application jumps out of the routine back to the C++ “catch†statement, the library is + * not given the opportunity to close any temporary data structures that were set up when the routine was + * called. The C++ application should save some state as the routine is started so that any problem that + * occurs might be diagnosed. + * + * \subsection subsec_error_adv Advanced Error Handling Operations + * The section above, see \ref subsec_error_ops, discusses the basic error + * handling operations of the library. In that section, all the error records on the error stack are from the + * library itself. In this section, we are going to introduce the operations that allow an application program + * to push its own error records onto the error stack once it declares an error class of its own through the + * HDF5 Error API. + * + * + * + * + * + * + *
Example: An Error Report
+ *

An error report shows both the library’s error record and the application’s error records. + * See the example below. + *

+ * Error Test-DIAG: Error detected in Error Program (1.0)
+ *         thread 8192:
+ *     #000: ../../hdf5/test/error_test.c line ### in main():
+ *         Error test failed
+ *       major: Error in test
+ *       minor: Error in subroutine
+ *     #001: ../../hdf5/test/error_test.c line ### in
+ *         test_error(): H5Dwrite failed as supposed to
+ *       major: Error in IO
+ *       minor: Error in H5Dwrite
+ *   HDF5-DIAG: Error detected in HDF5 (1.10.9) thread #####:
+ *     #002: ../../hdf5/src/H5Dio.c line ### in H5Dwrite():
+ *         not a dataset
+ *       major: Invalid arguments to routine
+ *       minor: Inappropriate type
+ *       
+ *
+ * In the line above error record #002 in the example above, the starting phrase is HDF5. This is the error + * class name of the HDF5 Library. All of the library’s error messages (major and minor) are in this default + * error class. The Error Test in the beginning of the line above error record #000 is the name of the + * application’s error class. The first two error records, #000 and #001, are from application’s error class. + * By definition, an error class is a group of major and minor error messages for a library (the HDF5 Library + * or an application library built on top of the HDF5 Library) or an application program. The error class can + * be registered for a library or program through the HDF5 Error API. Major and minor messages can be defined + * in an error class. An application will have object handles for the error class and for major and minor + * messages for further operation. See the example below. + * + * Example: The userâ€defined error handler + * \code + * \#define MSG_SIZE 64 + * herr_t + * custom_print_cb(unsigned n, const H5E_error2_t *err_desc, + * void* client_data) + * { + * FILE *stream = (FILE *)client_data; + * char maj[MSG_SIZE]; + * char min[MSG_SIZE]; + * char cls[MSG_SIZE]; + * const int indent = 4; + * + * *** Get descriptions for the major and minor error numbers *** + * if(H5Eget_class_name(err_desc->cls_id, cls, MSG_SIZE) < 0) + * TEST_ERROR; + * if(H5Eget_msg(err_desc->maj_num, NULL, maj, MSG_SIZE) < 0) + * TEST_ERROR; + * if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE) < 0) + * TEST_ERROR; + * fprintf (stream, “%*serror #%03d: %s in %s(): + * line %u\\nâ€, + * indent, “â€, n, err_desc->file_name, + * err_desc->func_name, err_desc->line); + * fprintf (stream, “%*sclass: %s\\nâ€, indent*2, “â€, cls); + * fprintf (stream, “%*smajor: %s\\nâ€, indent*2, “â€, maj); + * fprintf (stream, “%*sminor: %s\\nâ€, indent*2, “â€, min); + * return 0; + * error: + * return -1; + * } + * \endcode + * + * \subsubsection subsubsec_error_adv_more More Error API Functions + * The Error API has functions that can be used to register or unregister an error class, to create or close + * error messages, and to query an error class or error message. These functions are illustrated below. + * + * To register an error class: + * \code + * hid_t H5Eregister_class(const char* cls_name, const char* lib_name, const char* version) + * \endcode + * This function registers an error class with the HDF5 Library so that the application library or program + * can report errors together with the HDF5 Library. + * + * To add an error message to an error class: + * \code + * hid_t H5Ecreate_msg(hid_t class, H5E_type_t msg_type, const char* mesg) + * \endcode + * This function adds an error message to an error class defined by an application library or program. The + * error message can be either major or minor which is indicated by parameter msg_type. + * + * To get the name of an error class: + * \code + * ssize_t H5Eget_class_name(hid_t class_id, char* name, size_t size) + * \endcode + * This function retrieves the name of the error class specified by the class ID. + * + * To retrieve an error message: + * \code + * ssize_t H5Eget_msg(hid_t mesg_id, H5E_type_t* mesg_type, char* mesg, size_t size) + * \endcode + * This function retrieves the error message including its length and type. + * + * To close an error message: + * \code + * herr_t H5Eclose_msg(hid_t mesg_id) + * \endcode + * This function closes an error message. + * + * To remove an error class: + * \code + * herr_t H5Eunregister_class(hid_t class_id) + * \endcode + * This function removes an error class from the Error API. + * + * The example below shows how an application creates an error class and error messages. + * + * Example: Create an error class and error messages + * \code + * *** Create an error class *** + * class_id = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS); + * *** Retrieve class name *** + * H5Eget_class_name(class_id, cls_name, cls_size); + * *** Create a major error message in the class *** + * maj_id = H5Ecreate_msg(class_id, H5E_MAJOR, “... ...â€); + * *** Create a minor error message in the class *** + * min_id = H5Ecreate_msg(class_id, H5E_MINOR, “... ...â€); + * \endcode + * + * The example below shows how an application closes error messages and unregisters the error class. + * + * Example: Closing error messages and unregistering the error class + * \code + * H5Eclose_msg(maj_id); + * H5Eclose_msg(min_id); + * H5Eunregister_class(class_id); + * \endcode + * + * \subsubsection subsubsec_error_adv_app Pushing an Application Error Message onto Error Stack + * An application can push error records onto or pop error records off of the error stack just as the library + * does internally. An error stack can be registered, and an object handle can be returned to the application + * so that the application can manipulate a registered error stack. + * + * To register the current stack: + * \code + * hid_t H5Eget_current_stack(void) + * \endcode + * This function registers the current error stack, returns an object handle, and clears the current error + * stack. + * An empty error stack will also be assigned an ID. + * + * To replace the current error stack with another: + * \code + * herr_t H5Eset_current_stack(hid_t error_stack) + * \endcode + * This function replaces the current error stack with another error stack specified by error_stack and + * clears the current error stack. The object handle error_stack is closed after this function call. + * + * To push a new error record to the error stack: + * \code + * herr_t H5Epush(hid_t error_stack, const char* file, const char* func, + * unsigned line, hid_t cls_id, hid_t major_id, hid_t minor_id, + * const char* desc, ... ) + * \endcode + * This function pushes a new error record onto the error stack for the current thread. + * + * To delete some error messages: + * \code + * herr_t H5Epop(hid_t error_stack, size_t count) + * \endcode + * This function deletes some error messages from the error stack. + * + * To retrieve the number of error records: + * \code + * int H5Eget_num(hid_t error_stack) + * \endcode + * This function retrieves the number of error records from an error stack. + * + * To clear the error stack: + * \code + * herr_t H5Eclear_stack(hid_t error_stack) + * \endcode + * This function clears the error stack. + * + * To close the object handle for an error stack: + * \code + * herr_t H5Eclose_stack(hid_t error_stack) + * \endcode + * This function closes the object handle for an error stack and releases its resources. + * + * The example below shows how an application pushes an error record onto the default error stack. + * + * Example: Pushing an error message to an error stack + * \code + * *** Make call to HDF5 I/O routine *** + * if((dset_id=H5Dopen(file_id, dset_name, access_plist)) < 0) + * { + * *** Push client error onto error stack *** + * H5Epush(H5E_DEFAULT,__FILE__,FUNC,__LINE__,cls_id, + * CLIENT_ERR_MAJ_IO,CLIENT_ERR_MINOR_OPEN, “H5Dopen failedâ€); + * } + * *** Indicate error occurred in function *** + * return 0; + * \endcode + * + * The example below shows how an application registers the current error stack and + * creates an object handle to avoid another HDF5 function from clearing the error stack. + * + * Example: Registering the error stack + * \code + * if (H5Dwrite(dset_id, mem_type_id, mem_space_id, file_space_id, dset_xfer_plist_id, buf) < 0) + * { + * *** Push client error onto error stack *** + * H5Epush2(H5E_DEFAULT,__FILE__,FUNC,__LINE__,cls_id, + * CLIENT_ERR_MAJ_IO,CLIENT_ERR_MINOR_HDF5, + * “H5Dwrite failedâ€); + * *** Preserve the error stack by assigning an object handle to it *** + * error_stack = H5Eget_current_stack(); + * *** Close dataset *** + * H5Dclose(dset_id); + * *** Replace the current error stack with the preserved one *** + * H5Eset_current_stack(error_stack); + * } + * return 0; + * \endcode + * + * Previous Chapter \ref sec_attribute - Next Chapter \ref sec_plist + * + * \defgroup H5E Error Handling (H5E) + * + * \internal The \c FUNC_ENTER macro clears the error stack whenever an + * interface function is entered. When an error is detected, an entry + * is pushed onto the stack. As the functions unwind, additional + * entries are pushed onto the stack. The API function will return + * some indication that an error occurred and the application can + * print the error stack. + * + * \internal Certain API functions in the \ref H5E package, such as H5Eprint(), + * do not clear the error stack. Otherwise, any function which does + * not have an underscore immediately after the package name will + * clear the error stack. For instance, H5Fopen() clears the error + * stack while \Code{H5F_open} does not. + * + * \internal An error stack has a fixed maximum size. If this size is exceeded + * then the stack will be truncated and only the inner-most functions + * will have entries on the stack. This is expected to be a rare + * condition. + * + * \internal Each thread has its own error stack, but since multi-threading has + * not been added to the library yet, this package maintains a single + * error stack. The error stack is statically allocated to reduce the + * complexity of handling errors within the \ref H5E package. + * + * @see sec_error + * */ #endif /* H5Emodule_H */ diff --git a/src/H5Epkg.h b/src/H5Epkg.h index 30ff084eaeb..c6097e9fff9 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -48,7 +47,7 @@ * each thread individually. The association of stacks to threads will * be handled by the pthread library. * - * In order for this macro to work, H5E__get_my_stack() must be preceeded + * In order for this macro to work, H5E__get_my_stack() must be preceded * by "H5E_t *estack =". */ #define H5E__get_my_stack() H5E__get_stack() @@ -99,7 +98,7 @@ typedef struct H5E_cls_t { /* Major or minor message */ typedef struct H5E_msg_t { - char * msg; /* Message for error */ + char *msg; /* Message for error */ H5E_type_t type; /* Type of error (major or minor) */ H5E_cls_t *cls; /* Which error class this message belongs to */ } H5E_msg_t; @@ -109,7 +108,7 @@ struct H5E_t { size_t nused; /* Num slots currently used in stack */ H5E_error2_t slot[H5E_NSLOTS]; /* Array of error records */ H5E_auto_op_t auto_op; /* Operator for 'automatic' error reporting */ - void * auto_data; /* Callback data for 'automatic error reporting */ + void *auto_data; /* Callback data for 'automatic error reporting */ }; /*****************************/ diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 4cd8b703fd9..e8c24164f74 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -180,53 +179,6 @@ extern int H5E_mpi_error_str_len; } #endif /* H5_HAVE_PARALLEL */ -/******************************************************************************/ -/* Revisions to Error Macros, to go with Revisions to FUNC_ENTER/LEAVE Macros */ -/******************************************************************************/ - -/* - * H5E_PRINTF macro, used to facilitate error reporting between a BEGIN_FUNC() - * and an END_FUNC() within a function body. The arguments are the minor - * error number, a description of the error (as a printf-like format string), - * and an optional set of arguments for the printf format arguments. - */ -#define H5E_PRINTF(...) \ - H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__) - -/* - * H5_LEAVE macro, used to facilitate control flow between a - * BEGIN_FUNC() and an END_FUNC() within a function body. The argument is - * the return value. - * The return value is assigned to a variable `ret_value' and control branches - * to the `catch_except' label, if we're not already past it. - */ -#define H5_LEAVE(v) \ - { \ - ret_value = v; \ - if (!past_catch) \ - goto catch_except; \ - } - -/* - * H5E_THROW macro, used to facilitate error reporting between a - * FUNC_ENTER() and a FUNC_LEAVE() within a function body. The arguments are - * the minor error number, and an error string. - * The return value is assigned to a variable `ret_value' and control branches - * to the `catch_except' label, if we're not already past it. - */ -#define H5E_THROW(...) \ - { \ - H5E_PRINTF(__VA_ARGS__); \ - H5_LEAVE(fail_value) \ - } - -/* Macro for "catching" flow of control when an error occurs. Note that the - * H5_LEAVE macro won't jump back here once it's past this point. - */ -#define CATCH \ -catch_except:; \ - past_catch = TRUE; - /* Library-private functions defined in H5E package */ H5_DLL herr_t H5E_init(void); H5_DLL herr_t H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id, diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 375e92d39b9..e4d4599f9b2 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 2f529b330b9..5f4e325867a 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -24,7 +23,7 @@ #include "H5Ipublic.h" /* Value for the default error stack */ -#define H5E_DEFAULT (hid_t)0 +#define H5E_DEFAULT 0 /* (hid_t) */ /** * Different kinds of error information @@ -38,9 +37,9 @@ typedef struct H5E_error2_t { hid_t cls_id; /**< Class ID */ hid_t maj_num; - /**< Major error ID */ + /**< Major error ID */ hid_t min_num; - /**< Minor error number */ + /**< Minor error number */ unsigned line; /**< Line in file where error occurs */ const char *func_name; @@ -112,7 +111,7 @@ H5_DLLVAR hid_t H5E_ERR_CLS_g; #define H5E_BEGIN_TRY \ { \ H5E_auto2_t saved_efunc; \ - void * H5E_saved_edata; \ + void *H5E_saved_edata; \ \ (void)H5Eget_auto2(H5E_DEFAULT, &saved_efunc, &H5E_saved_edata); \ (void)H5Eset_auto2(H5E_DEFAULT, NULL, NULL); @@ -291,6 +290,26 @@ H5_DLL hid_t H5Ecreate_stack(void); * \since 1.8.0 */ H5_DLL hid_t H5Eget_current_stack(void); +/** + * -------------------------------------------------------------------------- + * \ingroup H5E + * + * \brief Appends one error stack to another, optionally closing the source + * stack. + * + * \estack_id{dst_stack_id} + * \estack_id{src_stack_id} + * \param[in] close_source_stack Flag to indicate whether to close the source stack + * \return \herr_t + * + * \details H5Eappend_stack() appends the messages from error stack + * \p src_stack_id to the error stack \p dst_stack_id. + * If \p close_source_stack is \c TRUE, the source error stack + * will be closed. + * + * \since 1.13.0 + */ +H5_DLL herr_t H5Eappend_stack(hid_t dst_stack_id, hid_t src_stack_id, hbool_t close_source_stack); /** * -------------------------------------------------------------------------- * \ingroup H5E @@ -696,12 +715,13 @@ typedef herr_t (*H5E_auto1_t)(void *client_data); * * \return \herr_t * + * \deprecated 1.8.0 Function H5Eclear() renamed to H5Eclear1() and deprecated + * in this release. + * * \details H5Eclear1() clears the error stack for the current thread.\n * The stack is also cleared whenever an API function is called, with * certain exceptions (for instance, H5Eprint1()). * - * \deprecated 1.8.0 Function H5Eclear() renamed to H5Eclear1() and deprecated - * in this release. */ H5_DLL herr_t H5Eclear1(void); /** @@ -717,6 +737,9 @@ H5_DLL herr_t H5Eclear1(void); * function * \return \herr_t * + * \deprecated 1.8.0 Function H5Eget_auto() renamed to H5Eget_auto1() and + * deprecated in this release. + * * \details H5Eget_auto1() returns the current settings for the automatic error * stack traversal function, \p func, and its data, * \p client_data. Either or both arguments may be \c NULL, in which case the @@ -743,8 +766,6 @@ H5_DLL herr_t H5Eclear1(void); * H5Eprint2(), mixing H5Eset_auto1() and H5Eget_auto2() or mixing * H5Eset_auto2() and H5Eget_auto1() does not fail. * - * \deprecated 1.8.0 Function H5Eget_auto() renamed to H5Eget_auto1() and - * deprecated in this release. */ H5_DLL herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data); /** @@ -761,6 +782,9 @@ H5_DLL herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data); * \param[in] str Error description string * \return \herr_t * + * \deprecated 1.8.0 Function H5Epush() renamed to H5Epush1() and + * deprecated in this release. + * * \details H5Epush1() pushes a new error record onto the error stack for the * current thread.\n * The error has major and minor numbers \p maj_num @@ -771,8 +795,6 @@ H5_DLL herr_t H5Eget_auto1(H5E_auto1_t *func, void **client_data); * allocated. * * \since 1.4.0 - * \deprecated 1.8.0 Function H5Epush() renamed to H5Epush1() and - * deprecated in this release. */ H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, const char *str); @@ -785,6 +807,9 @@ H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, H5E_ma * \param[in] stream File pointer, or \c NULL for \c stderr * \return \herr_t * + * \deprecated 1.8.0 Function H5Eprint() renamed to H5Eprint1() and + * deprecated in this release. + * * \details H5Eprint1() prints prints the error stack for the current thread * on the specified stream, \p stream. Even if the error stack is empty, a * one-line message of the following form will be printed: @@ -795,8 +820,6 @@ H5_DLL herr_t H5Epush1(const char *file, const char *func, unsigned line, H5E_ma * that prints error messages. Users are encouraged to write their own * more specific error handlers. * - * \deprecated 1.8.0 Function H5Eprint() renamed to H5Eprint1() and - * deprecated in this release. */ H5_DLL herr_t H5Eprint1(FILE *stream); /** @@ -809,6 +832,9 @@ H5_DLL herr_t H5Eprint1(FILE *stream); * \param[in] client_data Data passed to the error function * \return \herr_t * + * \deprecated 1.8.0 Function H5Eset_auto() renamed to H5Eset_auto1() and + * deprecated in this release. + * * \details H5Eset_auto1() turns on or off automatic printing of errors. When * turned on (non-null \p func pointer), any API function which returns * an error indication will first call \p func, passing it \p @@ -825,8 +851,6 @@ H5_DLL herr_t H5Eprint1(FILE *stream); * Automatic stack traversal is always in the #H5E_WALK_DOWNWARD * direction. * - * \deprecated 1.8.0 Function H5Eset_auto() renamed to H5Eset_auto1() and - * deprecated in this release. */ H5_DLL herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data); /** @@ -840,6 +864,9 @@ H5_DLL herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data); * \param[in] client_data Data to be passed to \p func * \return \herr_t * + * \deprecated 1.8.0 Function H5Ewalk() renamed to H5Ewalk1() and + * deprecated in this release. + * * \details H5Ewalk1() walks the error stack for the current thread and calls * the function specified in \p func for each error along the way. * @@ -857,8 +884,6 @@ H5_DLL herr_t H5Eset_auto1(H5E_auto1_t func, void *client_data); * is as follows: * \snippet this H5E_walk1_t_snip * - * \deprecated 1.8.0 Function H5Ewalk() renamed to H5Ewalk1() and - * deprecated in this release. */ H5_DLL herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client_data); /** @@ -871,14 +896,15 @@ H5_DLL herr_t H5Ewalk1(H5E_direction_t direction, H5E_walk1_t func, void *client * \param[in] maj Major error number * \return \herr_t * - * \details Given a major error number, H5Eget_major() returns a constant - * character string that describes the error. + * \deprecated 1.8.0 Function deprecated in this release. + * + * \details H5Eget_major() returns a constant + * character string that describes the error, given a major error number. * * \attention This function returns a dynamically allocated string (\c char * array). An application calling this function must free the memory * associated with the return value to prevent a memory leak. * - * \deprecated 1.8.0 Function deprecated in this release. */ H5_DLL char *H5Eget_major(H5E_major_t maj); /** @@ -891,8 +917,10 @@ H5_DLL char *H5Eget_major(H5E_major_t maj); * \param[in] min Minor error number * \return \herr_t * - * \details Given a minor error number, H5Eget_minor() returns a constant - * character string that describes the error. + * \deprecated 1.8.0 Function deprecated and return type changed in this release. + * + * \details H5Eget_minor() returns a constant + * character string that describes the error, given a minor error number. * * \attention In the Release 1.8.x series, H5Eget_minor() returns a string of * dynamic allocated \c char array. An application calling this @@ -900,7 +928,6 @@ H5_DLL char *H5Eget_major(H5E_major_t maj); * the memory associated with the return value to prevent a memory * leak. This is a change from the 1.6.x release series. * - * \deprecated 1.8.0 Function deprecated and return type changed in this release. */ H5_DLL char *H5Eget_minor(H5E_minor_t min); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 4eff528d6ea..1c4806255d4 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5F.c b/src/H5F.c index 3d044c50968..7135db3657f 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -472,10 +471,10 @@ H5Fis_accessible(const char *filename, hid_t fapl_id) hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - void * new_file = NULL; /* File struct for new file */ - H5P_genplist_t * plist; /* Property list pointer */ + void *new_file = NULL; /* File struct for new file */ + H5P_genplist_t *plist; /* Property list pointer */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_object_t * vol_obj = NULL; /* VOL object for file */ + H5VL_object_t *vol_obj = NULL; /* VOL object for file */ hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ hid_t ret_value; /* return value */ @@ -572,10 +571,10 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - void * new_file = NULL; /* File struct for new file */ - H5P_genplist_t * plist; /* Property list pointer */ + void *new_file = NULL; /* File struct for new file */ + H5P_genplist_t *plist; /* Property list pointer */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_object_t * vol_obj = NULL; /* VOL object for file */ + H5VL_object_t *vol_obj = NULL; /* VOL object for file */ hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ hid_t ret_value; /* Return value */ @@ -726,7 +725,7 @@ H5Fclose(hid_t file_id) herr_t H5Fdelete(const char *filename, hid_t fapl_id) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ htri_t is_hdf5 = FAIL; herr_t ret_value = SUCCEED; @@ -788,7 +787,7 @@ H5Fdelete(const char *filename, hid_t fapl_id) hid_t H5Freopen(hid_t file_id) { - void * file = NULL; /* File struct for new file */ + void *file = NULL; /* File struct for new file */ H5VL_object_t *vol_obj = NULL; /* VOL object for file */ hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -1427,7 +1426,7 @@ H5Fclear_elink_file_cache(hid_t file_id) * 1) The file being opened has v3 superblock * 2) The file is opened with H5F_ACC_RDWR * 3) The file is not already marked for SWMR writing - * 4) Current implementaion for opened objects: + * 4) Current implementation for opened objects: * --only allow datasets and groups without attributes * --disallow named datatype with/without attributes * --disallow opened attributes attached to objects diff --git a/src/H5FA.c b/src/H5FA.c index 05b0bd8a1e8..717777d8db4 100644 --- a/src/H5FA.c +++ b/src/H5FA.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -95,7 +94,7 @@ H5FL_BLK_DEFINE(fa_native_elmt); /*------------------------------------------------------------------------- * Function: H5FA__new * - * Purpose: Allocate and initialize a new fixe array wrapper in memory + * Purpose: Allocate and initialize a new fixed array wrapper in memory * * Return: Pointer to farray wrapper success * NULL on failure @@ -105,39 +104,40 @@ H5FL_BLK_DEFINE(fa_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, - H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) +static H5FA_t * +H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata) +{ + H5FA_t *fa = NULL; /* Pointer to new fixed array */ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + H5FA_t *ret_value = NULL; - /* Local variables */ - H5FA_t * fa = NULL; /* Pointer to new fixed array */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + FUNC_ENTER_STATIC - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Allocate fixed array wrapper */ if (NULL == (fa = H5FL_CALLOC(H5FA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array info") /* Lock the array header into memory */ if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, "unable to load fixed array header") /* Check for pending array deletion */ if (from_open && hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open fixed array pending deletion") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTOPENOBJ, NULL, "can't open fixed array pending deletion") /* Point fixed array wrapper at header and bump it's ref count */ fa->hdr = hdr; if (H5FA__hdr_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") /* Increment # of files using this array header */ if (H5FA__hdr_fuse_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, + "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ fa->f = f; @@ -145,15 +145,15 @@ BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, /* Set the return value */ ret_value = fa; - CATCH - +done: if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, "unable to release fixed array header") if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(STATIC) /* end H5FA__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__new() */ /*------------------------------------------------------------------------- * Function: H5FA_create @@ -168,16 +168,16 @@ END_FUNC(STATIC) /* end H5FA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, - H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) - - /* Local variables */ +H5FA_t * +H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata) +{ H5FA_t *fa = NULL; /* Pointer to new fixed array */ haddr_t fa_addr; /* Fixed array header address */ + H5FA_t *ret_value = NULL; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(cparam); @@ -186,22 +186,23 @@ BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, /* Create fixed array header */ if (HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, "can't create fixed array header") /* Allocate and initialize new fixed array wrapper */ if (NULL == (fa = H5FA__new(f, fa_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; - CATCH - +done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_create() */ /*------------------------------------------------------------------------- * Function: H5FA_open @@ -216,31 +217,33 @@ END_FUNC(PRIV) /* end H5FA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +H5FA_t * +H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata) +{ + H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + H5FA_t *ret_value = NULL; - /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + FUNC_ENTER_NOAPI(NULL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Allocate and initialize new fixed array wrapper */ if (NULL == (fa = H5FA__new(f, fa_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; - CATCH - +done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_open() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_open() */ /*------------------------------------------------------------------------- * Function: H5FA_get_nelmts @@ -254,20 +257,20 @@ END_FUNC(PRIV) /* end H5FA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) - - /* Local variables */ +herr_t +H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(nelmts); /* Retrieve the current number of elements in the fixed array */ *nelmts = fa->hdr->stats.nelmts; -END_FUNC(PRIV) /* end H5FA_get_nelmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_nelmts() */ /*------------------------------------------------------------------------- * Function: H5FA_get_addr @@ -281,13 +284,12 @@ END_FUNC(PRIV) /* end H5FA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) - - /* Local variables */ +herr_t +H5FA_get_addr(const H5FA_t *fa, haddr_t *addr) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); HDassert(addr); @@ -295,7 +297,8 @@ BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, hadd /* Retrieve the address of the fixed array's header */ *addr = fa->hdr->addr; -END_FUNC(PRIV) /* end H5FA_get_addr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_addr() */ /*------------------------------------------------------------------------- * Function: H5FA_set @@ -309,20 +312,21 @@ END_FUNC(PRIV) /* end H5FA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt)) - - /* Local variables */ - H5FA_hdr_t * hdr = fa->hdr; /* Header for fixed array */ - H5FA_dblock_t * dblock = NULL; /* Pointer to fixed array Data block */ +herr_t +H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt) +{ + H5FA_hdr_t *hdr = fa->hdr; /* Header for fixed array */ + H5FA_dblock_t *dblock = NULL; /* Pointer to fixed array Data block */ H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to fixed array Data block page */ unsigned dblock_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting fixed array Data block */ unsigned dblk_page_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting FIxed Array Data block page */ hbool_t hdr_dirty = FALSE; /* Whether header information changed */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); @@ -334,15 +338,16 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t /* Create the data block */ hdr->dblk_addr = H5FA__dblock_create(hdr, &hdr_dirty); if (!H5F_addr_defined(hdr->dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create fixed array data block") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, "unable to create fixed array data block") + } HDassert(idx < hdr->cparam.nelmts); /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)hdr->dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paging data block */ if (!dblock->npages) { @@ -375,7 +380,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Create the data block page */ if (H5FA__dblk_page_create(hdr, dblk_page_addr, dblk_page_nelmts) < 0) - H5E_THROW(H5E_CANTCREATE, "unable to create data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, "unable to create data block page") /* Mark data block page as initialized in data block */ H5VM_bit_set(dblock->dblk_page_init, page_idx, TRUE); @@ -385,8 +390,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t /* Protect the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Set the element in the data block page */ H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, @@ -394,19 +400,20 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t dblk_page_cache_flags |= H5AC__DIRTIED_FLAG; } /* end else */ - CATCH +done: /* Check for header modified */ if (hdr_dirty) if (H5FA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as modified") + HDONE_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as modified") /* Release resources */ if (dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, dblk_page_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_set() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_set() */ /*------------------------------------------------------------------------- * Function: H5FA_get @@ -420,16 +427,17 @@ END_FUNC(PRIV) /* end H5FA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt)) - - /* Local variables */ - H5FA_hdr_t * hdr = fa->hdr; /* Header for FA */ - H5FA_dblock_t * dblock = NULL; /* Pointer to data block for FA */ +herr_t +H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt) +{ + H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + H5FA_dblock_t *dblock = NULL; /* Pointer to data block for FA */ H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for FA */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); @@ -440,14 +448,15 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t if (!H5F_addr_defined(hdr->dblk_addr)) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else { /* Get the data block */ HDassert(H5F_addr_defined(hdr->dblk_addr)); if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)hdr->dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paged data block */ if (!dblock->npages) @@ -464,10 +473,10 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") /* We've retrieved the value, leave now */ - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ else { /* get the page */ size_t dblk_page_nelmts; /* # of elements in a data block page */ @@ -490,9 +499,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t /* Protect the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Retrieve element from data block */ H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), @@ -501,13 +510,14 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t } /* end else */ } /* end else */ - CATCH +done: if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_get() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_get() */ /*------------------------------------------------------------------------- * Function: H5FA_close @@ -521,18 +531,19 @@ END_FUNC(PRIV) /* end H5FA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) - - /* Local variables */ +herr_t +H5FA_close(H5FA_t *fa) +{ hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ haddr_t fa_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); - /* Close the header, if it was set */ + /* Close the header if it was set */ if (fa->hdr) { /* Decrement file reference & check if this is the last open fixed array using the shared array header */ @@ -562,7 +573,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Check the header's status in the metadata cache */ if (H5AC_get_entry_status(fa->f, fa_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, + "unable to check metadata cache status for fixed array header") /* Sanity checks on header */ HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -574,7 +586,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ if (NULL == (hdr = H5FA__hdr_protect(fa->f, fa_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTLOAD, FAIL, "unable to load fixed array header") /* Set the shared array header's file context for this operation */ hdr->f = fa->f; @@ -584,11 +596,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) * immediately -QAK) */ if (H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ if (H5FA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array") } /* end if */ else { /* Decrement the reference count on the array header */ @@ -596,16 +609,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) * immediately -QAK) */ if (H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") } /* end else */ } /* end if */ /* Release the fixed array wrapper */ fa = H5FL_FREE(H5FA_t, fa); - CATCH - -END_FUNC(PRIV) /* end H5FA_close() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_close() */ /*------------------------------------------------------------------------- * Function: H5FA_delete @@ -619,21 +633,22 @@ END_FUNC(PRIV) /* end H5FA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +herr_t +H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata) +{ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Lock the array header into memory */ if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", - (unsigned long long)fa_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) /* Check for files using shared array header */ if (hdr->file_rc) @@ -644,17 +659,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_ad /* Delete array now, starting with header (unprotects header) */ if (H5FA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array") hdr = NULL; - } /* end if */ - - CATCH + } - /* Unprotect the header, if an error occurred */ +done: + /* Unprotect the header if an error occurred */ if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PRIV) /* end H5FA_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_delete() */ /*------------------------------------------------------------------------- * Function: H5FA_iterate @@ -671,44 +686,44 @@ END_FUNC(PRIV) /* end H5FA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, - H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) - - /* Local variables */ +int +H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata) +{ uint8_t *elmt = NULL; hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + int ret_value = H5_ITER_CONT; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(H5_ITER_ERROR) + + /* Check arguments */ HDassert(fa); HDassert(op); HDassert(udata); /* Allocate space for a native array element */ if (NULL == (elmt = H5FL_BLK_MALLOC(fa_native_elmt, fa->hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, H5_ITER_ERROR, + "memory allocation failed for fixed array element") /* Iterate over all elements in array */ - for (u = 0; u < fa->hdr->stats.nelmts && cb_ret == H5_ITER_CONT; u++) { + for (u = 0; u < fa->hdr->stats.nelmts && ret_value == H5_ITER_CONT; u++) { /* Get array element */ if (H5FA_get(fa, u, elmt) < 0) - H5E_THROW(H5E_CANTGET, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, H5_ITER_ERROR, "unable to delete fixed array") - /* Make callback */ - if ((cb_ret = (*op)(u, elmt, udata)) < 0) { - H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) - } /* end if */ - } /* end for */ - - CATCH + /* Invoke callback */ + if ((ret_value = (*op)(u, elmt, udata)) < 0) { + HERROR(H5E_FARRAY, H5E_BADITER, "iteration callback error"); + break; + } + } +done: if (elmt) elmt = H5FL_BLK_FREE(fa_native_elmt, elmt); -END_FUNC(PRIV) /* end H5FA_iterate() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_iterate() */ /*------------------------------------------------------------------------- * Function: H5FA_depend @@ -723,14 +738,15 @@ END_FUNC(PRIV) /* end H5FA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) +herr_t +H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent) +{ + H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(hdr); HDassert(parent); @@ -749,13 +765,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_ /* Add the fixed array as a child of the parent (proxy) */ if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array as child of proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "unable to add fixed array as child of proxy") hdr->parent = parent; - } /* end if */ - - CATCH + } -END_FUNC(PRIV) /* end H5FA_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_depend() */ /*------------------------------------------------------------------------- * Function: H5FA_patch_file @@ -769,17 +785,17 @@ END_FUNC(PRIV) /* end H5FA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_patch_file(H5FA_t *fa, H5F_t *f)) +herr_t +H5FA_patch_file(H5FA_t *fa, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOERR - /* Local variables */ - - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(f); if (fa->f != f || fa->hdr->f != f) fa->f = fa->hdr->f = f; -END_FUNC(PRIV) /* end H5FA_patch_file() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_patch_file() */ diff --git a/src/H5FAcache.c b/src/H5FAcache.c index 1b127c73a07..9b6481b5bf3 100644 --- a/src/H5FAcache.c +++ b/src/H5FAcache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -66,7 +65,7 @@ /* Metadata cache (H5AC) callbacks */ static herr_t H5FA__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FA__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5FA__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5FA__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FA__cache_hdr_image_len(const void *thing, size_t *image_len); static herr_t H5FA__cache_hdr_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *thing); @@ -74,7 +73,7 @@ static herr_t H5FA__cache_hdr_free_icr(void *thing); static herr_t H5FA__cache_dblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FA__cache_dblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5FA__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5FA__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FA__cache_dblock_image_len(const void *thing, size_t *image_len); static herr_t H5FA__cache_dblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *thing); @@ -83,7 +82,7 @@ static herr_t H5FA__cache_dblock_fsf_size(const void *thing, hsize_t *fsf_size); static herr_t H5FA__cache_dblk_page_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FA__cache_dblk_page_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5FA__cache_dblk_page_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5FA__cache_dblk_page_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FA__cache_dblk_page_image_len(const void *thing, size_t *image_len); static herr_t H5FA__cache_dblk_page_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *thing); @@ -167,12 +166,13 @@ const H5AC_class_t H5AC_FARRAY_DBLK_PAGE[1] = {{ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; /* User data for callback */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->f); @@ -181,7 +181,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5FA_HEADER_SIZE_FILE(udata->f); -END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_verify_chksum @@ -196,13 +197,15 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -213,7 +216,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_deserialize @@ -228,16 +232,18 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ +static void * +H5FA__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ H5FA_cls_id_t id; /* ID of fixed array class, as found in file */ - H5FA_hdr_t * hdr = NULL; /* Fixed array info */ + H5FA_hdr_t *hdr = NULL; /* Fixed array info */ H5FA_hdr_cache_ud_t *udata = (H5FA_hdr_cache_ud_t *)_udata; - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(udata); @@ -246,24 +252,24 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate space for the fixed array data structure */ if (NULL == (hdr = H5FA__hdr_alloc(udata->f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array shared header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array shared header") /* Set the fixed array header's address */ hdr->addr = udata->addr; /* Magic number */ if (HDmemcmp(image, H5FA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong fixed array header signature") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array header signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5FA_HDR_VERSION) - H5E_THROW(H5E_VERSION, "wrong fixed array header version") + HGOTO_ERROR(H5E_FARRAY, H5E_VERSION, NULL, "wrong fixed array header version") /* Fixed array class */ id = (H5FA_cls_id_t)*image++; if (id >= H5FA_NUM_CLS_ID) - H5E_THROW(H5E_BADTYPE, "incorrect fixed array class") + HGOTO_ERROR(H5E_FARRAY, H5E_BADTYPE, NULL, "incorrect fixed array class") hdr->cparam.cls = H5FA_client_class_g[id]; /* General array creation/configuration information */ @@ -311,20 +317,20 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Finish initializing fixed array header */ if (H5FA__hdr_init(hdr, udata->ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, "initialization failed for fixed array header") HDassert(hdr->size == len); /* Set return value */ ret_value = hdr; - CATCH - +done: /* Release resources */ if (!ret_value) if (hdr && H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header") -END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_image_len @@ -338,12 +344,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_image_len(const void *_thing, size_t *image_len) +{ const H5FA_hdr_t *hdr = (const H5FA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(hdr); HDassert(image_len); @@ -351,7 +358,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = hdr->size; -END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_serialize @@ -365,15 +373,16 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the fixed array header */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ - /* check arguments */ + FUNC_ENTER_STATIC_NOERR + + /* Check arguments */ HDassert(f); HDassert(image); HDassert(hdr); @@ -410,7 +419,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); -END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_hdr_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_notify @@ -424,11 +434,13 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5FA__cache_hdr_notify(H5AC_notify_action_t action, void *_thing) +{ + H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = (H5FA_hdr_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Sanity check */ HDassert(hdr); @@ -460,16 +472,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Destroy flush dependency on object header proxy */ if (H5AC_proxy_entry_remove_child((H5AC_proxy_entry_t *)hdr->parent, (void *)hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTUNDEPEND, - "unable to destroy flush dependency between fixed array and proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between fixed array and proxy") hdr->parent = NULL; } /* end if */ /* Detach from 'top' proxy for fixed array */ if (hdr->top_proxy) { if (H5AC_proxy_entry_remove_child(hdr->top_proxy, hdr) < 0) - H5E_THROW( - H5E_CANTUNDEPEND, + HGOTO_ERROR( + H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency between header and fixed array 'top' proxy") /* Don't reset hdr->top_proxy here, it's destroyed when the header is freed -QAK */ } /* end if */ @@ -477,7 +489,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ @@ -486,9 +498,10 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, else HDassert(NULL == hdr->parent); - CATCH +done: -END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_hdr_free_icr @@ -503,18 +516,23 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_hdr_free_icr(void *thing)) +static herr_t +H5FA__cache_hdr_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the extensible array header */ if (H5FA__hdr_dest((H5FA_hdr_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array header") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array header") -END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_hdr_free_icr() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_get_initial_load_size @@ -528,14 +546,15 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data */ H5FA_dblock_t dblock; /* Fake data block for computing size */ size_t dblk_page_nelmts; /* # of elements per data block page */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -564,7 +583,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = (size_t)H5FA_DBLOCK_PREFIX_SIZE(&dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_verify_chksum @@ -579,13 +599,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_dblock_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -596,7 +618,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_deserialize @@ -611,16 +634,18 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ - H5FA_dblock_t * dblock = NULL; /* Data block info */ +static void * +H5FA__cache_dblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, + hbool_t H5_ATTR_UNUSED *dirty) +{ + H5FA_dblock_t *dblock = NULL; /* Data block info */ H5FA_dblock_cache_ud_t *udata = (H5FA_dblock_cache_ud_t *)_udata; /* User data for loading data block */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ haddr_t arr_addr; /* Address of array header in the file */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(udata); @@ -628,7 +653,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the fixed array data block */ if (NULL == (dblock = H5FA__dblock_alloc(udata->hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array data block") HDassert(((!dblock->npages) && (len == (size_t)H5FA_DBLOCK_SIZE(dblock))) || (len == (size_t)H5FA_DBLOCK_PREFIX_SIZE(dblock))); @@ -638,27 +663,27 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Magic number */ if (HDmemcmp(image, H5FA_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - H5E_THROW(H5E_BADVALUE, "wrong fixed array data block signature") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array data block signature") image += H5_SIZEOF_MAGIC; /* Version */ if (*image++ != H5FA_DBLOCK_VERSION) - H5E_THROW(H5E_VERSION, "wrong fixed array data block version") + HGOTO_ERROR(H5E_FARRAY, H5E_VERSION, NULL, "wrong fixed array data block version") /* Fixed array type */ if (*image++ != (uint8_t)udata->hdr->cparam.cls->id) - H5E_THROW(H5E_BADTYPE, "incorrect fixed array class") + HGOTO_ERROR(H5E_FARRAY, H5E_BADTYPE, NULL, "incorrect fixed array class") /* Address of header for array that owns this block (just for file integrity checks) */ H5F_addr_decode(udata->hdr->f, &image, &arr_addr); if (H5F_addr_ne(arr_addr, udata->hdr->addr)) - H5E_THROW(H5E_BADVALUE, "wrong fixed array header address") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, NULL, "wrong fixed array header address") /* Page initialization flags */ if (dblock->npages > 0) { H5MM_memcpy(dblock->dblk_page_init, image, dblock->dblk_page_init_size); image += dblock->dblk_page_init_size; - } /* end if */ + } /* Only decode elements if the data block is not paged */ if (!dblock->npages) { @@ -666,9 +691,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblock->elmts, (size_t)udata->hdr->cparam.nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDECODE, NULL, "can't decode fixed array data elements") image += (udata->hdr->cparam.nelmts * udata->hdr->cparam.raw_elmt_size); - } /* end if */ + } /* Sanity check */ /* (allow for checksum not decoded yet) */ @@ -688,14 +713,14 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblock; - CATCH - +done: /* Release resources */ if (!ret_value) if (dblock && H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block") -END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_image_len @@ -709,12 +734,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_image_len(const void *_thing, size_t *image_len) +{ const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(image_len); @@ -725,7 +751,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, else *image_len = H5FA_DBLOCK_PREFIX_SIZE(dblock); -END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_serialize @@ -739,14 +766,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, - void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) +{ H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object to serialize */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(f); @@ -773,7 +801,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Store the 'page init' bitmasks */ H5MM_memcpy(image, dblock->dblk_page_init, dblock->dblk_page_init_size); image += dblock->dblk_page_init_size; - } /* end if */ + } /* Only encode elements if the data block is not paged */ if (!dblock->npages) { @@ -783,9 +811,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5_CHECK_OVERFLOW(dblock->hdr->cparam.nelmts, /* From: */ hsize_t, /* To: */ size_t); if ((dblock->hdr->cparam.cls->encode)(image, dblock->elmts, (size_t)dblock->hdr->cparam.nelmts, dblock->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTENCODE, FAIL, "can't encode fixed array data elements") image += (dblock->hdr->cparam.nelmts * dblock->hdr->cparam.raw_elmt_size); - } /* end if */ + } /* Compute metadata checksum */ metadata_chksum = H5_checksum_metadata(_image, (size_t)(image - (uint8_t *)_image), 0); @@ -796,9 +824,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_notify @@ -812,11 +840,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing)) +static herr_t +H5FA__cache_dblock_notify(H5AC_notify_action_t action, void *_thing) +{ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblock); @@ -829,8 +859,8 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_AFTER_LOAD: /* Create flush dependency on parent */ if (H5FA__create_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW( - H5E_CANTDEPEND, + HGOTO_ERROR( + H5E_FARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency between data block and header, address = %llu", (unsigned long long)dblock->addr) break; @@ -842,35 +872,35 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, case H5AC_NOTIFY_ACTION_CHILD_CLEANED: case H5AC_NOTIFY_ACTION_CHILD_UNSERIALIZED: case H5AC_NOTIFY_ACTION_CHILD_SERIALIZED: - /* do nothing */ break; case H5AC_NOTIFY_ACTION_BEFORE_EVICT: /* Destroy flush dependency on parent */ if (H5FA__destroy_flush_depend((H5AC_info_t *)dblock->hdr, (H5AC_info_t *)dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") /* Detach from 'top' proxy for fixed array */ if (dblock->top_proxy) { if (H5AC_proxy_entry_remove_child(dblock->top_proxy, dblock) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block " - "and fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block " + "and fixed array 'top' proxy") dblock->top_proxy = NULL; - } /* end if */ + } break; default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") -#else /* NDEBUG */ + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") +#else HDassert(0 && "Unknown action?!?"); -#endif /* NDEBUG */ +#endif } /* end switch */ } /* end if */ - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_free_icr @@ -885,20 +915,24 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblock_free_icr(void *_thing)) +static herr_t +H5FA__cache_dblock_free_icr(void *_thing) +{ + H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; - H5FA_dblock_t *dblock = (H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC /* Check arguments */ HDassert(dblock); /* Release the fixed array data block */ if (H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array data block") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array data block") -END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblock_free_icr() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblock_fsf_size @@ -908,7 +942,7 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ * file space block set. * * This function is needed when the data block is paged, as - * the datablock header and all its pages are allocted as a + * the datablock header and all its pages are allocated as a * single contiguous chunk of file space, and must be * deallocated the same way. * @@ -929,11 +963,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_free_icr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size)) - +static herr_t +H5FA__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) +{ const H5FA_dblock_t *dblock = (const H5FA_dblock_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblock); HDassert(dblock->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -942,7 +978,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, *fsf_size = dblock->size; -END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblock_fsf_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_get_initial_load_size @@ -956,12 +993,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_fsf_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_get_initial_load_size(void *_udata, size_t *image_len) +{ H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(udata); HDassert(udata->hdr); @@ -971,7 +1009,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = (size_t)H5FA_DBLK_PAGE_SIZE(udata->hdr, udata->nelmts); -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblk_page_get_initial_load_size() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_verify_chksum @@ -986,13 +1025,15 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_get_initial_load_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, - H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata)) - - /* Local variables */ +static htri_t +H5FA__cache_dblk_page_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSED *_udata) +{ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ + htri_t ret_value = TRUE; + + FUNC_ENTER_STATIC_NOERR /* Check arguments */ HDassert(image); @@ -1003,7 +1044,8 @@ BEGIN_FUNC(STATIC, NOERR, htri_t, TRUE, -, if (stored_chksum != computed_chksum) ret_value = FALSE; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_verify_chksum() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_deserialize @@ -1018,18 +1060,19 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_verify_chksum() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty)) - - /* Local variables */ - H5FA_dblk_page_t * dblk_page = NULL; /* Data block page info */ +static void * +H5FA__cache_dblk_page_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) +{ + H5FA_dblk_page_t *dblk_page = NULL; /* Data block page info */ H5FA_dblk_page_cache_ud_t *udata = (H5FA_dblk_page_cache_ud_t *)_udata; /* User data for loading data block page */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ + void *ret_value = NULL; /* Sanity check */ + FUNC_ENTER_STATIC + HDassert(udata); HDassert(udata->hdr); HDassert(udata->nelmts > 0); @@ -1037,7 +1080,8 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Allocate the fixed array data block page */ if (NULL == (dblk_page = H5FA__dblk_page_alloc(udata->hdr, udata->nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for fixed array data block page") /* Set the fixed array data block's information */ dblk_page->addr = udata->dblk_page_addr; @@ -1047,7 +1091,7 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Decode elements in data block page */ /* Convert from raw elements on disk into native elements in memory */ if ((udata->hdr->cparam.cls->decode)(image, dblk_page->elmts, udata->nelmts, udata->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTDECODE, "can't decode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDECODE, NULL, "can't decode fixed array data elements") image += (udata->nelmts * udata->hdr->cparam.raw_elmt_size); /* Sanity check */ @@ -1068,14 +1112,15 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Release resources */ if (!ret_value) if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page") -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_deserialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_image_len @@ -1089,12 +1134,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_deserialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_image_len(const void *_thing, size_t *image_len) +{ const H5FA_dblk_page_t *dblk_page = (const H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + FUNC_ENTER_STATIC_NOERR + /* Check arguments */ HDassert(dblk_page); HDassert(image_len); @@ -1102,7 +1148,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, /* Set the image length size */ *image_len = dblk_page->size; -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__cache_dblk_page_image_len() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_serialize @@ -1116,14 +1163,16 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_image_len() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, - size_t H5_ATTR_UNUSED len, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *_image, size_t H5_ATTR_UNUSED len, + void *_thing) +{ H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object to serialize */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(f); @@ -1138,7 +1187,7 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Convert from native elements in memory into raw elements on disk */ if ((dblk_page->hdr->cparam.cls->encode)(image, dblk_page->elmts, dblk_page->nelmts, dblk_page->hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTENCODE, "can't encode fixed array data elements") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTENCODE, FAIL, "can't encode fixed array data elements") image += (dblk_page->nelmts * dblk_page->hdr->cparam.raw_elmt_size); /* Compute metadata checksum */ @@ -1150,9 +1199,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) == len); - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_serialize() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_notify @@ -1166,11 +1215,13 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_serialize() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, - H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing)) - - /* Local variables */ +static herr_t +H5FA__cache_dblk_page_notify(H5AC_notify_action_t action, void *_thing) +{ H5FA_dblk_page_t *dblk_page = (H5FA_dblk_page_t *)_thing; /* Pointer to the object */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Sanity check */ HDassert(dblk_page); @@ -1187,8 +1238,9 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, /* Detach from 'top' proxy for fixed array */ if (dblk_page->top_proxy) { if (H5AC_proxy_entry_remove_child(dblk_page->top_proxy, dblk_page) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency between data block page " - "and fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, + "unable to destroy flush dependency between data block page " + "and fixed array 'top' proxy") dblk_page->top_proxy = NULL; } /* end if */ break; @@ -1204,15 +1256,15 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, default: #ifdef NDEBUG - H5E_THROW(H5E_BADVALUE, "unknown action from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, FAIL, "unknown action from metadata cache") #else /* NDEBUG */ HDassert(0 && "Unknown action?!?"); #endif /* NDEBUG */ } /* end switch */ - CATCH - -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_notify() */ /*------------------------------------------------------------------------- * Function: H5FA__cache_dblk_page_free_icr @@ -1227,15 +1279,20 @@ END_FUNC(STATIC) /* end H5FA__cache_dblk_page_notify() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5FA__cache_dblk_page_free_icr(void *thing)) +static herr_t +H5FA__cache_dblk_page_free_icr(void *thing) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC /* Check arguments */ HDassert(thing); /* Release the fixed array data block page */ if (H5FA__dblk_page_dest((H5FA_dblk_page_t *)thing) < 0) - H5E_THROW(H5E_CANTFREE, "can't free fixed array data block page") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "can't free fixed array data block page") -END_FUNC(STATIC) /* end H5FA__cache_dblk_page_free_icr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__cache_dblk_page_free_icr() */ diff --git a/src/H5FAdbg.c b/src/H5FAdbg.c index 8c2c9a8b1e2..2ec14631098 100644 --- a/src/H5FAdbg.c +++ b/src/H5FAdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -79,13 +78,16 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5FA_class_t *cls, haddr_t obj_addr)) - +herr_t +H5FA__hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5FA_class_t *cls, + haddr_t obj_addr) +{ /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */ - void * dbg_ctx = NULL; /* Fixed array debugging context */ + H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */ + void *dbg_ctx = NULL; /* Fixed array debugging context */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -100,11 +102,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the fixed array header */ if (NULL == (hdr = H5FA__hdr_protect(f, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to load fixed array header") /* Print opening message */ HDfprintf(stream, "%*sFixed Array Header...\n", indent, ""); @@ -126,13 +128,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, "Fixed Array Data Block Address:", hdr->dblk_addr); - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") + HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context") if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_debug() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_debug @@ -146,15 +149,18 @@ END_FUNC(PKG) /* end H5FA__hdr_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, - const H5FA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr)) - +herr_t +H5FA__dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, const H5FA_class_t *cls, + haddr_t hdr_addr, haddr_t obj_addr) +{ /* Local variables */ - H5FA_hdr_t * hdr = NULL; /* Shared fixed array header */ - H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ - void * dbg_ctx = NULL; /* Fixed array context */ - size_t u; /* Local index variable */ + H5FA_hdr_t *hdr = NULL; /* Shared fixed array header */ + H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ + void *dbg_ctx = NULL; /* Fixed array context */ + size_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -170,16 +176,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (cls->crt_dbg_ctx) /* Create debugging context */ if (NULL == (dbg_ctx = cls->crt_dbg_ctx(f, obj_addr))) - H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to create fixed array debugging context") /* Load the fixed array header */ if (NULL == (hdr = H5FA__hdr_protect(f, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to load fixed array header") /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)addr) /* Print opening message */ HDfprintf(stream, "%*sFixed Array data Block...\n", indent, ""); @@ -222,9 +228,9 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) HDfprintf(stream, "%*sElements in page %zu:\n", indent, "", page_idx); for (u = 0; u < dblk_page_nelmts; u++) { @@ -232,10 +238,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ if (H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to release fixed array data block page") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; @@ -250,16 +257,17 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, if ((hdr->cparam.cls->debug)(stream, (indent + 3), MAX(0, (fwidth - 3)), (hsize_t)u, ((uint8_t *)dblock->elmts) + (hdr->cparam.cls->nat_elmt_size * u)) < 0) - H5E_THROW(H5E_CANTGET, "can't get element for debugging") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "can't get element for debugging") } /* end for */ } /* end else */ - CATCH +done: if (dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to release fixed array debugging context") + HDONE_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to release fixed array debugging context") if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__dblock_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_debug() */ diff --git a/src/H5FAdblkpage.c b/src/H5FAdblkpage.c index 0f5ee292d01..d0bf4282914 100644 --- a/src/H5FAdblkpage.c +++ b/src/H5FAdblkpage.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -84,21 +83,25 @@ H5FL_BLK_DEFINE(page_elmts); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts)) - - /* Local variables */ +H5FA_dblk_page_t * +H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts) +{ H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ + H5FA_dblk_page_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); /* Allocate memory for the data block */ if (NULL == (dblk_page = H5FL_CALLOC(H5FA_dblk_page_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for fixed array data block page") /* Share common array information */ if (H5FA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblk_page->hdr = hdr; /* Set non-zero internal fields */ @@ -106,40 +109,44 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, H5FA__dblk_page_alloc(H5FA_ /* Allocate buffer for elements in data block page */ if (NULL == (dblk_page->elmts = H5FL_BLK_MALLOC(page_elmts, nelmts * hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block page element buffer") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block page element buffer") /* Set the return value */ ret_value = dblk_page; - CATCH +done: if (!ret_value) if (dblk_page && H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block page") -END_FUNC(PKG) /* end H5FA__dblk_page_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_create * * Purpose: Creates a new fixed array data block page in the file * - * Return: Valid file address on success/HADDR_UNDEF on failure + * Return: SUCCEED/FAIL * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts)) - - /* Local variables */ +herr_t +H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts) +{ H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG - HDfprintf(stderr, "%s: Called, addr = %a\n", FUNC, addr); + HDfprintf(stderr, "%s: Called, addr = %" PRIuHADDR "\n", FUNC, addr); #endif /* H5FA_DEBUG */ /* Sanity check */ @@ -147,7 +154,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Allocate the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_alloc(hdr, nelmts))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, FAIL, + "memory allocation failed for fixed array data block page") /* Set info about data block page on disk */ dblk_page->addr = addr; @@ -158,34 +166,38 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Clear any elements in data block page to fill value */ if ((hdr->cparam.cls->fill)(dblk_page->elmts, nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set fixed array data block page elements to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, + "can't set fixed array data block page elements to class's fill value") /* Cache the new fixed array data block page */ if (H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block page to cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, FAIL, "can't add fixed array data block page to cache") inserted = TRUE; /* Add data block page as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, + "unable to add fixed array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ - CATCH +done: if (ret_value < 0) if (dblk_page) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblk_page) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block page from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, FAIL, + "unable to remove fixed array data block page from cache") /* Destroy data block page */ if (H5FA__dblk_page_dest(dblk_page) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, FAIL, "unable to destroy fixed array data block page") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_create() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_protect @@ -200,13 +212,14 @@ END_FUNC(PKG) /* end H5FA__dblk_page_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, - H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, - unsigned flags)) - - /* Local variables */ - H5FA_dblk_page_t * dblk_page = NULL; /* Fixed array data block page */ +H5FA_dblk_page_t * +H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, unsigned flags) +{ + H5FA_dblk_page_t *dblk_page = NULL; /* Fixed array data block page */ H5FA_dblk_page_cache_ud_t udata; /* Information needed for loading data block page */ + H5FA_dblk_page_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); @@ -227,32 +240,36 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblk_page_t *, NULL, NULL, /* Protect the data block page */ if (NULL == (dblk_page = (H5FA_dblk_page_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblk_page->top_proxy) { /* Add data block page as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblk_page) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") dblk_page->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblk_page; - CATCH +done: /* Clean up on error */ if (!ret_value) { /* Release the data block page, if it was protected */ if (dblk_page && H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", - (unsigned long long)dblk_page->addr) + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect fixed array data block page, address = %llu", + (unsigned long long)dblk_page->addr) } /* end if */ -END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_unprotect @@ -267,10 +284,12 @@ END_FUNC(PKG) /* end H5FA__dblk_page_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags)) +herr_t +H5FA__dblk_page_unprotect(H5FA_dblk_page_t *dblk_page, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; -/* Local variables */ + FUNC_ENTER_PACKAGE #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); @@ -281,12 +300,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Unprotect the data block page */ if (H5AC_unprotect(dblk_page->hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page->addr, dblk_page, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block page, address = %llu", - (unsigned long long)dblk_page->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array data block page, address = %llu", + (unsigned long long)dblk_page->addr) -END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblk_page_dest @@ -300,7 +320,12 @@ END_FUNC(PKG) /* end H5FA__dblk_page_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page)) +herr_t +H5FA__dblk_page_dest(H5FA_dblk_page_t *dblk_page) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblk_page); @@ -315,7 +340,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_ /* Decrement reference count on shared info */ if (H5FA__hdr_decr(dblk_page->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblk_page->hdr = NULL; } /* end if */ @@ -325,6 +351,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblk_page_dest(H5FA_dblk_page_ /* Free the data block page itself */ dblk_page = H5FL_FREE(H5FA_dblk_page_t, dblk_page); - CATCH - -END_FUNC(PKG) /* end H5FA__dblk_page_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblk_page_dest() */ diff --git a/src/H5FAdblock.c b/src/H5FAdblock.c index 21e2e03166e..8fe026fb631 100644 --- a/src/H5FAdblock.c +++ b/src/H5FAdblock.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -88,10 +87,13 @@ H5FL_BLK_DEFINE(fa_page_init); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t *hdr)) +H5FA_dblock_t * +H5FA__dblock_alloc(H5FA_hdr_t *hdr) +{ + H5FA_dblock_t *dblock = NULL; /* fixed array data block */ + H5FA_dblock_t *ret_value = NULL; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* fixed array data block */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -99,11 +101,11 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* Allocate memory for the data block */ if (NULL == (dblock = H5FL_CALLOC(H5FA_dblock_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array data block") /* Share common array information */ if (H5FA__hdr_incr(hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") dblock->hdr = hdr; /* Set non-zero internal fields */ @@ -126,7 +128,7 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* Allocate space for 'page init' flags */ if (NULL == (dblock->dblk_page_init = H5FL_BLK_CALLOC(fa_page_init, dblock->dblk_page_init_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for page init bitmask") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for page init bitmask") /* Compute data block page size */ dblock->dblk_page_size = (dblock->dblk_page_nelmts * hdr->cparam.raw_elmt_size) + H5FA_SIZEOF_CHKSUM; @@ -143,19 +145,20 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, H5FA__dblock_alloc(H5FA_hdr_t /* Allocate buffer for elements in data block */ H5_CHECK_OVERFLOW(dblk_size, /* From: */ hsize_t, /* To: */ size_t); if (NULL == (dblock->elmts = H5FL_BLK_MALLOC(chunk_elmts, (size_t)dblk_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for data block element buffer") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, + "memory allocation failed for data block element buffer") } /* end else */ /* Set the return value */ ret_value = dblock; - CATCH - +done: if (!ret_value) if (dblock && H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_alloc() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_create @@ -169,13 +172,15 @@ END_FUNC(PKG) /* end H5FA__dblock_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty)) +haddr_t +H5FA__dblock_create(H5FA_hdr_t *hdr, hbool_t *hdr_dirty) +{ + H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ + haddr_t dblock_addr; /* Fixed array data block address */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ - haddr_t dblock_addr; /* Fixed array data block address */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -183,31 +188,35 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Allocate the data block */ if (NULL == (dblock = H5FA__dblock_alloc(hdr))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for fixed array data block") /* Set size of data block on disk */ hdr->stats.dblk_size = dblock->size = H5FA_DBLOCK_SIZE(dblock); /* Allocate space for the data block on disk */ if (HADDR_UNDEF == (dblock_addr = H5MF_alloc(hdr->f, H5FD_MEM_FARRAY_DBLOCK, (hsize_t)dblock->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for fixed array data block") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "file allocation failed for fixed array data block") dblock->addr = dblock_addr; /* Don't initialize elements if paged */ if (!dblock->npages) /* Clear any elements in data block to fill value */ if ((hdr->cparam.cls->fill)(dblock->elmts, (size_t)hdr->cparam.nelmts) < 0) - H5E_THROW(H5E_CANTSET, "can't set fixed array data block elements to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "can't set fixed array data block elements to class's fill value") /* Cache the new fixed array data block */ if (H5AC_insert_entry(hdr->f, H5AC_FARRAY_DBLOCK, dblock_addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add fixed array data block to cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add fixed array data block to cache") inserted = TRUE; /* Add data block as child of 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add fixed array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ @@ -217,26 +226,28 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Set address of data block to return */ ret_value = dblock_addr; - CATCH +done: if (!H5F_addr_defined(ret_value)) if (dblock) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(dblock) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array data block from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove fixed array data block from cache") /* Release data block's disk space */ if (H5F_addr_defined(dblock->addr) && H5MF_xfree(hdr->f, H5FD_MEM_FARRAY_DBLOCK, dblock->addr, (hsize_t)dblock->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to release fixed array data block") /* Destroy data block */ if (H5FA__dblock_dest(dblock) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy fixed array data block") } /* end if */ -END_FUNC(PKG) /* end H5FA__dblock_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_create() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_protect @@ -250,12 +261,14 @@ END_FUNC(PKG) /* end H5FA__dblock_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, - H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags)) +H5FA_dblock_t * +H5FA__dblock_protect(H5FA_hdr_t *hdr, haddr_t dblk_addr, unsigned flags) +{ + H5FA_dblock_t *dblock = NULL; /* Fixed array data block */ + H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + H5FA_dblock_t *ret_value = NULL; - /* Local variables */ - H5FA_dblock_t * dblock; /* Fixed array data block */ - H5FA_dblock_cache_ud_t udata; /* Information needed for loading data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -271,31 +284,33 @@ BEGIN_FUNC(PKG, ERR, H5FA_dblock_t *, NULL, NULL, /* Protect the data block */ if (NULL == (dblock = (H5FA_dblock_t *)H5AC_protect(hdr->f, H5AC_FARRAY_DBLOCK, dblk_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr) /* Create top proxy, if it doesn't exist */ if (hdr->top_proxy && NULL == dblock->top_proxy) { /* Add data block as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, hdr->f, dblock) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") dblock->top_proxy = hdr->top_proxy; } /* end if */ /* Set return value */ ret_value = dblock; - CATCH - +done: /* Clean up on error */ if (!ret_value) /* Release the data block, if it was protected */ if (dblock && H5AC_unprotect(hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", - (unsigned long long)dblock->addr) + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, + "unable to unprotect fixed array data block, address = %llu", + (unsigned long long)dblock->addr) -END_FUNC(PKG) /* end H5FA__dblock_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_unprotect @@ -309,22 +324,25 @@ END_FUNC(PKG) /* end H5FA__dblock_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags)) +herr_t +H5FA__dblock_unprotect(H5FA_dblock_t *dblock, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); /* Unprotect the data block */ if (H5AC_unprotect(dblock->hdr->f, H5AC_FARRAY_DBLOCK, dblock->addr, dblock, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array data block, address = %llu", - (unsigned long long)dblock->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array data block, address = %llu", + (unsigned long long)dblock->addr) -END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_delete @@ -338,10 +356,13 @@ END_FUNC(PKG) /* end H5FA__dblock_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr)) +herr_t +H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr) +{ + H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_dblock_t *dblock = NULL; /* Pointer to data block */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -349,8 +370,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, dblk_addr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", (unsigned long long)dblk_addr) /* Check if data block is paged */ if (dblock->npages) { @@ -365,21 +386,22 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_delete(H5FA_hdr_t *hdr, /* Evict the data block page from the metadata cache */ /* (OK to call if it doesn't exist in the cache) */ if (H5AC_expunge_entry(hdr->f, H5AC_FARRAY_DBLK_PAGE, dblk_page_addr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTEXPUNGE, "unable to remove array data block page from metadata cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTEXPUNGE, FAIL, + "unable to remove array data block page from metadata cache") /* Advance to next page address */ dblk_page_addr += dblock->dblk_page_size; } /* end for */ } /* end if */ - CATCH - +done: /* Finished deleting data block in metadata cache */ if (dblock && H5FA__dblock_unprotect(dblock, H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") -END_FUNC(PKG) /* end H5FA__dblock_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_delete() */ /*------------------------------------------------------------------------- * Function: H5FA__dblock_dest @@ -393,7 +415,12 @@ END_FUNC(PKG) /* end H5FA__dblock_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dblock)) +herr_t +H5FA__dblock_dest(H5FA_dblock_t *dblock) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dblock); @@ -417,7 +444,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dbl /* Decrement reference count on shared info */ if (H5FA__hdr_decr(dblock->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") dblock->hdr = NULL; } /* end if */ @@ -427,6 +455,6 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__dblock_dest(H5FA_dblock_t *dbl /* Free the data block itself */ dblock = H5FL_FREE(H5FA_dblock_t, dblock); - CATCH - -END_FUNC(PKG) /* end H5FA__dblock_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__dblock_dest() */ diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 867160fc0fe..ffa8a6773b3 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -82,17 +81,20 @@ H5FL_DEFINE_STATIC(H5FA_hdr_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, H5FA__hdr_alloc(H5F_t *f)) +H5FA_hdr_t * +H5FA__hdr_alloc(H5F_t *f) +{ + H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ + H5FA_hdr_t *ret_value = NULL; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Shared Fixed Array header */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); /* Allocate space for the shared information */ if (NULL == (hdr = H5FL_CALLOC(H5FA_hdr_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for Fixed Array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -106,13 +108,12 @@ BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, H5FA__hdr_alloc(H5F_t *f)) /* Set the return value */ ret_value = hdr; - CATCH - +done: if (!ret_value) if (hdr && H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy fixed array header") - -END_FUNC(PKG) /* end H5FA__hdr_alloc() */ + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, NULL, "unable to destroy fixed array header") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_alloc() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_init @@ -126,9 +127,12 @@ END_FUNC(PKG) /* end H5FA__hdr_alloc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata)) +herr_t +H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -140,33 +144,36 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_init(H5FA_hdr_t *hdr, void hdr->stats.nelmts = hdr->cparam.nelmts; /* Create the callback context, if there's one */ - if (hdr->cparam.cls->crt_context) { + if (hdr->cparam.cls->crt_context) if (NULL == (hdr->cb_ctx = (*hdr->cparam.cls->crt_context)(ctx_udata))) - H5E_THROW(H5E_CANTCREATE, "unable to create fixed array client callback context") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, + "unable to create fixed array client callback context") - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_init() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_init() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_create * * Purpose: Creates a new Fixed Array header in the file * - * Return: SUCCEED/FAIL + * Return: Success: Address of new header in the file + * Failure: HADDR_UNDEF * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, - H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) +haddr_t +H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata) +{ + H5FA_hdr_t *hdr = NULL; /* Fixed array header */ + hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + haddr_t ret_value = HADDR_UNDEF; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* Fixed array header */ - hbool_t inserted = FALSE; /* Whether the header was inserted into cache */ + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(f); @@ -176,17 +183,19 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, { /* Check for valid parameters */ if (cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, "element size must be greater than zero") if (cparam->max_dblk_page_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, + "max. # of elements bits must be greater than zero") if (cparam->nelmts == 0) - H5E_THROW(H5E_BADVALUE, "# of elements must be greater than zero") + HGOTO_ERROR(H5E_FARRAY, H5E_BADVALUE, HADDR_UNDEF, "# of elements must be greater than zero") } #endif /* NDEBUG */ /* Allocate space for the shared information */ if (NULL == (hdr = H5FA__hdr_alloc(f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for Fixed Array shared header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, + "memory allocation failed for Fixed Array shared header") hdr->dblk_addr = HADDR_UNDEF; @@ -195,50 +204,52 @@ BEGIN_FUNC(PKG, ERR, haddr_t, HADDR_UNDEF, HADDR_UNDEF, /* Finish initializing fixed array header */ if (H5FA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, HADDR_UNDEF, "initialization failed for fixed array header") /* Allocate space for the header on disk */ if (HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_FARRAY_HDR, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for Fixed Array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, HADDR_UNDEF, "file allocation failed for Fixed Array header") /* Create 'top' proxy for extensible array entries */ if (hdr->swmr_write) if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create fixed array entry proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, HADDR_UNDEF, "can't create fixed array entry proxy") /* Cache the new Fixed Array header */ if (H5AC_insert_entry(f, H5AC_FARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add fixed array header to cache") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINSERT, HADDR_UNDEF, "can't add fixed array header to cache") inserted = TRUE; /* Add header as child of 'top' proxy */ if (hdr->top_proxy) if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, HADDR_UNDEF, + "unable to add fixed array entry as child of array proxy") /* Set address of array header to return */ ret_value = hdr->addr; - CATCH - +done: if (!H5F_addr_defined(ret_value)) if (hdr) { /* Remove from cache, if inserted */ if (inserted) if (H5AC_remove_entry(hdr) < 0) - H5E_THROW(H5E_CANTREMOVE, "unable to remove fixed array header from cache") + HDONE_ERROR(H5E_FARRAY, H5E_CANTREMOVE, HADDR_UNDEF, + "unable to remove fixed array header from cache") /* Release header's disk space */ if (H5F_addr_defined(hdr->addr) && H5MF_xfree(f, H5FD_MEM_FARRAY_HDR, hdr->addr, (hsize_t)hdr->size) < 0) - H5E_THROW(H5E_CANTFREE, "unable to free Fixed Array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to free Fixed Array header") /* Destroy header */ if (H5FA__hdr_dest(hdr) < 0) - H5E_THROW(H5E_CANTFREE, "unable to destroy Fixed Array header") - } /* end if */ + HDONE_ERROR(H5E_FARRAY, H5E_CANTFREE, HADDR_UNDEF, "unable to destroy Fixed Array header") + } -END_FUNC(PKG) /* end H5FA__hdr_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_create() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_incr @@ -252,7 +263,12 @@ END_FUNC(PKG) /* end H5FA__hdr_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_incr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_incr(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -260,14 +276,14 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_incr(H5FA_hdr_t *hdr)) /* Mark header as un-evictable when something is depending on it */ if (hdr->rc == 0) if (H5AC_pin_protected_entry(hdr) < 0) - H5E_THROW(H5E_CANTPIN, "unable to pin fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPIN, FAIL, "unable to pin fixed array header") /* Increment reference count on shared header */ hdr->rc++; - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_incr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_incr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_decr @@ -281,7 +297,12 @@ END_FUNC(PKG) /* end H5FA__hdr_incr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_decr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_decr(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); @@ -294,12 +315,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_decr(H5FA_hdr_t *hdr)) if (hdr->rc == 0) { HDassert(hdr->file_rc == 0); if (H5AC_unpin_entry(hdr) < 0) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin fixed array header") - } /* end if */ - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPIN, FAIL, "unable to unpin fixed array header") + } -END_FUNC(PKG) /* end H5FA__hdr_decr() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_decr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_incr @@ -313,7 +334,10 @@ END_FUNC(PKG) /* end H5FA__hdr_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr) +{ + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -321,21 +345,28 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__hdr_fuse_incr(H5FA_hdr_t *hdr)) /* Increment file reference count on shared header */ hdr->file_rc++; -END_FUNC(PKG) /* end H5FA__hdr_fuse_incr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__hdr_fuse_incr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_fuse_decr * * Purpose: Decrement file reference count on shared array header * - * Return: SUCCEED/FAIL + * Return: Success: The reference count of the header + * Failure: Can't fail * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) +size_t +H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr) +{ + size_t ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(hdr); @@ -347,7 +378,8 @@ BEGIN_FUNC(PKG, NOERR, size_t, 0, -, H5FA__hdr_fuse_decr(H5FA_hdr_t *hdr)) /* Set return value */ ret_value = hdr->file_rc; -END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_fuse_decr() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_modified @@ -361,18 +393,23 @@ END_FUNC(PKG) /* end H5FA__hdr_fuse_decr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_modified(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_modified(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Mark header as dirty in cache */ if (H5AC_mark_entry_dirty(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as dirty") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as dirty") -END_FUNC(PKG) /* end H5FA__hdr_modified() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_modified() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_protect @@ -386,12 +423,14 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, - H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags)) - - /* Local variables */ - H5FA_hdr_t * hdr; /* Fixed array header */ +H5FA_hdr_t * +H5FA__hdr_protect(H5F_t *f, haddr_t fa_addr, void *ctx_udata, unsigned flags) +{ + H5FA_hdr_t *hdr; /* Fixed array header */ H5FA_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5FA_hdr_t *ret_value = NULL; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(f); @@ -407,27 +446,28 @@ BEGIN_FUNC(PKG, ERR, H5FA_hdr_t *, NULL, NULL, /* Protect the header */ if (NULL == (hdr = (H5FA_hdr_t *)H5AC_protect(f, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", - (unsigned long long)fa_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) hdr->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ /* Create top proxy, if it doesn't exist */ if (hdr->swmr_write && NULL == hdr->top_proxy) { /* Create 'top' proxy for fixed array entries */ if (NULL == (hdr->top_proxy = H5AC_proxy_entry_create())) - H5E_THROW(H5E_CANTCREATE, "can't create fixed array entry proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, NULL, "can't create fixed array entry proxy") /* Add header as child of 'top' proxy */ if (H5AC_proxy_entry_add_child(hdr->top_proxy, f, hdr) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array entry as child of array proxy") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, NULL, + "unable to add fixed array entry as child of array proxy") + } /* Set return value */ ret_value = hdr; - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_protect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_protect() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_unprotect @@ -441,21 +481,24 @@ END_FUNC(PKG) /* end H5FA__hdr_protect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags)) +herr_t +H5FA__hdr_unprotect(H5FA_hdr_t *hdr, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; - /* Local variables */ + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); /* Unprotect the header */ if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to unprotect fixed array hdr, address = %llu", - (unsigned long long)hdr->addr) - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, + "unable to unprotect fixed array hdr, address = %llu", (unsigned long long)hdr->addr) -END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_unprotect() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_delete @@ -469,46 +512,49 @@ END_FUNC(PKG) /* end H5FA__hdr_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_delete(H5FA_hdr_t *hdr)) - - /* Local variables */ +herr_t +H5FA__hdr_delete(H5FA_hdr_t *hdr) +{ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting header */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(hdr); HDassert(!hdr->file_rc); #ifndef NDEBUG - { - unsigned hdr_status = 0; /* Array header's status in the metadata cache */ - /* Check the array header's status in the metadata cache */ - if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for array header") + unsigned hdr_status = 0; /* Array header's status in the metadata cache */ + + /* Check the array header's status in the metadata cache */ + if (H5AC_get_entry_status(hdr->f, hdr->addr, &hdr_status) < 0) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, "unable to check metadata cache status for array header") + + /* Sanity checks on array header */ + HDassert(hdr_status & H5AC_ES__IN_CACHE); + HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - /* Sanity checks on array header */ - HDassert(hdr_status & H5AC_ES__IN_CACHE); - HDassert(hdr_status & H5AC_ES__IS_PROTECTED); - } /* end block */ #endif /* NDEBUG */ /* Check for Fixed Array Data block */ if (H5F_addr_defined(hdr->dblk_addr)) { /* Delete Fixed Array Data block */ if (H5FA__dblock_delete(hdr, hdr->dblk_addr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array data block") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array data block") + } /* Set flags to finish deleting header on unprotect */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH - +done: /* Unprotect the header, deleting it if an error hasn't occurred */ if (H5AC_unprotect(hdr->f, H5AC_FARRAY_HDR, hdr->addr, hdr, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PKG) /* end H5FA__hdr_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_delete() */ /*------------------------------------------------------------------------- * Function: H5FA__hdr_dest @@ -522,7 +568,12 @@ END_FUNC(PKG) /* end H5FA__hdr_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_dest(H5FA_hdr_t *hdr)) +herr_t +H5FA__hdr_dest(H5FA_hdr_t *hdr) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* Check arguments */ HDassert(hdr); @@ -531,20 +582,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5FA__hdr_dest(H5FA_hdr_t *hdr)) /* Destroy the callback context */ if (hdr->cb_ctx) { if ((*hdr->cparam.cls->dst_context)(hdr->cb_ctx) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array client callback context") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, + "unable to destroy fixed array client callback context") + } hdr->cb_ctx = NULL; /* Destroy the 'top' proxy */ if (hdr->top_proxy) { if (H5AC_proxy_entry_dest(hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTRELEASE, "unable to destroy fixed array 'top' proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTRELEASE, FAIL, "unable to destroy fixed array 'top' proxy") hdr->top_proxy = NULL; - } /* end if */ + } /* Free the shared info itself */ hdr = H5FL_FREE(H5FA_hdr_t, hdr); - CATCH - -END_FUNC(PKG) /* end H5FA__hdr_dest() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__hdr_dest() */ diff --git a/src/H5FAint.c b/src/H5FAint.c index 864c7ee8149..1a5ab75d244 100644 --- a/src/H5FAint.c +++ b/src/H5FAint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -79,8 +78,12 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5FA__create_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -88,11 +91,11 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Create a flush dependency between parent and child entry */ if (H5AC_create_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTDEPEND, "unable to create flush dependency") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEPEND, FAIL, "unable to create flush dependency") -END_FUNC(PKG) /* end H5FA__create_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__create_flush_depend() */ /*------------------------------------------------------------------------- * Function: H5FA__destroy_flush_depend @@ -106,8 +109,12 @@ END_FUNC(PKG) /* end H5FA__create_flush_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, - H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry)) +herr_t +H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(parent_entry); @@ -115,8 +122,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, /* Destroy a flush dependency between parent and child entry */ if (H5AC_destroy_flush_dependency(parent_entry, child_entry) < 0) - H5E_THROW(H5E_CANTUNDEPEND, "unable to destroy flush dependency") - - CATCH + HGOTO_ERROR(H5E_FARRAY, H5E_CANTUNDEPEND, FAIL, "unable to destroy flush dependency") -END_FUNC(PKG) /* end H5FA__destroy_flush_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__destroy_flush_depend() */ diff --git a/src/H5FApkg.h b/src/H5FApkg.h index c4bf93485fb..48aa8df6d75 100644 --- a/src/H5FApkg.h +++ b/src/H5FApkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -129,7 +128,7 @@ typedef struct H5FA_hdr_t { size_t rc; /* Reference count of the header */ haddr_t addr; /* Address of header in file */ size_t size; /* Size of header in file */ - H5F_t * f; /* Pointer to file for fixed array */ + H5F_t *f; /* Pointer to file for fixed array */ size_t file_rc; /* Reference count of files using array header */ hbool_t pending_delete; /* Array is pending deletion */ size_t sizeof_addr; /* Size of file addresses */ @@ -141,7 +140,7 @@ typedef struct H5FA_hdr_t { /* SWMR / Flush dependency information (not stored) */ hbool_t swmr_write; /* Flag indicating the file is opened with SWMR-write access */ H5AC_proxy_entry_t *top_proxy; /* 'Top' proxy cache entry for all array entries */ - void * parent; /* Pointer to 'top' proxy flush dependency + void *parent; /* Pointer to 'top' proxy flush dependency * parent, if it exists, otherwise NULL. * If the fixed array is being used * to index a chunked dataset and the @@ -168,7 +167,7 @@ typedef struct H5FA_dblock_t { /* Fixed array information (stored) */ uint8_t *dblk_page_init; /* Bitmap of whether a data block page is initialized */ - void * elmts; /* Buffer for elements stored in data block */ + void *elmts; /* Buffer for elements stored in data block */ /* Internal array information (not stored) */ H5FA_hdr_t *hdr; /* Shared array header info */ @@ -179,8 +178,8 @@ typedef struct H5FA_dblock_t { /* Computed/cached values (not stored) */ haddr_t addr; /* Address of this data block on disk */ hsize_t size; /* Size of data block on disk */ - size_t npages; /* Nummber of pages in data block (zero if not paged) */ - size_t last_page_nelmts; /* Nummber of elements in last page, if paged */ + size_t npages; /* Number of pages in data block (zero if not paged) */ + size_t last_page_nelmts; /* Number of elements in last page, if paged */ /* Fixed Array data block information (not stored) */ size_t dblk_page_nelmts; /* # of elements per data block page */ @@ -211,16 +210,16 @@ typedef struct H5FA_dbk_page_t { /* Fixed array */ struct H5FA_t { H5FA_hdr_t *hdr; /* Pointer to internal fixed array header info */ - H5F_t * f; /* Pointer to file for fixed array */ + H5F_t *f; /* Pointer to file for fixed array */ }; /* Metadata cache callback user data types */ /* Info needed for loading header */ typedef struct H5FA_hdr_cache_ud_t { - H5F_t * f; /* Pointer to file for fixed array */ + H5F_t *f; /* Pointer to file for fixed array */ haddr_t addr; /* Address of header on disk */ - void * ctx_udata; /* User context for class */ + void *ctx_udata; /* User context for class */ } H5FA_hdr_cache_ud_t; /* Info needed for loading data block */ @@ -258,7 +257,7 @@ H5_DLL herr_t H5FA__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t H5_DLL H5FA_hdr_t *H5FA__hdr_alloc(H5F_t *f); H5_DLL herr_t H5FA__hdr_init(H5FA_hdr_t *hdr, void *ctx_udata); H5_DLL haddr_t H5FA__hdr_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata); -H5_DLL void * H5FA__hdr_alloc_elmts(H5FA_hdr_t *hdr, size_t nelmts); +H5_DLL void *H5FA__hdr_alloc_elmts(H5FA_hdr_t *hdr, size_t nelmts); H5_DLL herr_t H5FA__hdr_free_elmts(H5FA_hdr_t *hdr, size_t nelmts, void *elmts); H5_DLL herr_t H5FA__hdr_incr(H5FA_hdr_t *hdr); H5_DLL herr_t H5FA__hdr_decr(H5FA_hdr_t *hdr); @@ -280,7 +279,7 @@ H5_DLL herr_t H5FA__dblock_delete(H5FA_hdr_t *hdr, haddr_t dblk_addr); H5_DLL herr_t H5FA__dblock_dest(H5FA_dblock_t *dblock); /* Data block page routines */ -H5_DLL herr_t H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts); +H5_DLL herr_t H5FA__dblk_page_create(H5FA_hdr_t *hdr, haddr_t addr, size_t nelmts); H5_DLL H5FA_dblk_page_t *H5FA__dblk_page_alloc(H5FA_hdr_t *hdr, size_t nelmts); H5_DLL H5FA_dblk_page_t *H5FA__dblk_page_protect(H5FA_hdr_t *hdr, haddr_t dblk_page_addr, size_t dblk_page_nelmts, unsigned flags); diff --git a/src/H5FAprivate.h b/src/H5FAprivate.h index 26057bf4e15..9bdc0742c75 100644 --- a/src/H5FAprivate.h +++ b/src/H5FAprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -24,11 +23,6 @@ #ifndef H5FAprivate_H #define H5FAprivate_H -/* Include package's public header */ -#ifdef NOT_YET -#include "H5FApublic.h" -#endif /* NOT_YET */ - /* Private headers needed by this file */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Fprivate.h" /* File access */ @@ -58,13 +52,13 @@ typedef enum H5FA_cls_id_t { */ typedef struct H5FA_class_t { H5FA_cls_id_t id; /* ID of Fixed Array class, as found in file */ - const char * name; /* Name of class (for debugging) */ + const char *name; /* Name of class (for debugging) */ size_t nat_elmt_size; /* Size of native (memory) element */ /* Fixed array client callback methods */ void *(*crt_context)(void *udata); /* Create context for other callbacks */ herr_t (*dst_context)(void *ctx); /* Destroy context */ - herr_t (*fill)(void * nat_blk, + herr_t (*fill)(void *nat_blk, size_t nelmts); /* Fill array of elements with encoded form of "missing element" value */ herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, void *ctx); /* Encode elements from native form to disk storage form */ @@ -134,7 +128,7 @@ H5_DLL herr_t H5FA_patch_file(H5FA_t *fa, H5F_t *f); H5_DLL herr_t H5FA_get_stats(const H5FA_t *ea, H5FA_stat_t *stats); /* Debugging routines */ -#ifdef H5FA_DEBUGGING -#endif /* H5FA_DEBUGGING */ +#ifdef H5FA_DEBUG +#endif /* H5FA_DEBUG */ #endif /* H5FAprivate_H */ diff --git a/src/H5FAstat.c b/src/H5FAstat.c index 1fdf47fc913..85607d775a5 100644 --- a/src/H5FAstat.c +++ b/src/H5FAstat.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -78,21 +77,21 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats)) - -/* Local variables */ +herr_t +H5FA_get_stats(const H5FA_t *fa, H5FA_stat_t *stats) +{ + FUNC_ENTER_NOAPI_NOERR #ifdef H5FA_DEBUG HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* H5FA_DEBUG */ - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(stats); /* Copy fixed array statistics */ H5MM_memcpy(stats, &fa->hdr->stats, sizeof(fa->hdr->stats)); -END_FUNC(PRIV) /* end H5FA_get_stats() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_stats() */ diff --git a/src/H5FAtest.c b/src/H5FAtest.c index 6dd6e00c5b1..064d537aed1 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -61,13 +60,13 @@ typedef struct H5FA__test_ctx_t { /********************/ /* Fixed array class callbacks */ -static void * H5FA__test_crt_context(void *udata); +static void *H5FA__test_crt_context(void *udata); static herr_t H5FA__test_dst_context(void *ctx); static herr_t H5FA__test_fill(void *nat_blk, size_t nelmts); static herr_t H5FA__test_encode(void *raw, const void *elmt, size_t nelmts, void *ctx); static herr_t H5FA__test_decode(const void *raw, void *elmt, size_t nelmts, void *ctx); static herr_t H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); -static void * H5FA__test_crt_dbg_context(H5F_t *f, haddr_t obj_addr); +static void *H5FA__test_crt_dbg_context(H5F_t *f, haddr_t obj_addr); /*********************/ /* Package Variables */ @@ -112,14 +111,17 @@ H5FL_DEFINE_STATIC(H5FA__test_ctx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5FA__test_crt_context(void H5_ATTR_UNUSED *udata)) - - /* Local variables */ +static void * +H5FA__test_crt_context(void H5_ATTR_UNUSED *udata) +{ H5FA__test_ctx_t *ctx; /* Context for callbacks */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") /* Initialize the context */ ctx->bogus = H5FA__TEST_BOGUS_VAL; @@ -127,9 +129,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, H5FA__test_crt_context(void H5_ATTR_ /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5FA__test_crt_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__test_crt_context() */ /*------------------------------------------------------------------------- * Function: H5FA__test_dst_context @@ -143,18 +145,21 @@ END_FUNC(STATIC) /* end H5FA__test_crt_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_dst_context(void *_ctx)) - - /* Local variables */ +static herr_t +H5FA__test_dst_context(void *_ctx) +{ H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(H5FA__TEST_BOGUS_VAL == ctx->bogus); /* Release context structure */ ctx = H5FL_FREE(H5FA__test_ctx_t, ctx); -END_FUNC(STATIC) /* end H5FA__test_dst_context() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_dst_context() */ /*------------------------------------------------------------------------- * Function: H5FA__test_fill @@ -168,18 +173,21 @@ END_FUNC(STATIC) /* end H5FA__test_dst_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, H5FA__test_fill(void *nat_blk, size_t nelmts)) - - /* Local variables */ +static herr_t +H5FA__test_fill(void *nat_blk, size_t nelmts) +{ uint64_t fill_val = H5FA_TEST_FILL; /* Value to fill elements with */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(nat_blk); HDassert(nelmts); H5VM_array_fill(nat_blk, &fill_val, sizeof(uint64_t), nelmts); -END_FUNC(STATIC) /* end H5FA__test_fill() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_fill() */ /*------------------------------------------------------------------------- * Function: H5FA__test_encode @@ -193,14 +201,15 @@ END_FUNC(STATIC) /* end H5FA__test_fill() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5FA__test_encode(void *raw, const void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx) +{ #ifndef NDEBUG H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ +#endif + const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */ + + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(raw); @@ -221,7 +230,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_encode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_encode() */ /*------------------------------------------------------------------------- * Function: H5FA__test_decode @@ -235,15 +245,16 @@ END_FUNC(STATIC) /* end H5FA__test_encode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx)) - -/* Local variables */ +static herr_t +H5FA__test_decode(const void *_raw, void *_elmt, size_t nelmts, void H5_ATTR_UNUSED *_ctx) +{ #ifndef NDEBUG H5FA__test_ctx_t *ctx = (H5FA__test_ctx_t *)_ctx; /* Callback context to destroy */ -#endif /* NDEBUG */ - uint64_t * elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ - const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ +#endif + uint64_t *elmt = (uint64_t *)_elmt; /* Convenience pointer to native elements */ + const uint8_t *raw = (const uint8_t *)_raw; /* Convenience pointer to raw elements */ + + FUNC_ENTER_STATIC_NOERR /* Sanity checks */ HDassert(raw); @@ -264,7 +275,8 @@ BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, nelmts--; } /* end while */ -END_FUNC(STATIC) /* end H5FA__test_decode() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_decode() */ /*------------------------------------------------------------------------- * Function: H5FA__test_debug @@ -278,22 +290,24 @@ END_FUNC(STATIC) /* end H5FA__test_decode() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, herr_t, SUCCEED, -, - H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt)) - - /* Local variables */ +static herr_t +H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt) +{ char temp_str[128]; /* Temporary string, for formatting */ + FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(stream); HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%llu:", (unsigned long long)idx); HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, (unsigned long long)*(const uint64_t *)elmt); -END_FUNC(STATIC) /* end H5FA__test_debug() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA__test_debug() */ /*------------------------------------------------------------------------- * Function: H5FA__test_crt_dbg_context @@ -308,15 +322,17 @@ END_FUNC(STATIC) /* end H5FA__test_debug() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, - H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr)) - - /* Local variables */ +static void * +H5FA__test_crt_dbg_context(H5F_t H5_ATTR_UNUSED *f, haddr_t H5_ATTR_UNUSED obj_addr) +{ H5FA__test_ctx_t *ctx; /* Context for callbacks */ + void *ret_value = NULL; + + FUNC_ENTER_STATIC /* Allocate new context structure */ if (NULL == (ctx = H5FL_MALLOC(H5FA__test_ctx_t))) - H5E_THROW(H5E_CANTALLOC, "can't allocate fixed array client callback context") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "can't allocate fixed array client callback context") /* Initialize the context */ ctx->bogus = H5FA__TEST_BOGUS_VAL; @@ -324,9 +340,9 @@ BEGIN_FUNC(STATIC, ERR, void *, NULL, NULL, /* Set return value */ ret_value = ctx; - CATCH - -END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5FA__test_crt_dbg_context() */ /*------------------------------------------------------------------------- * Function: H5FA__get_cparam_test @@ -340,7 +356,10 @@ END_FUNC(STATIC) /* end H5FA__test_crt_dbg_context() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam)) +herr_t +H5FA__get_cparam_test(const H5FA_t *fa, H5FA_create_t *cparam) +{ + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(fa); @@ -350,22 +369,27 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5FA__get_cparam_test(const H5FA_t *f cparam->raw_elmt_size = fa->hdr->cparam.raw_elmt_size; cparam->nelmts = fa->hdr->cparam.nelmts; -END_FUNC(PKG) /* end H5FA__get_cparam_test() */ + FUNC_LEAVE_NOAPI(SUCCEED); +} /* end H5FA__get_cparam_test() */ /*------------------------------------------------------------------------- * Function: H5FA__cmp_cparam_test * * Purpose: Compare the parameters used to create the fixed array * - * Return: SUCCEED/FAIL + * Return: An integer value like strcmp * * Programmer: Vailin Choi * Thursday, April 30, 2009 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, - H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2)) +int +H5FA__cmp_cparam_test(const H5FA_create_t *cparam1, const H5FA_create_t *cparam2) +{ + int ret_value = 0; + + FUNC_ENTER_PACKAGE_NOERR /* Check arguments. */ HDassert(cparam1); @@ -373,10 +397,10 @@ BEGIN_FUNC(PKG, ERRCATCH, int, 0, -, /* Compare creation parameters for array */ if (cparam1->raw_elmt_size < cparam2->raw_elmt_size) - H5_LEAVE(-1) + ret_value = -1; else if (cparam1->raw_elmt_size > cparam2->raw_elmt_size) - H5_LEAVE(1) + ret_value = 1; - CATCH + FUNC_LEAVE_NOAPI(ret_value) -END_FUNC(PKG) /* end H5FA__cmp_cparam_test() */ +} /* end H5FA__cmp_cparam_test() */ diff --git a/src/H5FD.c b/src/H5FD.c index 11cbdc4868c..acc653bf4b2 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -266,7 +265,7 @@ hid_t H5FD_register(const void *_cls, size_t size, hbool_t app_ref) { const H5FD_class_t *cls = (const H5FD_class_t *)_cls; - H5FD_class_t * saved = NULL; + H5FD_class_t *saved = NULL; H5FD_mem_t type; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -674,13 +673,13 @@ H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5FD_t * H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_class_t * driver; /* VFD for file */ - H5FD_t * file = NULL; /* VFD file struct */ + H5FD_class_t *driver; /* VFD for file */ + H5FD_t *file = NULL; /* VFD file struct */ H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ unsigned long driver_flags = 0; /* File-inspecific driver feature flags */ H5FD_file_image_info_t file_image_info; /* Initial file image */ - H5FD_t * ret_value = NULL; /* Return value */ + H5FD_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1324,7 +1323,7 @@ H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map) HDassert(file->cls); HDassert(type_map); - /* Check for VFD class providing a type map retrieval rouine */ + /* Check for VFD class providing a type map retrieval routine */ if (file->cls->get_type_map) { /* Retrieve type mapping for this file */ if ((file->cls->get_type_map)(file, type_map) < 0) @@ -1746,8 +1745,10 @@ H5FDget_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: - if (FAIL == ret_value) - *file_handle = NULL; + if (FAIL == ret_value) { + if (file_handle) + *file_handle = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5FDget_vfd_handle() */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 3bb95f724ec..57f6572b885 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -51,7 +50,7 @@ typedef struct H5FD_core_region_t { */ typedef struct H5FD_core_t { H5FD_t pub; /* public stuff, must be first */ - char * name; /* for equivalence testing */ + char *name; /* for equivalence testing */ unsigned char *mem; /* the underlying memory */ haddr_t eoa; /* end of allocated region */ haddr_t eof; /* current allocated size */ @@ -91,7 +90,7 @@ typedef struct H5FD_core_t { #endif /* H5_HAVE_WIN32_API */ hbool_t dirty; /* changes not saved? */ H5FD_file_image_callbacks_t fi_callbacks; /* file image callbacks */ - H5SL_t * dirty_list; /* dirty parts of the file */ + H5SL_t *dirty_list; /* dirty parts of the file */ } H5FD_core_t; /* Driver-specific file access properties */ @@ -131,7 +130,7 @@ static herr_t H5FD__core_add_dirty_region(H5FD_core_t *file, haddr_t start, had static herr_t H5FD__core_destroy_dirty_list(H5FD_core_t *file); static herr_t H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size); static herr_t H5FD__core_term(void); -static void * H5FD__core_fapl_get(H5FD_t *_file); +static void *H5FD__core_fapl_get(H5FD_t *_file); static H5FD_t *H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD__core_close(H5FD_t *_file); static int H5FD__core_cmp(const H5FD_t *_f1, const H5FD_t *_f2); @@ -388,7 +387,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 */ @@ -417,7 +416,7 @@ H5FD__core_write_to_bstore(H5FD_core_t *file, haddr_t addr, size_t size) static herr_t H5FD__init_package(void) { - char * lock_env_var = NULL; /* Environment variable pointer */ + char *lock_env_var = NULL; /* Environment variable pointer */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -508,7 +507,7 @@ H5FD__core_term(void) herr_t H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5FD_core_fapl_t fa; /* Core VFD info */ const H5FD_core_fapl_t *old_fa; /* Old core VFD info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -559,7 +558,7 @@ H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) herr_t H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_size) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ const H5FD_core_fapl_t *fa; /* Core VFD info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -601,7 +600,7 @@ H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_siz herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5FD_core_fapl_t fa; /* Core VFD info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -642,7 +641,7 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ const H5FD_core_fapl_t *fa; /* Core VFD info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -681,9 +680,9 @@ H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_stor static void * H5FD__core_fapl_get(H5FD_t *_file) { - H5FD_core_t * file = (H5FD_core_t *)_file; + H5FD_core_t *file = (H5FD_core_t *)_file; H5FD_core_fapl_t *fa; /* Core VFD info */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -721,16 +720,16 @@ static H5FD_t * H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { int o_flags; - H5FD_core_t * file = NULL; + H5FD_core_t *file = NULL; const H5FD_core_fapl_t *fa = NULL; - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif h5_stat_t sb; int fd = -1; H5FD_file_image_info_t file_image_info; - H5FD_t * ret_value = NULL; /* Return value */ + H5FD_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -916,8 +915,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 */ @@ -1510,7 +1509,7 @@ H5FD__core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_UN * Addendum -- 12/2/11 * For file images opened with the core file driver, it is * necessary that we avoid reallocating the core file driver's - * buffer uneccessarily. + * buffer unnecessarily. * * To this end, I have made the following functional changes * to this function. diff --git a/src/H5FDcore.h b/src/H5FDcore.h index d456c3efb57..07c37bc3e83 100644 --- a/src/H5FDcore.h +++ b/src/H5FDcore.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 35da1f17f76..bae1a711b6b 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -120,8 +119,8 @@ typedef struct H5FD_direct_t { /* Prototypes */ static herr_t H5FD__direct_term(void); -static void * H5FD__direct_fapl_get(H5FD_t *file); -static void * H5FD__direct_fapl_copy(const void *_old_fa); +static void *H5FD__direct_fapl_get(H5FD_t *file); +static void *H5FD__direct_fapl_copy(const void *_old_fa); static H5FD_t *H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD__direct_close(H5FD_t *_file); static int H5FD__direct_cmp(const H5FD_t *_f1, const H5FD_t *_f2); @@ -191,7 +190,7 @@ DESCRIPTION static herr_t H5FD__init_package(void) { - char * lock_env_var = NULL; /* Environment variable pointer */ + char *lock_env_var = NULL; /* Environment variable pointer */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -233,8 +232,11 @@ H5FD_direct_init(void) FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g)) + if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g)) { H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g, sizeof(H5FD_class_t), FALSE); + if (H5I_INVALID_HID == H5FD_DIRECT_g) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register direct"); + } /* Set return value */ ret_value = H5FD_DIRECT_g; @@ -283,7 +285,7 @@ H5FD__direct_term(void) herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbuf_size) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5FD_direct_fapl_t fa; herr_t ret_value; @@ -339,7 +341,7 @@ herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary /*out*/, size_t *block_size /*out*/, size_t *cbuf_size /*out*/) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ const H5FD_direct_fapl_t *fa; herr_t ret_value = SUCCEED; /* Return value */ @@ -384,7 +386,7 @@ static void * H5FD__direct_fapl_get(H5FD_t *_file) { H5FD_direct_t *file = (H5FD_direct_t *)_file; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -412,7 +414,7 @@ static void * H5FD__direct_fapl_copy(const void *_old_fa) { const H5FD_direct_fapl_t *old_fa = (const H5FD_direct_fapl_t *)_old_fa; - H5FD_direct_fapl_t * new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t)); + H5FD_direct_fapl_t *new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t)); FUNC_ENTER_STATIC_NOERR @@ -445,7 +447,7 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad { int o_flags; int fd = (-1); - H5FD_direct_t * file = NULL; + H5FD_direct_t *file = NULL; const H5FD_direct_fapl_t *fa; #ifdef H5_HAVE_WIN32_API HFILE filehandle; @@ -453,8 +455,8 @@ H5FD__direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad #endif h5_stat_t sb; H5P_genplist_t *plist; /* Property list */ - void * buf1, *buf2; - H5FD_t * ret_value = NULL; + void *buf1, *buf2; + H5FD_t *ret_value = NULL; FUNC_ENTER_STATIC @@ -852,7 +854,7 @@ H5FD__direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U hbool_t _must_align = TRUE; herr_t ret_value = SUCCEED; /* Return value */ size_t alloc_size; - void * copy_buf = NULL, *p2; + void *copy_buf = NULL, *p2; size_t _boundary; size_t _fbsize; size_t _cbsize; @@ -1032,8 +1034,8 @@ H5FD__direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_ hbool_t _must_align = TRUE; herr_t ret_value = SUCCEED; /* Return value */ size_t alloc_size; - void * copy_buf = NULL, *p1; - const void * p3; + void *copy_buf = NULL, *p1; + const void *p3; size_t _boundary; size_t _fbsize; size_t _cbsize; diff --git a/src/H5FDdirect.h b/src/H5FDdirect.h index f06de7f4160..3a5fa8c7231 100644 --- a/src/H5FDdirect.h +++ b/src/H5FDdirect.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index adfa1a31aa7..71c83831593 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -60,7 +59,7 @@ typedef struct H5FD_family_t { unsigned amembs; /*number of member slots allocated */ H5FD_t **memb; /*dynamic array of member pointers */ haddr_t eoa; /*end of allocated addresses */ - char * name; /*name generator printf format */ + char *name; /*name generator printf format */ unsigned flags; /*flags for opening additional members */ /* Information from properties set by 'h5repart' tool */ @@ -79,8 +78,8 @@ typedef struct H5FD_family_fapl_t { /* Callback prototypes */ static herr_t H5FD__family_term(void); -static void * H5FD__family_fapl_get(H5FD_t *_file); -static void * H5FD__family_fapl_copy(const void *_old_fa); +static void *H5FD__family_fapl_get(H5FD_t *_file); +static void *H5FD__family_fapl_copy(const void *_old_fa); static herr_t H5FD__family_fapl_free(void *_fa); static hsize_t H5FD__family_sb_size(H5FD_t *_file); static herr_t H5FD__family_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); @@ -241,7 +240,7 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t msize, hid_t memb_fapl_id) { herr_t ret_value; H5FD_family_fapl_t fa = {0, -1}; - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ihi", fapl_id, msize, memb_fapl_id); @@ -284,7 +283,7 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t msize, hid_t memb_fapl_id) herr_t H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize /*out*/, hid_t *memb_fapl_id /*out*/) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ const H5FD_family_fapl_t *fa; herr_t ret_value = SUCCEED; /* Return value */ @@ -327,10 +326,10 @@ H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize /*out*/, hid_t *memb_fapl_id /* static void * H5FD__family_fapl_get(H5FD_t *_file) { - H5FD_family_t * file = (H5FD_family_t *)_file; + H5FD_family_t *file = (H5FD_family_t *)_file; H5FD_family_fapl_t *fa = NULL; - H5P_genplist_t * plist; /* Property list pointer */ - void * ret_value = NULL; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -371,9 +370,9 @@ static void * H5FD__family_fapl_copy(const void *_old_fa) { const H5FD_family_fapl_t *old_fa = (const H5FD_family_fapl_t *)_old_fa; - H5FD_family_fapl_t * new_fa = NULL; - H5P_genplist_t * plist; /* Property list pointer */ - void * ret_value = NULL; /* Return value */ + H5FD_family_fapl_t *new_fa = NULL; + H5P_genplist_t *plist; /* Property list pointer */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -585,10 +584,10 @@ static H5FD_t * H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_family_t *file = NULL; - char * memb_name = NULL, *temp = NULL; + char *memb_name = NULL, *temp = NULL; hsize_t eof = HADDR_UNDEF; unsigned t_flags = flags & ~H5F_ACC_CREAT; - H5FD_t * ret_value = NULL; + H5FD_t *ret_value = NULL; FUNC_ENTER_STATIC @@ -610,7 +609,7 @@ H5FD__family_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad file->mem_newsize = 0; /*New member size used by h5repart only */ } /* end if */ else { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ const H5FD_family_fapl_t *fa; if (NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) @@ -909,7 +908,7 @@ H5FD__family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa) { H5FD_family_t *file = (H5FD_family_t *)_file; haddr_t addr = abs_eoa; - char * memb_name = NULL; + char *memb_name = NULL; unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1044,7 +1043,7 @@ H5FD__family_get_eof(const H5FD_t *_file, H5FD_mem_t type) static herr_t H5FD__family_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - H5FD_family_t * file = (H5FD_family_t *)_file; + H5FD_family_t *file = (H5FD_family_t *)_file; H5P_genplist_t *plist; hsize_t offset; int memb; @@ -1089,8 +1088,8 @@ static herr_t H5FD__family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *_buf /*out*/) { - H5FD_family_t * file = (H5FD_family_t *)_file; - unsigned char * buf = (unsigned char *)_buf; + H5FD_family_t *file = (H5FD_family_t *)_file; + unsigned char *buf = (unsigned char *)_buf; haddr_t sub; size_t req; hsize_t tempreq; @@ -1154,13 +1153,13 @@ H5FD__family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s static herr_t H5FD__family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *_buf) { - H5FD_family_t * file = (H5FD_family_t *)_file; + H5FD_family_t *file = (H5FD_family_t *)_file; const unsigned char *buf = (const unsigned char *)_buf; haddr_t sub; size_t req; hsize_t tempreq; unsigned u; /* Local index variable */ - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5FDfamily.h b/src/H5FDfamily.h index 20ef5325924..ea5c6558a1a 100644 --- a/src/H5FDfamily.h +++ b/src/H5FDfamily.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index 9f0614e4835..b53d5da3d25 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -1,15 +1,13 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only HDFS Virtual File Driver (VFD) * - * Copyright (c) 2018, The HDF Group. * - * * + * Copyright by The HDF Group. * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* @@ -253,7 +251,7 @@ typedef struct H5FD_hdfs_t { H5FD_t pub; H5FD_hdfs_fapl_t fa; haddr_t eoa; - hdfs_t * hdfs_handle; + hdfs_t *hdfs_handle; #if HDFS_STATS hdfs_statsbin meta[HDFS_STATS_BIN_COUNT + 1]; hdfs_statsbin raw[HDFS_STATS_BIN_COUNT + 1]; @@ -275,8 +273,8 @@ typedef struct H5FD_hdfs_t { /* Prototypes */ static herr_t H5FD__hdfs_term(void); -static void * H5FD__hdfs_fapl_get(H5FD_t *_file); -static void * H5FD__hdfs_fapl_copy(const void *_old_fa); +static void *H5FD__hdfs_fapl_get(H5FD_t *_file); +static void *H5FD__hdfs_fapl_copy(const void *_old_fa); static herr_t H5FD__hdfs_fapl_free(void *_fa); static H5FD_t *H5FD__hdfs_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD__hdfs_close(H5FD_t *_file); @@ -450,8 +448,8 @@ H5FD__hdfs_handle_open(const char *path, const char *namenode_name, const int32_ const int32_t stream_buffer_size) { struct hdfsBuilder *builder = NULL; - hdfs_t * handle = NULL; - hdfs_t * ret_value = NULL; + hdfs_t *handle = NULL; + hdfs_t *ret_value = NULL; FUNC_ENTER_STATIC @@ -569,16 +567,16 @@ H5FD__hdfs_handle_close(hdfs_t *handle) * Function: H5FD__hdfs_validate_config() * * Purpose: Test to see if the supplied instance of H5FD_hdfs_fapl_t - * contains internally consistant data. Return SUCCEED if so, + * contains internally consistent data. Return SUCCEED if so, * and FAIL otherwise. * - * Note the difference between internally consistant and + * Note the difference between internally consistent and * correct. As we will have to try to access the target * object to determine whether the supplied data is correct, - * we will settle for internal consistancy at this point + * we will settle for internal consistency at this point * * Return: SUCCEED if instance of H5FD_hdfs_fapl_t contains internally - * consistant data, FAIL otherwise. + * consistent data, FAIL otherwise. * * Programmer: Jacob Smith * 9/10/17 @@ -665,7 +663,7 @@ herr_t H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_dst) { const H5FD_hdfs_fapl_t *fa_src = NULL; - H5P_genplist_t * plist = NULL; + H5P_genplist_t *plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -713,9 +711,9 @@ H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_dst) static void * H5FD__hdfs_fapl_get(H5FD_t *_file) { - H5FD_hdfs_t * file = (H5FD_hdfs_t *)_file; + H5FD_hdfs_t *file = (H5FD_hdfs_t *)_file; H5FD_hdfs_fapl_t *fa = NULL; - void * ret_value = NULL; + void *ret_value = NULL; FUNC_ENTER_STATIC @@ -753,8 +751,8 @@ static void * H5FD__hdfs_fapl_copy(const void *_old_fa) { const H5FD_hdfs_fapl_t *old_fa = (const H5FD_hdfs_fapl_t *)_old_fa; - H5FD_hdfs_fapl_t * new_fa = NULL; - void * ret_value = NULL; + H5FD_hdfs_fapl_t *new_fa = NULL; + void *ret_value = NULL; FUNC_ENTER_STATIC @@ -879,9 +877,9 @@ hdfs__reset_stats(H5FD_hdfs_t *file) static H5FD_t * H5FD__hdfs_open(const char *path, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_t * ret_value = NULL; - H5FD_hdfs_t * file = NULL; - hdfs_t * handle = NULL; + H5FD_t *ret_value = NULL; + H5FD_hdfs_t *file = NULL; + hdfs_t *handle = NULL; H5FD_hdfs_fapl_t fa; FUNC_ENTER_STATIC @@ -1000,7 +998,7 @@ static herr_t hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) { herr_t ret_value = SUCCEED; - parsed_url_t * purl = NULL; + parsed_url_t *purl = NULL; unsigned i = 0; unsigned long count_meta = 0; unsigned long count_raw = 0; @@ -1012,7 +1010,7 @@ hdfs__fprint_stats(FILE *stream, const H5FD_hdfs_t *file) unsigned long long max_raw = 0; unsigned long long bytes_raw = 0; unsigned long long bytes_meta = 0; - double re_dub = 0.0; /* re-usable double variable */ + double re_dub = 0.0; /* reusable double variable */ unsigned suffix_i = 0; const char suffixes[] = {' ', 'K', 'M', 'G', 'T', 'P'}; @@ -1275,8 +1273,8 @@ H5FD__hdfs_cmp(const H5FD_t *_f1, const H5FD_t *_f2) int ret_value = 0; const H5FD_hdfs_t *f1 = (const H5FD_hdfs_t *)_f1; const H5FD_hdfs_t *f2 = (const H5FD_hdfs_t *)_f2; - hdfsFileInfo * finfo1 = NULL; - hdfsFileInfo * finfo2 = NULL; + hdfsFileInfo *finfo1 = NULL; + hdfsFileInfo *finfo2 = NULL; FUNC_ENTER_STATIC_NOERR @@ -1732,7 +1730,7 @@ H5FD_hdfs_init(void) } herr_t -H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out) +H5Pget_fapl_hdfs(hid_t H5_ATTR_UNUSED fapl_id, H5FD_hdfs_fapl_t H5_ATTR_UNUSED *fa_out) { herr_t ret_value = FAIL; @@ -1746,7 +1744,7 @@ H5Pget_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa_out) } herr_t -H5Pset_fapl_hdfs(hid_t fapl_id, H5FD_hdfs_fapl_t *fa) +H5Pset_fapl_hdfs(hid_t H5_ATTR_UNUSED fapl_id, H5FD_hdfs_fapl_t H5_ATTR_UNUSED *fa) { herr_t ret_value = FAIL; diff --git a/src/H5FDhdfs.h b/src/H5FDhdfs.h index 219d0acdfa8..61ae81fec31 100644 --- a/src/H5FDhdfs.h +++ b/src/H5FDhdfs.h @@ -1,15 +1,14 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Read-Only HDFS Virtual File Driver (VFD) * - * Copyright (c) 2018, The HDF Group. * + * Copyright by The HDF Group. * * * * All rights reserved. * * * - * NOTICE: * - * All information contained herein is, and remains, the property of The HDF * - * Group. The intellectual and technical concepts contained herein are * - * proprietary to The HDF Group. Dissemination of this information or * - * reproduction of this material is strictly forbidden unless prior written * - * permission is obtained from The HDF Group. * + * 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. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* diff --git a/src/H5FDint.c b/src/H5FDint.c index 25d77d174e1..264f17a8c0e 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 7214b75e15b..41481d60a44 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -44,7 +43,7 @@ static htri_t ignore_disabled_file_locks_s = FAIL; /* Driver-specific file access properties */ typedef struct H5FD_log_fapl_t { - char * logfile; /* Allocated log file name */ + char *logfile; /* Allocated log file name */ unsigned long long flags; /* Flags for logging behavior */ size_t buf_size; /* Size of buffers for track flavor and number of times each byte is accessed */ } H5FD_log_fapl_t; @@ -118,9 +117,9 @@ typedef struct H5FD_log_t { hbool_t fam_to_single; /* Fields for tracking I/O operations */ - unsigned char * nread; /* Number of reads from a file location */ - unsigned char * nwrite; /* Number of write to a file location */ - unsigned char * flavor; /* Flavor of information written to file location */ + unsigned char *nread; /* Number of reads from a file location */ + unsigned char *nwrite; /* Number of write to a file location */ + unsigned char *flavor; /* Flavor of information written to file location */ unsigned long long total_read_ops; /* Total number of read operations */ unsigned long long total_write_ops; /* Total number of write operations */ unsigned long long total_seek_ops; /* Total number of seek operations */ @@ -130,7 +129,7 @@ typedef struct H5FD_log_t { double total_seek_time; /* Total time spent in seek operations */ double total_truncate_time; /* Total time spent in truncate operations */ size_t iosize; /* Size of I/O information buffers */ - FILE * logfp; /* Log file pointer */ + FILE *logfp; /* Log file pointer */ H5FD_log_fapl_t fa; /* Driver-specific file access properties */ } H5FD_log_t; @@ -157,8 +156,8 @@ typedef struct H5FD_log_t { /* Prototypes */ static herr_t H5FD__log_term(void); -static void * H5FD__log_fapl_get(H5FD_t *file); -static void * H5FD__log_fapl_copy(const void *_old_fa); +static void *H5FD__log_fapl_get(H5FD_t *file); +static void *H5FD__log_fapl_copy(const void *_old_fa); static herr_t H5FD__log_fapl_free(void *_fa); static H5FD_t *H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD__log_close(H5FD_t *_file); @@ -228,7 +227,7 @@ H5FL_DEFINE_STATIC(H5FD_log_t); static herr_t H5FD__init_package(void) { - char * lock_env_var = NULL; /* Environment variable pointer */ + char *lock_env_var = NULL; /* Environment variable pointer */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -374,7 +373,7 @@ static void * H5FD__log_fapl_get(H5FD_t *_file) { H5FD_log_t *file = (H5FD_log_t *)_file; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -401,8 +400,8 @@ static void * H5FD__log_fapl_copy(const void *_old_fa) { const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t *)_old_fa; - H5FD_log_fapl_t * new_fa = NULL; /* New FAPL info */ - void * ret_value = NULL; /* Return value */ + H5FD_log_fapl_t *new_fa = NULL; /* New FAPL info */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -479,8 +478,8 @@ H5FD__log_fapl_free(void *_fa) static H5FD_t * H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_log_t * file = NULL; - H5P_genplist_t * plist; /* Property list */ + H5FD_log_t *file = NULL; + H5P_genplist_t *plist; /* Property list */ const H5FD_log_fapl_t *fa; /* File access property list information */ int fd = -1; /* File descriptor */ int o_flags; /* Flags for open() call */ @@ -490,7 +489,7 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5_timer_t open_timer; /* Timer for open() call */ H5_timer_t stat_timer; /* Timer for stat() call */ h5_stat_t sb; - H5FD_t * ret_value = NULL; /* Return value */ + H5FD_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1178,7 +1177,7 @@ static herr_t H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf /*out*/) { - H5FD_log_t * file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; H5_timer_t read_timer; /* Timer for read operation */ @@ -1393,7 +1392,7 @@ static herr_t H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { - H5FD_log_t * file = (H5FD_log_t *)_file; + H5FD_log_t *file = (H5FD_log_t *)_file; size_t orig_size = size; /* Save the original size for later */ haddr_t orig_addr = addr; H5_timer_t write_timer; /* Timer for write operation */ @@ -1559,7 +1558,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10zu bytes) (%s) Written", orig_addr, (orig_addr + orig_size) - 1, orig_size, flavors[type]); - /* Check if this is the first write into a "default" section, grabbed by the metadata agregation + /* Check if this is the first write into a "default" section, grabbed by the metadata aggregation * algorithm */ if (file->fa.flags & H5FD_LOG_FLAVOR) { if ((H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT) { diff --git a/src/H5FDlog.h b/src/H5FDlog.h index 969c09131cc..f83bbd25c03 100644 --- a/src/H5FDlog.h +++ b/src/H5FDlog.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDmirror.c b/src/H5FDmirror.c index f604eaf6dd3..c0efb96d10f 100644 --- a/src/H5FDmirror.c +++ b/src/H5FDmirror.c @@ -140,8 +140,8 @@ typedef struct H5FD_mirror_t { /* Prototypes */ static herr_t H5FD__mirror_term(void); -static void * H5FD__mirror_fapl_get(H5FD_t *_file); -static void * H5FD__mirror_fapl_copy(const void *_old_fa); +static void *H5FD__mirror_fapl_get(H5FD_t *_file); +static void *H5FD__mirror_fapl_copy(const void *_old_fa); static herr_t H5FD__mirror_fapl_free(void *_fa); static haddr_t H5FD__mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t type); static herr_t H5FD__mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr); @@ -244,11 +244,13 @@ H5FD_mirror_init(void) FUNC_ENTER_NOAPI(H5I_INVALID_HID) - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); - if (H5I_VFL != H5I_get_type(H5FD_MIRROR_g)) + if (H5I_VFL != H5I_get_type(H5FD_MIRROR_g)) { H5FD_MIRROR_g = H5FD_register(&H5FD_mirror_g, sizeof(H5FD_class_t), FALSE); - + if (H5I_INVALID_HID == H5FD_MIRROR_g) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register mirror"); + } ret_value = H5FD_MIRROR_g; done: @@ -266,12 +268,12 @@ H5FD_mirror_init(void) static herr_t H5FD__mirror_term(void) { - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Reset VFL ID */ H5FD_MIRROR_g = 0; - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__mirror_term() */ @@ -335,9 +337,9 @@ H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *_buf) /* --------------------------------------------------------------------------- * Function: is_host_little_endian * - * Purpose: Determine whether the host machine is is little-endian. + * Purpose: Determine whether the host machine is little-endian. * - * Store an intger with a known value, re-map the memory to a + * Store an integer with a known value, re-map the memory to a * character array, and inspect the array's contents. * * Return: The number of bytes written to the buffer (8). @@ -1120,14 +1122,14 @@ H5FD_mirror_xmit_is_xmit(const H5FD_mirror_xmit_t *xmit) static herr_t H5FD__mirror_verify_reply(H5FD_mirror_t *file) { - unsigned char * xmit_buf = NULL; + unsigned char *xmit_buf = NULL; struct H5FD_mirror_xmit_reply_t reply; ssize_t read_ret = 0; herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); HDassert(file && file->sock_fd); @@ -1166,7 +1168,7 @@ H5FD__mirror_verify_reply(H5FD_mirror_t *file) /* ------------------------------------------------------------------------- * Function: H5FD__mirror_fapl_get * - * Purpose: Get the file access propety list which could be used to create + * Purpose: Get the file access property list which could be used to create * an identical file. * * Return: Success: pointer to the new file access property list value. @@ -1176,13 +1178,13 @@ H5FD__mirror_verify_reply(H5FD_mirror_t *file) static void * H5FD__mirror_fapl_get(H5FD_t *_file) { - H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; H5FD_mirror_fapl_t *fa = NULL; - void * ret_value = NULL; + void *ret_value = NULL; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); fa = (H5FD_mirror_fapl_t *)H5MM_calloc(sizeof(H5FD_mirror_fapl_t)); if (NULL == fa) @@ -1213,12 +1215,12 @@ static void * H5FD__mirror_fapl_copy(const void *_old_fa) { const H5FD_mirror_fapl_t *old_fa = (const H5FD_mirror_fapl_t *)_old_fa; - H5FD_mirror_fapl_t * new_fa = NULL; - void * ret_value = NULL; + H5FD_mirror_fapl_t *new_fa = NULL; + void *ret_value = NULL; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); new_fa = (H5FD_mirror_fapl_t *)H5MM_malloc(sizeof(H5FD_mirror_fapl_t)); if (new_fa == NULL) @@ -1248,9 +1250,9 @@ H5FD__mirror_fapl_free(void *_fa) { H5FD_mirror_fapl_t *fa = (H5FD_mirror_fapl_t *)_fa; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); /* sanity check */ HDassert(fa != NULL); @@ -1275,13 +1277,13 @@ herr_t H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_dst) { const H5FD_mirror_fapl_t *fa_src = NULL; - H5P_genplist_t * plist = NULL; + H5P_genplist_t *plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", fapl_id, fa_dst); - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); if (NULL == fa_dst) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_dst is NULL"); @@ -1322,7 +1324,7 @@ H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", fapl_id, fa); - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS); if (NULL == plist) @@ -1360,15 +1362,15 @@ H5FD__mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad int live_socket = -1; struct sockaddr_in target_addr; socklen_t addr_size; - unsigned char * xmit_buf = NULL; + unsigned char *xmit_buf = NULL; H5FD_mirror_fapl_t fa; - H5FD_mirror_t * file = NULL; + H5FD_mirror_t *file = NULL; H5FD_mirror_xmit_open_t *open_xmit = NULL; - H5FD_t * ret_value = NULL; + H5FD_t *ret_value = NULL; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); /* --------------- */ /* Check arguments */ @@ -1491,9 +1493,9 @@ H5FD__mirror_close(H5FD_t *_file) int xmit_encoded = 0; /* monitor point of failure */ herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); /* Sanity check */ HDassert(file); @@ -1563,12 +1565,12 @@ H5FD__mirror_close(H5FD_t *_file) static herr_t H5FD__mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags) { - FUNC_ENTER_STATIC_NOERR; + FUNC_ENTER_PACKAGE_NOERR; - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); /* Notice: the Mirror VFD Writer currently uses only the Sec2 driver as - * the underying driver -- as such, the Mirror VFD implementation copies + * the underlying driver -- as such, the Mirror VFD implementation copies * the Sec2 feature flags as its own. * * File pointer is always NULL/unused -- the H5FD_FEAT_IGNORE_DRVRINFO flag @@ -1600,9 +1602,9 @@ H5FD__mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_mirror_t *file = (const H5FD_mirror_t *)_file; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); HDassert(file); @@ -1623,13 +1625,13 @@ static herr_t H5FD__mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) { H5FD_mirror_xmit_eoa_t xmit_eoa; - unsigned char * xmit_buf = NULL; - H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + unsigned char *xmit_buf = NULL; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); HDassert(file); @@ -1682,9 +1684,9 @@ H5FD__mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type) { const H5FD_mirror_t *file = (const H5FD_mirror_t *)_file; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); HDassert(file); @@ -1703,9 +1705,9 @@ static herr_t H5FD__mirror_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id, haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf) { - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); FUNC_LEAVE_NOAPI(FAIL) } /* end H5FD__mirror_read() */ @@ -1732,13 +1734,13 @@ H5FD__mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf) { H5FD_mirror_xmit_write_t xmit_write; - unsigned char * xmit_buf = NULL; - H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + unsigned char *xmit_buf = NULL; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); HDassert(file); HDassert(buf); @@ -1799,9 +1801,9 @@ H5FD__mirror_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_AT H5FD_mirror_t *file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); file->xmit.xmit_count = (file->xmit_i)++; file->xmit.op = H5FD_MIRROR_OP_TRUNCATE; @@ -1843,13 +1845,13 @@ static herr_t H5FD__mirror_lock(H5FD_t *_file, hbool_t rw) { H5FD_mirror_xmit_lock_t xmit_lock; - unsigned char * xmit_buf = NULL; - H5FD_mirror_t * file = (H5FD_mirror_t *)_file; + unsigned char *xmit_buf = NULL; + H5FD_mirror_t *file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); file->xmit.xmit_count = (file->xmit_i)++; file->xmit.op = H5FD_MIRROR_OP_LOCK; @@ -1894,9 +1896,9 @@ H5FD__mirror_unlock(H5FD_t *_file) H5FD_mirror_t *file = (H5FD_mirror_t *)_file; herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - LOG_OP_CALL(FUNC); + LOG_OP_CALL(__func__); file->xmit.xmit_count = (file->xmit_i)++; file->xmit.op = H5FD_MIRROR_OP_UNLOCK; diff --git a/src/H5FDmirror.h b/src/H5FDmirror.h index 49e24c1b0f3..0db8b1314ff 100644 --- a/src/H5FDmirror.h +++ b/src/H5FDmirror.h @@ -33,7 +33,7 @@ extern "C" { /* --------------------------------------------------------------------------- * Structure: H5FD_mirror_fapl_t * - * Used to pass configuraiton information to the Mirror VFD. + * Used to pass configuration information to the Mirror VFD. * Populate components as appropriate and pass structure pointer to * `H5Pset_fapl_mirror()`. * diff --git a/src/H5FDmirror_priv.h b/src/H5FDmirror_priv.h index 21de97b78a2..f647c21c497 100644 --- a/src/H5FDmirror_priv.h +++ b/src/H5FDmirror_priv.h @@ -28,10 +28,10 @@ extern "C" { * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -/* The maximum allowed size for a receiving buffer when accepting bytes to +/* Define the maximum allowed size for a receiving buffer when accepting bytes to * write. Writes larger than this size are performed by multiple accept-write * steps by the Writer. */ -#define H5FD_MIRROR_DATA_BUFFER_MAX H5_GB /* 1 Gigabyte */ +#define H5FD_MIRROR_DATA_BUFFER_MAX (1024 * 1024 * 1024) /* 1 Gigabyte */ #define H5FD_MIRROR_XMIT_CURR_VERSION 1 #define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B @@ -80,7 +80,7 @@ extern "C" { * * `magic` (uint32_t) * A "unique" number identifying the structure and endianness of - * transmitting maching. + * transmitting machine. * Must be set to H5FD_MIRROR_XMIT_MAGIC native to the VFD "sender". * * `version` (uint8_t) @@ -214,13 +214,13 @@ typedef struct H5FD_mirror_xmit_open_t { * * `status` (uint32_t) * Number indicating whether the command was successful or if an - * occured. + * occurred. * Allowed values are H5FD_MIRROR_STATUS_OK and * H5FD_MIRROR_STATUS_ERROR. * * `message` (char[]) * Error message. Populated if and only if there was a problem. - * It is possible that a message may reach the end of the alloted + * It is possible that a message may reach the end of the allotted * space without a NULL terminator -- the onus is on the programmer to * handle this situation. * diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index 048b8f3635f..b20f1404b5f 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDmpi.h b/src/H5FDmpi.h index cf493015a04..fa3862be405 100644 --- a/src/H5FDmpi.h +++ b/src/H5FDmpi.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index c0b14ce3b6a..e783eec935d 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -73,7 +72,7 @@ typedef struct H5FD_mpio_t { /* Callbacks */ static herr_t H5FD__mpio_term(void); -static H5FD_t * H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +static H5FD_t *H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD__mpio_close(H5FD_t *_file); static herr_t H5FD__mpio_query(const H5FD_t *_f1, unsigned long *flags); static haddr_t H5FD__mpio_get_eoa(const H5FD_t *_file, H5FD_mem_t type); @@ -217,6 +216,41 @@ H5FD__mpio_parse_debug_str(const char *s) FUNC_LEAVE_NOAPI_VOID } /* end H5FD__mpio_parse_debug_str() */ + +/*--------------------------------------------------------------------------- + * Function: H5FD__mem_t_to_str + * + * Purpose: Returns a string representing the enum value in an H5FD_mem_t + * enum + * + * Returns: H5FD_mem_t enum value string + * + *--------------------------------------------------------------------------- + */ +static const char * +H5FD__mem_t_to_str(H5FD_mem_t mem_type) +{ + switch (mem_type) { + case H5FD_MEM_NOLIST: + return "H5FD_MEM_NOLIST"; + case H5FD_MEM_DEFAULT: + return "H5FD_MEM_DEFAULT"; + case H5FD_MEM_SUPER: + return "H5FD_MEM_SUPER"; + case H5FD_MEM_BTREE: + return "H5FD_MEM_BTREE"; + case H5FD_MEM_DRAW: + return "H5FD_MEM_DRAW"; + case H5FD_MEM_GHEAP: + return "H5FD_MEM_GHEAP"; + case H5FD_MEM_LHEAP: + return "H5FD_MEM_LHEAP"; + case H5FD_MEM_OHDR: + return "H5FD_MEM_OHDR"; + default: + return "(Unknown)"; + } +} #endif /* H5FDmpio_DEBUG */ /*------------------------------------------------------------------------- @@ -784,7 +818,7 @@ H5FD_get_mpio_atomicity(H5FD_t *_file, hbool_t *flag) static H5FD_t * H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR_UNUSED maxaddr) { - H5FD_mpio_t * file = NULL; /* VFD File struct for new file */ + H5FD_mpio_t *file = NULL; /* VFD File struct for new file */ H5P_genplist_t *plist; /* Property list pointer */ MPI_Comm comm = MPI_COMM_NULL; /* MPI Communicator, from plist */ MPI_Info info = MPI_INFO_NULL; /* MPI Info, from plist */ @@ -860,14 +894,19 @@ H5FD__mpio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t H5_ATTR file->mpi_size = mpi_size; /* Only processor p0 will get the filesize and broadcast it. */ - if (mpi_rank == 0) + if (mpi_rank == 0) { + /* If MPI_File_get_size fails, broadcast file size as -1 to signal error */ if (MPI_SUCCESS != (mpi_code = MPI_File_get_size(fh, &file_size))) - HMPI_GOTO_ERROR(NULL, "MPI_File_get_size failed", mpi_code) + file_size = (MPI_Offset)-1; + } /* Broadcast file size */ if (MPI_SUCCESS != (mpi_code = MPI_Bcast(&file_size, (int)sizeof(MPI_Offset), MPI_BYTE, 0, comm))) HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code) + if (file_size < 0) + HMPI_GOTO_ERROR(NULL, "MPI_File_get_size failed", mpi_code) + /* Determine if the file should be truncated */ if (file_size && (flags & H5F_ACC_TRUNC)) { /* Truncate the file */ @@ -985,7 +1024,6 @@ H5FD__mpio_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags /* out *flags |= H5FD_FEAT_AGGREGATE_METADATA; /* OK to aggregate metadata allocations */ *flags |= H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */ *flags |= H5FD_FEAT_HAS_MPI; /* This driver uses MPI */ - *flags |= H5FD_FEAT_ALLOCATE_EARLY; /* Allocate space early instead of late */ *flags |= H5FD_FEAT_DEFAULT_VFD_COMPATIBLE; /* VFD creates a file which can be opened with the default VFD */ } /* end if */ @@ -1163,6 +1201,7 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU int n; #endif hbool_t use_view_this_time = FALSE; + hbool_t derived_type = FALSE; hbool_t rank0_bcast = FALSE; /* If read-with-rank0-and-bcast flag was used */ #ifdef H5FDmpio_DEBUG hbool_t H5FD_mpio_debug_t_flag = (H5FD_mpio_debug_flags_s[(int)'t'] && H5FD_MPIO_TRACE_THIS_RANK(file)); @@ -1190,8 +1229,6 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU if (H5FD_mpi_haddr_to_MPIOff(addr, &mpi_off /*out*/) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off") size_i = (int)size; - if ((hsize_t)size_i != size) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i") #ifdef H5FDmpio_DEBUG if (H5FD_mpio_debug_r_flag) @@ -1264,10 +1301,14 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU rank0_bcast = TRUE; /* Read on rank 0 Bcast to other ranks */ - if (file->mpi_rank == 0) + if (file->mpi_rank == 0) { + /* If MPI_File_read_at fails, push an error, but continue + * to participate in following MPI_Bcast */ if (MPI_SUCCESS != (mpi_code = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) + HMPI_DONE_ERROR(FAIL, "MPI_File_read_at failed", mpi_code) + } + if (MPI_SUCCESS != (mpi_code = MPI_Bcast(buf, size_i, buf_type, 0, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code) } /* end if */ @@ -1275,7 +1316,7 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU /* Perform collective read operation */ if (MPI_SUCCESS != (mpi_code = MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mpi_code) + HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mpi_code) } /* end if */ else { #ifdef H5FDmpio_DEBUG @@ -1297,6 +1338,21 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end if */ else { + if (size != (hsize_t)size_i) { + /* If HERE, then we need to work around the integer size limit + * of 2GB. The input size_t size variable cannot fit into an integer, + * but we can get around that limitation by creating a different datatype + * and then setting the integer size (or element count) to 1 when using + * the derived_type. + */ + + if (H5_mpio_create_large_type(size, 0, MPI_BYTE, &buf_type) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "can't create MPI-I/O datatype") + + derived_type = TRUE; + size_i = 1; + } + #ifdef H5FDmpio_DEBUG if (H5FD_mpio_debug_r_flag) HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); @@ -1311,11 +1367,21 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU if (!rank0_bcast || (rank0_bcast && file->mpi_rank == 0)) { /* How many bytes were actually read? */ #if MPI_VERSION >= 3 - if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_read))) + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements_x(&mpi_stat, buf_type, &bytes_read))) { #else - if (MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read))) + if (MPI_SUCCESS != (mpi_code = MPI_Get_elements(&mpi_stat, MPI_BYTE, &bytes_read))) { #endif - HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) + if (rank0_bcast && file->mpi_rank == 0) { + /* If MPI_Get_elements(_x) fails for a rank 0 bcast strategy, + * push an error, but continue to participate in the following + * MPI_Bcast. + */ + bytes_read = -1; + HMPI_DONE_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) + } + else + HMPI_GOTO_ERROR(FAIL, "MPI_Get_elements failed", mpi_code) + } } /* end if */ /* If the rank0-bcast feature was used, broadcast the # of bytes read to @@ -1343,6 +1409,12 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU if (bytes_read < 0 || bytes_read > io_size) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed") +#ifdef H5FDmpio_DEBUG + if (H5FD_mpio_debug_r_flag) + HDfprintf(stderr, "%s: (%d) mpi_off = %ld bytes_read = %lld type = %s\n", __func__, file->mpi_rank, + (long)mpi_off, bytes_read, H5FD__mem_t_to_str(type)); +#endif + /* * This gives us zeroes beyond end of physical MPI file. */ @@ -1350,6 +1422,9 @@ H5FD__mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNU HDmemset((char *)buf + bytes_read, 0, (size_t)n); done: + if (derived_type) + MPI_Type_free(&buf_type); + #ifdef H5FDmpio_DEBUG if (H5FD_mpio_debug_t_flag) HDfprintf(stderr, "%s: (%d) Leaving\n", FUNC, file->mpi_rank); @@ -1468,20 +1543,6 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h */ mpi_off = 0; } /* end if */ - else if (size != (hsize_t)size_i) { - /* If HERE, then we need to work around the integer size limit - * of 2GB. The input size_t size variable cannot fit into an integer, - * but we can get around that limitation by creating a different datatype - * and then setting the integer size (or element count) to 1 when using - * the derived_type. - */ - - if (H5_mpio_create_large_type(size, 0, MPI_BYTE, &buf_type) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "can't create MPI-I/O datatype") - - derived_type = TRUE; - size_i = 1; - } /* Write the data. */ if (use_view_this_time) { @@ -1527,6 +1588,21 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) } /* end if */ else { + if (size != (hsize_t)size_i) { + /* If HERE, then we need to work around the integer size limit + * of 2GB. The input size_t size variable cannot fit into an integer, + * but we can get around that limitation by creating a different datatype + * and then setting the integer size (or element count) to 1 when using + * the derived_type. + */ + + if (H5_mpio_create_large_type(size, 0, MPI_BYTE, &buf_type) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "can't create MPI-I/O datatype") + + derived_type = TRUE; + size_i = 1; + } + #ifdef H5FDmpio_DEBUG if (H5FD_mpio_debug_w_flag) HDfprintf(stderr, "%s: (%d) doing MPI independent IO\n", FUNC, file->mpi_rank); @@ -1560,6 +1636,12 @@ H5FD__mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, h if (bytes_written != io_size || bytes_written < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed") +#ifdef H5FDmpio_DEBUG + if (H5FD_mpio_debug_w_flag) + HDfprintf(stderr, "%s: (%d) mpi_off = %ld bytes_written = %lld type = %s\n", __func__, + file->mpi_rank, (long)mpi_off, bytes_written, H5FD__mem_t_to_str(type)); +#endif + /* Each process will keep track of its perceived EOF value locally, and * ultimately we will reduce this value to the maximum amongst all * processes, but until then keep the actual eof at HADDR_UNDEF just in @@ -1680,7 +1762,7 @@ H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR /* In principle, it is possible for the size returned by the * call to MPI_File_get_size() to depend on whether writes from - * all proceeses have completed at the time process 0 makes the + * all processes have completed at the time process 0 makes the * call. * * In practice, most (all?) truncate calls will come after a barrier @@ -1695,17 +1777,19 @@ H5FD__mpio_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code) /* Only processor p0 will get the filesize and broadcast it. */ - /* (Note that throwing an error here will cause non-rank 0 processes - * to hang in following Bcast. -QAK, 3/17/2018) - */ - if (0 == file->mpi_rank) + if (0 == file->mpi_rank) { + /* If MPI_File_get_size fails, broadcast file size as -1 to signal error */ if (MPI_SUCCESS != (mpi_code = MPI_File_get_size(file->f, &size))) - HMPI_GOTO_ERROR(FAIL, "MPI_File_get_size failed", mpi_code) + size = (MPI_Offset)-1; + } /* Broadcast file size */ if (MPI_SUCCESS != (mpi_code = MPI_Bcast(&size, (int)sizeof(MPI_Offset), MPI_BYTE, 0, file->comm))) HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code) + if (size < 0) + HMPI_GOTO_ERROR(FAIL, "MPI_File_get_size failed", mpi_code) + if (H5FD_mpi_haddr_to_MPIOff(file->eoa, &needed_eof) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset") diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index 8caf11c76cd..e2fb0a288a9 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -223,7 +222,7 @@ H5_DLL herr_t H5Pset_dxpl_mpio_collective_opt(hid_t dxpl_id, H5FD_mpio_collectiv * * Use of this function is optional. * - * \todo Add missing version information + * \since 1.8.0 * */ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt(hid_t dxpl_id, H5FD_mpio_chunk_opt_t opt_mode); @@ -247,7 +246,7 @@ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt(hid_t dxpl_id, H5FD_mpio_chunk_opt_t op * otherwise, a separate I/O process will be invoked for each chunk * (multi-chunk I/O). * - * \todo Add missing version information + * \since 1.8.0 * */ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt_num(hid_t dxpl_id, unsigned num_chunk_per_proc); @@ -272,7 +271,7 @@ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt_num(hid_t dxpl_id, unsigned num_chunk_p * percent_proc_per_chunk, the library will do collective I/O for this * chunk; otherwise, independent I/O will be done for the chunk. * - * \todo Add missing version information + * \since 1.8.0 * */ H5_DLL herr_t H5Pset_dxpl_mpio_chunk_opt_ratio(hid_t dxpl_id, unsigned percent_num_proc_per_chunk); diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 92266244f2f..68380cefbbd 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -81,7 +80,7 @@ static hid_t H5FD_MULTI_g = 0; typedef struct H5FD_multi_fapl_t { H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; /*memory usage map */ hid_t memb_fapl[H5FD_MEM_NTYPES]; /*member access properties */ - char * memb_name[H5FD_MEM_NTYPES]; /*name generators */ + char *memb_name[H5FD_MEM_NTYPES]; /*name generators */ haddr_t memb_addr[H5FD_MEM_NTYPES]; /*starting addr per member */ hbool_t relax; /*less stringent error checking */ } H5FD_multi_fapl_t; @@ -96,14 +95,14 @@ typedef struct H5FD_multi_t { H5FD_t pub; /*public stuff, must be first */ H5FD_multi_fapl_t fa; /*driver-specific file access properties */ haddr_t memb_next[H5FD_MEM_NTYPES]; /*addr of next member */ - H5FD_t * memb[H5FD_MEM_NTYPES]; /*member pointers */ + H5FD_t *memb[H5FD_MEM_NTYPES]; /*member pointers */ haddr_t memb_eoa[H5FD_MEM_NTYPES]; /*EOA for individual files, *end of allocated addresses. v1.6 library *have the EOA for the entire file. But it's *meaningless for MULTI file. We replaced it *with the EOAs for individual files */ unsigned flags; /*file open flags saved for debugging */ - char * name; /*name passed to H5Fopen or H5Fcreate */ + char *name; /*name passed to H5Fopen or H5Fcreate */ } H5FD_multi_t; /* Driver specific data transfer properties */ @@ -120,8 +119,8 @@ static herr_t H5FD_multi_term(void); static hsize_t H5FD_multi_sb_size(H5FD_t *file); static herr_t H5FD_multi_sb_encode(H5FD_t *file, char *name /*out*/, unsigned char *buf /*out*/); static herr_t H5FD_multi_sb_decode(H5FD_t *file, const char *name, const unsigned char *buf); -static void * H5FD_multi_fapl_get(H5FD_t *file); -static void * H5FD_multi_fapl_copy(const void *_old_fa); +static void *H5FD_multi_fapl_get(H5FD_t *file); +static void *H5FD_multi_fapl_copy(const void *_old_fa); static herr_t H5FD_multi_fapl_free(void *_fa); static H5FD_t *H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD_multi_close(H5FD_t *_file); @@ -401,7 +400,7 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_f H5FD_mem_t _memb_map[H5FD_MEM_NTYPES]; hid_t _memb_fapl[H5FD_MEM_NTYPES]; char _memb_name[H5FD_MEM_NTYPES][16]; - const char * _memb_name_ptrs[H5FD_MEM_NTYPES]; + const char *_memb_name_ptrs[H5FD_MEM_NTYPES]; haddr_t _memb_addr[H5FD_MEM_NTYPES]; static const char *letters = "Xsbrglo"; static const char *func = "H5FDset_fapl_multi"; /* Function Name for error reporting */ @@ -499,7 +498,7 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map /*out*/, hid_t *memb_fapl { const H5FD_multi_fapl_t *fa; H5FD_mem_t mt; - static const char * func = "H5FDget_fapl_multi"; /* Function Name for error reporting */ + static const char *func = "H5FDget_fapl_multi"; /* Function Name for error reporting */ /*NO TRACE*/ @@ -609,9 +608,9 @@ H5FD_multi_sb_size(H5FD_t *_file) static herr_t H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; haddr_t memb_eoa; - unsigned char * p; + unsigned char *p; size_t nseen; size_t i; H5FD_mem_t m; @@ -621,7 +620,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out H5Eclear2(H5E_DEFAULT); /* Name and version number */ - strncpy(name, "NCSAmulti", (size_t)8); + strncpy(name, "NCSAmult", (size_t)9); name[8] = '\0'; assert(7 == H5FD_MEM_NTYPES); @@ -657,7 +656,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out p = buf + 8 + nseen * 2 * 8; UNIQUE_MEMBERS (file->fa.memb_map, mt) { size_t n = strlen(file->fa.memb_name[mt]) + 1; - strncpy((char *)p, file->fa.memb_name[mt], n); + strcpy((char *)p, file->fa.memb_name[mt]); p += n; for (i = n; i % 8; i++) *p++ = '\0'; @@ -690,17 +689,17 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out static herr_t H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; char x[2 * H5FD_MEM_NTYPES * 8]; H5FD_mem_t map[H5FD_MEM_NTYPES]; int i; size_t nseen = 0; hbool_t map_changed = FALSE; hbool_t in_use[H5FD_MEM_NTYPES]; - const char * memb_name[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; haddr_t memb_eoa[H5FD_MEM_NTYPES]; - haddr_t * ap; + haddr_t *ap; static const char *func = "H5FD_multi_sb_decode"; /* Function Name for error reporting */ /* Clear the error stack */ @@ -864,9 +863,9 @@ static void * H5FD_multi_fapl_copy(const void *_old_fa) { const H5FD_multi_fapl_t *old_fa = (const H5FD_multi_fapl_t *)_old_fa; - H5FD_multi_fapl_t * new_fa = (H5FD_multi_fapl_t *)calloc(1, sizeof(H5FD_multi_fapl_t)); + H5FD_multi_fapl_t *new_fa = (H5FD_multi_fapl_t *)calloc(1, sizeof(H5FD_multi_fapl_t)); int nerrors = 0; - static const char * func = "H5FD_multi_fapl_copy"; /* Function Name for error reporting */ + static const char *func = "H5FD_multi_fapl_copy"; /* Function Name for error reporting */ assert(new_fa); @@ -961,11 +960,11 @@ H5FD_multi_fapl_free(void *_fa) static H5FD_t * H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_multi_t * file = NULL; + H5FD_multi_t *file = NULL; hid_t close_fapl = -1; const H5FD_multi_fapl_t *fa; H5FD_mem_t m; - static const char * func = "H5FD_multi_open"; /* Function Name for error reporting */ + static const char *func = "H5FD_multi_open"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1062,7 +1061,7 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr static herr_t H5FD_multi_close(H5FD_t *_file) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; int nerrors = 0; static const char *func = "H5FD_multi_close"; /* Function Name for error reporting */ @@ -1224,7 +1223,7 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) { const H5FD_multi_t *file = (const H5FD_multi_t *)_file; haddr_t eoa = 0; - static const char * func = "H5FD_multi_get_eoa"; /* Function Name for error reporting */ + static const char *func = "H5FD_multi_get_eoa"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1325,7 +1324,7 @@ H5FD_multi_get_eoa(const H5FD_t *_file, H5FD_mem_t type) static herr_t H5FD_multi_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t eoa) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; H5FD_mem_t mmt; herr_t status; static const char *func = "H5FD_multi_set_eoa"; /* Function Name for error reporting */ @@ -1391,7 +1390,7 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) { const H5FD_multi_t *file = (const H5FD_multi_t *)_file; haddr_t eof = 0; - static const char * func = "H5FD_multi_get_eof"; /* Function Name for error reporting */ + static const char *func = "H5FD_multi_get_eof"; /* Function Name for error reporting */ /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); @@ -1480,7 +1479,7 @@ H5FD_multi_get_eof(const H5FD_t *_file, H5FD_mem_t type) static herr_t H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; H5FD_mem_t type, mmt; static const char *func = "H5FD_multi_get_handle"; /* Function Name for error reporting */ @@ -1514,7 +1513,7 @@ H5FD_multi_get_handle(H5FD_t *_file, hid_t fapl, void **file_handle) static haddr_t H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; H5FD_mem_t mmt; haddr_t addr; static const char *func = "H5FD_multi_alloc"; /* Function Name for error reporting */ @@ -1695,7 +1694,7 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si static herr_t H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; H5FD_mem_t mt; int nerrors = 0; static const char *func = "H5FD_multi_flush"; /* Function Name for error reporting */ @@ -1768,7 +1767,7 @@ H5FD_multi_flush(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) static herr_t H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; H5FD_mem_t mt; int nerrors = 0; static const char *func = "H5FD_multi_truncate"; /* Function Name for error reporting */ @@ -1811,7 +1810,7 @@ H5FD_multi_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) static herr_t H5FD_multi_lock(H5FD_t *_file, hbool_t rw) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; int nerrors = 0; H5FD_mem_t out_mt = H5FD_MEM_DEFAULT; static const char *func = "H5FD_multi_unlock"; /* Function Name for error reporting */ @@ -1872,7 +1871,7 @@ H5FD_multi_lock(H5FD_t *_file, hbool_t rw) static herr_t H5FD_multi_unlock(H5FD_t *_file) { - H5FD_multi_t * file = (H5FD_multi_t *)_file; + H5FD_multi_t *file = (H5FD_multi_t *)_file; int nerrors = 0; static const char *func = "H5FD_multi_unlock"; /* Function Name for error reporting */ diff --git a/src/H5FDmulti.h b/src/H5FDmulti.h index 62cc9c8843f..f7b7c2e424d 100644 --- a/src/H5FDmulti.h +++ b/src/H5FDmulti.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDpkg.h b/src/H5FDpkg.h index acbaf88777b..893486db870 100644 --- a/src/H5FDpkg.h +++ b/src/H5FDpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 10d8069fa10..62d377f9670 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -66,7 +65,7 @@ typedef enum { /* Define structure to hold initial file image and other relevant information */ typedef struct { - void * buffer; + void *buffer; size_t size; H5FD_file_image_callbacks_t callbacks; } H5FD_file_image_info_t; @@ -104,19 +103,19 @@ typedef struct { /* Forward declarations for prototype arguments */ struct H5F_t; -H5_DLL int H5FD_term_interface(void); -H5_DLL herr_t H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr); +H5_DLL int H5FD_term_interface(void); +H5_DLL herr_t H5FD_locate_signature(H5FD_t *file, haddr_t *sig_addr); H5_DLL H5FD_class_t *H5FD_get_class(hid_t id); H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name /*out*/, uint8_t *buf); H5_DLL herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf); -H5_DLL void * H5FD_fapl_get(H5FD_t *file); +H5_DLL void *H5FD_fapl_get(H5FD_t *file); H5_DLL herr_t H5FD_free_driver_info(hid_t driver_id, const void *driver_info); H5_DLL hid_t H5FD_register(const void *cls, size_t size, hbool_t app_ref); -H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); -H5_DLL herr_t H5FD_close(H5FD_t *file); -H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); -H5_DLL herr_t H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/); +H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); +H5_DLL herr_t H5FD_close(H5FD_t *file); +H5_DLL int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2); +H5_DLL herr_t H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/); H5_DLL haddr_t H5FD_alloc(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); H5_DLL herr_t H5FD_free(H5FD_t *file, H5FD_mem_t type, struct H5F_t *f, haddr_t addr, hsize_t size); diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 36f37f0b58e..7464eb6fe21 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -18,8 +17,13 @@ #ifndef H5FDpublic_H #define H5FDpublic_H -#include "H5public.h" -#include "H5Fpublic.h" /*for H5F_close_degree_t */ +/* Public headers needed by this file */ +#include "H5public.h" /* Generic Functions */ +#include "H5Fpublic.h" /* Files */ + +/*****************/ +/* Public Macros */ +/*****************/ #define H5_HAVE_VFL 1 /*define a convenient app feature test*/ #define H5FD_VFD_DEFAULT 0 /* Default VFL driver value */ @@ -180,7 +184,7 @@ typedef enum H5F_mem_t H5FD_mem_t; /* * Defining H5FD_FEAT_DATA_SIEVE for a VFL driver means that * the library will attempt to cache raw data as it is read from/written to - * a file in a "data seive" buffer. See Rajeev Thakur's papers: + * a file in a "data sieve" buffer. See Rajeev Thakur's papers: * http://www.mcs.anl.gov/~thakur/papers/romio-coll.ps.gz * http://www.mcs.anl.gov/~thakur/papers/mpio-high-perf.ps.gz */ @@ -268,7 +272,7 @@ typedef struct H5FD_t H5FD_t; /* Class information for each file driver */ typedef struct H5FD_class_t { - const char * name; + const char *name; haddr_t maxaddr; H5F_close_degree_t fc_degree; herr_t (*terminate)(void); @@ -441,8 +445,8 @@ extern "C" { #endif /* Function prototypes */ -H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); -H5_DLL herr_t H5FDunregister(hid_t driver_id); +H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); +H5_DLL herr_t H5FDunregister(hid_t driver_id); H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); H5_DLL herr_t H5FDclose(H5FD_t *file); H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); @@ -462,7 +466,26 @@ H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); H5_DLL herr_t H5FDunlock(H5FD_t *file); -/* Allows querying a VFD ID for features before the file is opened */ +/** + * \ingroup H5FD + * + * \brief Allows querying a VFD ID for features before the file is opened + * + * \param[in] driver_id Virtual File Driver (VFD) ID + * \param[out] flags VFD flags supported + * + * \return \herr_t + * + * \details Queries a virtual file driver (VFD) for feature flags. Takes a + * VFD hid_t so it can be used before the file is opened. For example, + * this could be used to check if a VFD supports SWMR. + * + * \note The flags obtained here are just those of the base driver and + * do not take any configuration options (e.g., set via a fapl + * call) into consideration. + * + * \since 1.10.2 + */ H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags /*out*/); #ifdef __cplusplus diff --git a/src/H5FDros3.c b/src/H5FDros3.c index 2470c8b61d5..1314b1ca007 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -193,7 +193,7 @@ typedef struct H5FD_ros3_t { H5FD_t pub; H5FD_ros3_fapl_t fa; haddr_t eoa; - s3r_t * s3r_handle; + s3r_t *s3r_handle; #if ROS3_STATS ros3_statsbin meta[ROS3_STATS_BIN_COUNT + 1]; ros3_statsbin raw[ROS3_STATS_BIN_COUNT + 1]; @@ -215,8 +215,8 @@ typedef struct H5FD_ros3_t { /* Prototypes */ static herr_t H5FD__ros3_term(void); -static void * H5FD__ros3_fapl_get(H5FD_t *_file); -static void * H5FD__ros3_fapl_copy(const void *_old_fa); +static void *H5FD__ros3_fapl_get(H5FD_t *_file); +static void *H5FD__ros3_fapl_copy(const void *_old_fa); static herr_t H5FD__ros3_fapl_free(void *_fa); static H5FD_t *H5FD__ros3_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD__ros3_close(H5FD_t *_file); @@ -326,8 +326,12 @@ H5FD_ros3_init(void) HDfprintf(stdout, "H5FD_ros3_init() called.\n"); #endif - if (H5I_VFL != H5I_get_type(H5FD_ROS3_g)) + if (H5I_VFL != H5I_get_type(H5FD_ROS3_g)) { H5FD_ROS3_g = H5FD_register(&H5FD_ros3_g, sizeof(H5FD_class_t), FALSE); + if (H5I_INVALID_HID == H5FD_ROS3_g) { + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register ros3"); + } + } #if ROS3_STATS /* pre-compute statsbin boundaries @@ -376,7 +380,7 @@ H5FD__ros3_term(void) * Function: H5Pset_fapl_ros3 * * Purpose: Modify the file access property list to use the H5FD_ROS3 - * driver defined in this source file. All driver specfic + * driver defined in this source file. All driver specific * properties are passed in as a pointer to a suitably * initialized instance of H5FD_ros3_fapl_t * @@ -419,16 +423,16 @@ H5Pset_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa) * Function: H5FD__ros3_validate_config() * * Purpose: Test to see if the supplied instance of H5FD_ros3_fapl_t - * contains internally consistant data. Return SUCCEED if so, + * contains internally consistent data. Return SUCCEED if so, * and FAIL otherwise. * - * Note the difference between internally consistant and + * Note the difference between internally consistent and * correct. As we will have to try to access the target * object to determine whether the supplied data is correct, - * we will settle for internal consistancy at this point + * we will settle for internal consistency at this point * * Return: SUCCEED if instance of H5FD_ros3_fapl_t contains internally - * consistant data, FAIL otherwise. + * consistent data, FAIL otherwise. * * Programmer: Jacob Smith * 9/10/17 @@ -475,7 +479,7 @@ herr_t H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_dst) { const H5FD_ros3_fapl_t *fa_src = NULL; - H5P_genplist_t * plist = NULL; + H5P_genplist_t *plist = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -524,9 +528,9 @@ H5Pget_fapl_ros3(hid_t fapl_id, H5FD_ros3_fapl_t *fa_dst) static void * H5FD__ros3_fapl_get(H5FD_t *_file) { - H5FD_ros3_t * file = (H5FD_ros3_t *)_file; + H5FD_ros3_t *file = (H5FD_ros3_t *)_file; H5FD_ros3_fapl_t *fa = NULL; - void * ret_value = NULL; + void *ret_value = NULL; FUNC_ENTER_STATIC @@ -566,8 +570,8 @@ static void * H5FD__ros3_fapl_copy(const void *_old_fa) { const H5FD_ros3_fapl_t *old_fa = (const H5FD_ros3_fapl_t *)_old_fa; - H5FD_ros3_fapl_t * new_fa = NULL; - void * ret_value = NULL; + H5FD_ros3_fapl_t *new_fa = NULL; + void *ret_value = NULL; FUNC_ENTER_STATIC @@ -700,13 +704,13 @@ ros3_reset_stats(H5FD_ros3_t *file) static H5FD_t * H5FD__ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - H5FD_ros3_t * file = NULL; - struct tm * now = NULL; + H5FD_ros3_t *file = NULL; + struct tm *now = NULL; char iso8601now[ISO8601_SIZE]; unsigned char signing_key[SHA256_DIGEST_LENGTH]; - s3r_t * handle = NULL; + s3r_t *handle = NULL; H5FD_ros3_fapl_t fa; - H5FD_t * ret_value = NULL; + H5FD_t *ret_value = NULL; FUNC_ENTER_STATIC @@ -739,7 +743,7 @@ H5FD__ros3_open(const char *url, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (fa.authenticate == TRUE) { /* compute signing key (part of AWS/S3 REST API) * can be re-used by user/key for 7 days after creation. - * find way to re-use/share + * find way to reuse/share */ now = gmnow(); HDassert(now != NULL); @@ -849,7 +853,7 @@ static herr_t ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) { herr_t ret_value = SUCCEED; - parsed_url_t * purl = NULL; + parsed_url_t *purl = NULL; unsigned i = 0; unsigned long count_meta = 0; unsigned long count_raw = 0; @@ -861,7 +865,7 @@ ros3_fprint_stats(FILE *stream, const H5FD_ros3_t *file) unsigned long long max_raw = 0; unsigned long long bytes_raw = 0; unsigned long long bytes_meta = 0; - double re_dub = 0.0; /* re-usable double variable */ + double re_dub = 0.0; /* reusable double variable */ unsigned suffix_i = 0; const char suffixes[] = {' ', 'K', 'M', 'G', 'T', 'P'}; @@ -1156,8 +1160,8 @@ H5FD__ros3_close(H5FD_t H5_ATTR_UNUSED *_file) static int H5FD__ros3_cmp(const H5FD_t *_f1, const H5FD_t *_f2) { - const H5FD_ros3_t * f1 = (const H5FD_ros3_t *)_f1; - const H5FD_ros3_t * f2 = (const H5FD_ros3_t *)_f2; + const H5FD_ros3_t *f1 = (const H5FD_ros3_t *)_f1; + const H5FD_ros3_t *f2 = (const H5FD_ros3_t *)_f2; const parsed_url_t *purl1 = NULL; const parsed_url_t *purl2 = NULL; int ret_value = 0; diff --git a/src/H5FDs3comms.c b/src/H5FDs3comms.c index ee5b5ec67b0..aad7ff3e23b 100644 --- a/src/H5FDs3comms.c +++ b/src/H5FDs3comms.c @@ -81,7 +81,7 @@ */ struct s3r_datastruct { unsigned long magic; - char * data; + char *data; size_t size; }; #define S3COMMS_CALLBACK_DATASTRUCT_MAGIC 0x28c2b2ul @@ -209,11 +209,11 @@ herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) { size_t i = 0; - char * valuecpy = NULL; - char * namecpy = NULL; + char *valuecpy = NULL; + char *namecpy = NULL; size_t namelen = 0; - char * lowername = NULL; - char * nvcat = NULL; + char *lowername = NULL; + char *nvcat = NULL; hrb_node_t *node_ptr = NULL; hrb_node_t *new_node = NULL; hbool_t is_looking = TRUE; @@ -579,7 +579,7 @@ H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value) * * Headers list at `first_header` is not touched. * - * - Programmer should re-use or destroy `first_header` pointer + * - Programmer should reuse or destroy `first_header` pointer * (hrb_node_t *) as suits their purposes. * - Recommend fetching prior to destroy() * e.g., `reuse_node = hrb_to_die->first_header; destroy(hrb_to_die);` @@ -662,12 +662,12 @@ hrb_t * H5FD_s3comms_hrb_init_request(const char *_verb, const char *_resource, const char *_http_version) { hrb_t *request = NULL; - char * res = NULL; + char *res = NULL; size_t reslen = 0; hrb_t *ret_value = NULL; - char * verb = NULL; + char *verb = NULL; size_t verblen = 0; - char * vrsn = NULL; + char *vrsn = NULL; size_t vrsnlen = 0; FUNC_ENTER_NOAPI_NOINIT @@ -875,11 +875,11 @@ herr_t H5FD_s3comms_s3r_getsize(s3r_t *handle) { uintmax_t content_length = 0; - CURL * curlh = NULL; - char * end = NULL; - char * headerresponse = NULL; + CURL *curlh = NULL; + char *end = NULL; + char *headerresponse = NULL; struct s3r_datastruct sds = {S3COMMS_CALLBACK_DATASTRUCT_MAGIC, NULL, 0}; - char * start = NULL; + char *start = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT @@ -1026,10 +1026,10 @@ s3r_t * H5FD_s3comms_s3r_open(const char *url, const char *region, const char *id, const unsigned char *signing_key) { size_t tmplen = 0; - CURL * curlh = NULL; - s3r_t * handle = NULL; + CURL *curlh = NULL; + s3r_t *handle = NULL; parsed_url_t *purl = NULL; - s3r_t * ret_value = NULL; + s3r_t *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -1205,14 +1205,14 @@ H5FD_s3comms_s3r_open(const char *url, const char *region, const char *id, const herr_t H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest) { - CURL * curlh = NULL; + CURL *curlh = NULL; CURLcode p_status = CURLE_OK; struct curl_slist *curlheaders = NULL; - hrb_node_t * headers = NULL; - hrb_node_t * node = NULL; - struct tm * now = NULL; - char * rangebytesstr = NULL; - hrb_t * request = NULL; + hrb_node_t *headers = NULL; + hrb_node_t *node = NULL; + struct tm *now = NULL; + char *rangebytesstr = NULL; + hrb_t *request = NULL; int ret = 0; /* working variable to check */ /* return value of HDsnprintf */ struct s3r_datastruct *sds = NULL; @@ -1555,7 +1555,7 @@ struct tm * gmnow(void) { time_t now; - time_t * now_ptr = &now; + time_t *now_ptr = &now; struct tm *ret_value = NULL; /* Doctor assert, checks against error in time() */ @@ -1933,7 +1933,7 @@ H5FD__s3comms_load_aws_creds_from_file(FILE *file, const char *profile_name, cha unsigned buffer_i = 0; unsigned setting_i = 0; int found_setting = 0; - char * line_buffer = &(buffer[0]); + char *line_buffer = &(buffer[0]); FUNC_ENTER_STATIC @@ -2050,7 +2050,7 @@ H5FD_s3comms_load_aws_profile(const char *profile_name, char *key_id_out, char * char *aws_region_out) { herr_t ret_value = SUCCEED; - FILE * credfile = NULL; + FILE *credfile = NULL; char awspath[117]; char filepath[128]; int ret = 0; @@ -2196,8 +2196,8 @@ herr_t H5FD_s3comms_parse_url(const char *str, parsed_url_t **_purl) { parsed_url_t *purl = NULL; /* pointer to new structure */ - const char * tmpstr = NULL; /* working pointer in string */ - const char * curstr = str; /* "start" pointer in string */ + const char *tmpstr = NULL; /* working pointer in string */ + const char *curstr = str; /* "start" pointer in string */ long int len = 0; /* substring length */ long int urllen = 0; /* length of passed-in url string */ unsigned int i = 0; @@ -2527,7 +2527,7 @@ H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr * Create AWS4 "Signing Key" from secret key, AWS region, and timestamp. * * Sequentially runs HMAC_SHA256 on strings in specified order, - * generating re-usable checksum (according to documentation, valid for + * generating reusable checksum (according to documentation, valid for * 7 days from time given). * * `secret` is `access key id` for targeted service/bucket/resource. @@ -2559,7 +2559,7 @@ H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr herr_t H5FD_s3comms_signing_key(unsigned char *md, const char *secret, const char *region, const char *iso8601now) { - char * AWS4_secret = NULL; + char *AWS4_secret = NULL; size_t AWS4_secret_len = 0; unsigned char datekey[SHA256_DIGEST_LENGTH]; unsigned char dateregionkey[SHA256_DIGEST_LENGTH]; diff --git a/src/H5FDs3comms.h b/src/H5FDs3comms.h index da6a62d7bb7..4f006a953ec 100644 --- a/src/H5FDs3comms.h +++ b/src/H5FDs3comms.h @@ -179,7 +179,7 @@ * HTTP header fields, of particular use when composing an * "S3 Canonical Request" for authentication. * - * - The creation of a Canoncial Request involves: + * - The creation of a Canonical Request involves: * - convert field names to lower case * - sort by this lower-case name * - convert ": " name-value separator in HTTP string to ":" @@ -216,7 +216,7 @@ * * `magic` (unsigned long) * - * "unique" idenfier number for the structure type + * "unique" identifier number for the structure type * * `name` (char *) * @@ -249,10 +249,10 @@ */ typedef struct hrb_node_t { unsigned long magic; - char * name; - char * value; - char * cat; - char * lowername; + char *name; + char *value; + char *cat; + char *lowername; struct hrb_node_t *next; } hrb_node_t; #define S3COMMS_HRB_NODE_MAGIC 0x7F5757UL @@ -325,12 +325,12 @@ typedef struct hrb_node_t { */ typedef struct { unsigned long magic; - char * body; + char *body; size_t body_len; - hrb_node_t * first_header; - char * resource; - char * verb; - char * version; + hrb_node_t *first_header; + char *resource; + char *verb; + char *version; } hrb_t; #define S3COMMS_HRB_MAGIC 0x6DCC84UL @@ -388,11 +388,11 @@ typedef struct { */ typedef struct { unsigned long magic; - char * scheme; /* required */ - char * host; /* required */ - char * port; - char * path; - char * query; + char *scheme; /* required */ + char *host; /* required */ + char *port; + char *path; + char *query; } parsed_url_t; #define S3COMMS_PARSED_URL_MAGIC 0x21D0DFUL @@ -459,29 +459,29 @@ typedef struct { * * Pointer to NULL-terminated string for "secret" access id to S3 resource. * - * Requred to authenticate. + * Required to authenticate. * * `signing_key` (unsigned char *) * - * Pointer to `SHA256_DIGEST_LENGTH`-long string for "re-usable" signing + * Pointer to `SHA256_DIGEST_LENGTH`-long string for "reusable" signing * key, generated via * `HMAC-SHA256(HMAC-SHA256(HMAC-SHA256(HMAC-SHA256("AWS4", * ""), ""), "aws4_request")` * which may be re-used for several (up to seven (7)) days from creation? * Computed once upon file open. * - * Requred to authenticate. + * Required to authenticate. * *---------------------------------------------------------------------------- */ typedef struct { unsigned long magic; - CURL * curlhandle; + CURL *curlhandle; size_t filesize; - char * httpverb; - parsed_url_t * purl; - char * region; - char * secret_id; + char *httpverb; + parsed_url_t *purl; + char *region; + char *secret_id; unsigned char *signing_key; } s3r_t; diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 6fe12822559..1c5b63b4288 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -189,7 +188,7 @@ H5FL_DEFINE_STATIC(H5FD_sec2_t); static herr_t H5FD__init_package(void) { - char * lock_env_var = NULL; /* Environment variable pointer */ + char *lock_env_var = NULL; /* Environment variable pointer */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -322,7 +321,7 @@ H5FD__sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr #endif h5_stat_t sb; H5P_genplist_t *plist; /* Property list pointer */ - H5FD_t * ret_value = NULL; /* Return value */ + H5FD_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -549,7 +548,7 @@ H5FD__sec2_query(const H5FD_t *_file, unsigned long *flags /* out */) /* Set the VFL feature flags that this driver supports */ /* Notice: the Mirror VFD Writer currently uses only the Sec2 driver as - * the underying driver -- as such, the Mirror VFD implementation copies + * the underlying driver -- as such, the Mirror VFD implementation copies * these feature flags as its own. Any modifications made here must be * reflected in H5FDmirror.c * -- JOS 2020-01-13 diff --git a/src/H5FDsec2.h b/src/H5FDsec2.h index 541ac71b2ff..86bc4126004 100644 --- a/src/H5FDsec2.h +++ b/src/H5FDsec2.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -26,7 +25,21 @@ extern "C" { #endif -H5_DLL hid_t H5FD_sec2_init(void); +H5_DLL hid_t H5FD_sec2_init(void); +/** + * \ingroup FAPL + * + * \brief Sets the sec2 driver + * + * \fapl_id + * \returns \herr_t + * + * \details H5Pset_fapl_sec2() modifies the file access property list to use + * the sec2 driver, H5FDsec2. + * + * \since 1.4.0 + * + */ H5_DLL herr_t H5Pset_fapl_sec2(hid_t fapl_id); #ifdef __cplusplus diff --git a/src/H5FDspace.c b/src/H5FDspace.c index 339c413fd86..a6205e6267f 100644 --- a/src/H5FDspace.c +++ b/src/H5FDspace.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -148,7 +147,7 @@ H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr FUNC_ENTER_PACKAGE #ifdef H5FD_ALLOC_DEBUG - HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); + HDfprintf(stderr, "%s: type = %u, size = %" PRIuHSIZE "\n", FUNC, (unsigned)type, size); #endif /* H5FD_ALLOC_DEBUG */ /* check args */ @@ -211,7 +210,7 @@ H5FD__alloc_real(H5FD_t *file, H5FD_mem_t type, hsize_t size, haddr_t *frag_addr done: #ifdef H5FD_ALLOC_DEBUG - HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); + HDfprintf(stderr, "%s: ret_value = %" PRIuHADDR "\n", FUNC, ret_value); #endif /* H5FD_ALLOC_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__alloc_real() */ @@ -287,7 +286,8 @@ H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size) HDassert(size > 0); #ifdef H5FD_ALLOC_DEBUG - HDfprintf(stderr, "%s: type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)type, addr, size); + HDfprintf(stderr, "%s: type = %u, addr = %" PRIuHADDR ", size = %" PRIuHSIZE "\n", FUNC, (unsigned)type, + addr, size); #endif /* H5FD_ALLOC_DEBUG */ /* Sanity checking */ @@ -317,11 +317,11 @@ H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size) eoa = file->cls->get_eoa(file, type); #ifdef H5FD_ALLOC_DEBUG - HDfprintf(stderr, "%s: eoa = %a\n", FUNC, eoa); + HDfprintf(stderr, "%s: eoa = %" PRIuHADDR "\n", FUNC, eoa); #endif /* H5FD_ALLOC_DEBUG */ if (eoa == (addr + size)) { #ifdef H5FD_ALLOC_DEBUG - HDfprintf(stderr, "%s: Reducing file size to = %a\n", FUNC, addr); + HDfprintf(stderr, "%s: Reducing file size to = %" PRIuHADDR "\n", FUNC, addr); #endif /* H5FD_ALLOC_DEBUG */ if (file->cls->set_eoa(file, type, addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "set end of space allocation request failed") @@ -330,8 +330,8 @@ H5FD__free_real(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size) else { /* leak memory */ #ifdef H5FD_ALLOC_DEBUG - HDfprintf(stderr, "%s: LEAKED MEMORY!!! type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)type, - addr, size); + HDfprintf(stderr, "%s: LEAKED MEMORY!!! type = %u, addr = %" PRIuHADDR ", size = %" PRIuHSIZE "\n", + FUNC, (unsigned)type, addr, size); #endif /* H5FD_ALLOC_DEBUG */ } /* end else */ diff --git a/src/H5FDsplitter.c b/src/H5FDsplitter.c index 93ba154217d..722a1a302b1 100644 --- a/src/H5FDsplitter.c +++ b/src/H5FDsplitter.c @@ -46,9 +46,9 @@ typedef struct H5FD_splitter_t { H5FD_t pub; /* public stuff, must be first */ unsigned version; /* version of the H5FD_splitter_vfd_config_t structure used */ H5FD_splitter_fapl_t fa; /* driver-specific file access properties */ - H5FD_t * rw_file; /* pointer of R/W channel */ - H5FD_t * wo_file; /* pointer of W/O channel */ - FILE * logfp; /* Log file pointer */ + H5FD_t *rw_file; /* pointer of R/W channel */ + H5FD_t *wo_file; /* pointer of W/O channel */ + FILE *logfp; /* Log file pointer */ } H5FD_splitter_t; /* @@ -107,8 +107,8 @@ static herr_t H5FD__splitter_term(void); static hsize_t H5FD__splitter_sb_size(H5FD_t *_file); static herr_t H5FD__splitter_sb_encode(H5FD_t *_file, char *name /*out*/, unsigned char *buf /*out*/); static herr_t H5FD__splitter_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf); -static void * H5FD__splitter_fapl_get(H5FD_t *_file); -static void * H5FD__splitter_fapl_copy(const void *_old_fa); +static void *H5FD__splitter_fapl_get(H5FD_t *_file); +static void *H5FD__splitter_fapl_copy(const void *_old_fa); static herr_t H5FD__splitter_fapl_free(void *_fapl); static H5FD_t *H5FD__splitter_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); static herr_t H5FD__splitter_close(H5FD_t *_file); @@ -293,7 +293,7 @@ herr_t H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) { H5FD_splitter_fapl_t *info = NULL; - H5P_genplist_t * plist_ptr = NULL; + H5P_genplist_t *plist_ptr = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -315,9 +315,9 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) * determining attribute. */ if (H5P_DEFAULT != vfd_config->wo_fapl_id) { - H5FD_class_t * wo_driver = NULL; + H5FD_class_t *wo_driver = NULL; H5FD_driver_prop_t wo_driver_prop; - H5P_genplist_t * wo_plist_ptr = NULL; + H5P_genplist_t *wo_plist_ptr = NULL; unsigned long wo_driver_flags = 0; wo_plist_ptr = (H5P_genplist_t *)H5I_object(vfd_config->wo_fapl_id); @@ -339,10 +339,12 @@ H5Pset_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *vfd_config) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate file access property list struct") info->ignore_wo_errs = vfd_config->ignore_wo_errs; - HDstrncpy(info->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX); - HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX); - info->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ - info->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ + HDstrncpy(info->wo_path, vfd_config->wo_path, H5FD_SPLITTER_PATH_MAX + 1); + info->wo_path[H5FD_SPLITTER_PATH_MAX] = '\0'; + HDstrncpy(info->log_file_path, vfd_config->log_file_path, H5FD_SPLITTER_PATH_MAX + 1); + info->log_file_path[H5FD_SPLITTER_PATH_MAX] = '\0'; + info->rw_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ + info->wo_fapl_id = H5P_FILE_ACCESS_DEFAULT; /* pre-set value */ /* Set non-default channel FAPL IDs in splitter configuration info */ if (H5P_DEFAULT != vfd_config->rw_fapl_id) { @@ -381,7 +383,7 @@ herr_t H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config) { const H5FD_splitter_fapl_t *fapl_ptr = NULL; - H5P_genplist_t * plist_ptr = NULL; + H5P_genplist_t *plist_ptr = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -411,8 +413,8 @@ H5Pget_fapl_splitter(hid_t fapl_id, H5FD_splitter_vfd_config_t *config) if (NULL == (fapl_ptr = (const H5FD_splitter_fapl_t *)H5P_peek_driver_info(plist_ptr))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unable to get specific-driver info") - HDstrncpy(config->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); - HDstrncpy(config->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(config->wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX + 1); + HDstrncpy(config->log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX + 1); config->ignore_wo_errs = fapl_ptr->ignore_wo_errs; /* Copy R/W and W/O FAPLs */ @@ -511,7 +513,7 @@ H5FD__splitter_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr const void *buf) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - H5P_genplist_t * plist_ptr = NULL; + H5P_genplist_t *plist_ptr = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -548,7 +550,7 @@ static void * H5FD__splitter_fapl_get(H5FD_t *_file) { H5FD_splitter_t *file = (H5FD_splitter_t *)_file; - void * ret_value = NULL; + void *ret_value = NULL; FUNC_ENTER_STATIC_NOERR @@ -572,8 +574,8 @@ static void * H5FD__splitter_fapl_copy(const void *_old_fa) { const H5FD_splitter_fapl_t *old_fa_ptr = (const H5FD_splitter_fapl_t *)_old_fa; - H5FD_splitter_fapl_t * new_fa_ptr = NULL; - void * ret_value = NULL; + H5FD_splitter_fapl_t *new_fa_ptr = NULL; + void *ret_value = NULL; FUNC_ENTER_STATIC @@ -586,8 +588,8 @@ H5FD__splitter_fapl_copy(const void *_old_fa) HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, NULL, "unable to allocate log file FAPL") H5MM_memcpy(new_fa_ptr, old_fa_ptr, sizeof(H5FD_splitter_fapl_t)); - HDstrncpy(new_fa_ptr->wo_path, old_fa_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); - HDstrncpy(new_fa_ptr->log_file_path, old_fa_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(new_fa_ptr->wo_path, old_fa_ptr->wo_path, H5FD_SPLITTER_PATH_MAX + 1); + HDstrncpy(new_fa_ptr->log_file_path, old_fa_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX + 1); /* Copy R/W and W/O FAPLs */ if (H5FD__copy_plist(old_fa_ptr->rw_fapl_id, &(new_fa_ptr->rw_fapl_id)) < 0) @@ -652,10 +654,10 @@ H5FD__splitter_fapl_free(void *_fapl) static H5FD_t * H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, haddr_t maxaddr) { - H5FD_splitter_t * file_ptr = NULL; /* Splitter VFD info */ + H5FD_splitter_t *file_ptr = NULL; /* Splitter VFD info */ const H5FD_splitter_fapl_t *fapl_ptr = NULL; /* Driver-specific property list */ - H5P_genplist_t * plist_ptr = NULL; - H5FD_t * ret_value = NULL; + H5P_genplist_t *plist_ptr = NULL; + H5FD_t *ret_value = NULL; FUNC_ENTER_STATIC @@ -687,8 +689,8 @@ H5FD__splitter_open(const char *name, unsigned flags, hid_t splitter_fapl_id, ha HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get VFL driver info") /* Copy simpler info */ - HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX); - HDstrncpy(file_ptr->fa.log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX); + HDstrncpy(file_ptr->fa.wo_path, fapl_ptr->wo_path, H5FD_SPLITTER_PATH_MAX + 1); + HDstrncpy(file_ptr->fa.log_file_path, fapl_ptr->log_file_path, H5FD_SPLITTER_PATH_MAX + 1); file_ptr->fa.ignore_wo_errs = fapl_ptr->ignore_wo_errs; /* Copy R/W and W/O channel FAPLs. */ @@ -1297,7 +1299,7 @@ H5FD__splitter_log_error(const H5FD_splitter_t *file, const char *atfunc, const if (file->logfp != NULL) { size_t size; - char * s; + char *s; size = HDstrlen(atfunc) + HDstrlen(msg) + 3; /* ':', ' ', '\n' */ s = (char *)H5MM_malloc(sizeof(char) * (size + 1)); diff --git a/src/H5FDsplitter.h b/src/H5FDsplitter.h index ee6e7c53a7c..b42458286c0 100644 --- a/src/H5FDsplitter.h +++ b/src/H5FDsplitter.h @@ -34,7 +34,7 @@ * Structure: H5FD_spliiter_vfd_config_t * * One-stop shopping for configuring a Splitter VFD (rather than many - * paramaters passed into H5Pset/get functions). + * parameters passed into H5Pset/get functions). * * magic (int32_t) * Semi-unique number, used to sanity-check that a given pointer is diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 3d0332fcc54..24f4de1d1ac 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -79,7 +78,7 @@ typedef enum { */ typedef struct H5FD_stdio_t { H5FD_t pub; /* public stuff, must be first */ - FILE * fp; /* the file handle */ + FILE *fp; /* the file handle */ int fd; /* file descriptor (for truncate) */ haddr_t eoa; /* end of allocated region */ haddr_t eof; /* end of file; current file size */ @@ -332,9 +331,9 @@ H5Pset_fapl_stdio(hid_t fapl_id) static H5FD_t * H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - FILE * f = NULL; + FILE *f = NULL; unsigned write_access = 0; /* File opened with write access? */ - H5FD_stdio_t * file = NULL; + H5FD_stdio_t *file = NULL; static const char *func = "H5FD_stdio_open"; /* Function Name for error reporting */ #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; @@ -489,7 +488,7 @@ H5FD_stdio_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr static herr_t H5FD_stdio_close(H5FD_t *_file) { - H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; static const char *func = "H5FD_stdio_close"; /* Function Name for error reporting */ /* Clear the error stack */ @@ -758,7 +757,7 @@ H5FD_stdio_get_eof(const H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type) static herr_t H5FD_stdio_get_handle(H5FD_t *_file, hid_t /*UNUSED*/ fapl, void **file_handle) { - H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; static const char *func = "H5FD_stdio_get_handle"; /* Function Name for error reporting */ /* Quiet the compiler */ @@ -796,7 +795,7 @@ static herr_t H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, haddr_t addr, size_t size, void /*OUT*/ *buf) { - H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; static const char *func = "H5FD_stdio_read"; /* Function Name for error reporting */ /* Quiet the compiler */ @@ -899,7 +898,7 @@ static herr_t H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxpl_id, haddr_t addr, size_t size, const void *buf) { - H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; static const char *func = "H5FD_stdio_write"; /* Function Name for error reporting */ /* Quiet the compiler */ @@ -986,7 +985,7 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t /*UNUSED*/ type, hid_t /*UNUSED*/ dxp static herr_t H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t closing) { - H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; static const char *func = "H5FD_stdio_flush"; /* Function Name for error reporting */ /* Quiet the compiler */ @@ -1030,7 +1029,7 @@ H5FD_stdio_flush(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t closing) static herr_t H5FD_stdio_truncate(H5FD_t *_file, hid_t /*UNUSED*/ dxpl_id, hbool_t /*UNUSED*/ closing) { - H5FD_stdio_t * file = (H5FD_stdio_t *)_file; + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; static const char *func = "H5FD_stdio_truncate"; /* Function Name for error reporting */ /* Quiet the compiler */ @@ -1121,7 +1120,7 @@ static herr_t H5FD_stdio_lock(H5FD_t *_file, hbool_t rw) { #ifdef H5_HAVE_FLOCK - H5FD_stdio_t * file = (H5FD_stdio_t *)_file; /* VFD file struct */ + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; /* VFD file struct */ int lock_flags; /* file locking flags */ static const char *func = "H5FD_stdio_lock"; /* Function Name for error reporting */ @@ -1172,7 +1171,7 @@ static herr_t H5FD_stdio_unlock(H5FD_t *_file) { #ifdef H5_HAVE_FLOCK - H5FD_stdio_t * file = (H5FD_stdio_t *)_file; /* VFD file struct */ + H5FD_stdio_t *file = (H5FD_stdio_t *)_file; /* VFD file struct */ static const char *func = "H5FD_stdio_unlock"; /* Function Name for error reporting */ /* Clear the error stack */ diff --git a/src/H5FDstdio.h b/src/H5FDstdio.h index 9db92edf834..215d3407586 100644 --- a/src/H5FDstdio.h +++ b/src/H5FDstdio.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -38,7 +37,7 @@ H5_DLL hid_t H5FD_stdio_init(void); * \returns \herr_t * * \details H5Pset_fapl_stdio() modifies the file access property list to use - * the standard I/O driver, H5FDstdio(). + * the standard I/O driver, H5FDstdio. * * \since 1.4.0 * diff --git a/src/H5FDtest.c b/src/H5FDtest.c index 4a907e554f4..87d24b64f75 100644 --- a/src/H5FDtest.c +++ b/src/H5FDtest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -72,8 +71,6 @@ * VFD feature flags (which do not exist until the driver * is instantiated). * - * See test/Makefile.am for a list of the VFD strings. - * * This function is only intended for use in the test code. * * Return: TRUE (1) if the VFD supports SWMR I/O or vfd_name is @@ -83,10 +80,6 @@ * * This function cannot fail at this time so there is no * error return value. - * - * Programmer: Dana Robinson - * Fall 2014 - * *------------------------------------------------------------------------- */ hbool_t diff --git a/src/H5FDwindows.c b/src/H5FDwindows.c index 6ce33a746c2..83b408c7fcb 100644 --- a/src/H5FDwindows.c +++ b/src/H5FDwindows.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FDwindows.h b/src/H5FDwindows.h index 79e73b66e1b..a43e16fc78d 100644 --- a/src/H5FDwindows.h +++ b/src/H5FDwindows.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FL.c b/src/H5FL.c index 95188d5bb3d..f42e90dd1dd 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -54,7 +53,7 @@ static size_t H5FL_fac_lst_mem_lim = /* A garbage collection node for regular free lists */ typedef struct H5FL_reg_gc_node_t { - H5FL_reg_head_t * list; /* Pointer to the head of the list to garbage collect */ + H5FL_reg_head_t *list; /* Pointer to the head of the list to garbage collect */ struct H5FL_reg_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_reg_gc_node_t; @@ -69,7 +68,7 @@ static H5FL_reg_gc_list_t H5FL_reg_gc_head = {0, NULL}; /* A garbage collection node for array free lists */ typedef struct H5FL_gc_arr_node_t { - H5FL_arr_head_t * list; /* Pointer to the head of the list to garbage collect */ + H5FL_arr_head_t *list; /* Pointer to the head of the list to garbage collect */ struct H5FL_gc_arr_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_gc_arr_node_t; @@ -84,7 +83,7 @@ static H5FL_gc_arr_list_t H5FL_arr_gc_head = {0, NULL}; /* A garbage collection node for blocks */ typedef struct H5FL_blk_gc_node_t { - H5FL_blk_head_t * pq; /* Pointer to the head of the PQ to garbage collect */ + H5FL_blk_head_t *pq; /* Pointer to the head of the PQ to garbage collect */ struct H5FL_blk_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ } H5FL_blk_gc_node_t; @@ -99,7 +98,7 @@ static H5FL_blk_gc_list_t H5FL_blk_gc_head = {0, NULL}; /* A garbage collection node for factory free lists */ struct H5FL_fac_gc_node_t { - H5FL_fac_head_t * list; /* Pointer to the head of the list to garbage collect */ + H5FL_fac_head_t *list; /* Pointer to the head of the list to garbage collect */ struct H5FL_fac_gc_node_t *next; /* Pointer to the next node in the list of things to garbage collect */ }; @@ -130,7 +129,7 @@ static H5FL_track_t *H5FL_out_head_g = NULL; #endif /* H5FL_TRACK */ /* Forward declarations of local static functions */ -static void * H5FL__malloc(size_t mem_size); +static void *H5FL__malloc(size_t mem_size); static herr_t H5FL__reg_init(H5FL_reg_head_t *head); static herr_t H5FL__reg_gc(void); static herr_t H5FL__reg_gc_list(H5FL_reg_head_t *head); @@ -337,8 +336,11 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj) /* Free tracking information about the allocation location */ H5CS_close_stack(trk->stack); - trk->file = H5MM_xfree(trk->file); - trk->func = H5MM_xfree(trk->func); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk->file = NULL; + trk->func = NULL; /* Remove from "outstanding allocations" list */ if (trk == H5FL_out_head_g) { @@ -443,8 +445,11 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) /* Copy allocation location information */ ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); HDassert(((H5FL_track_t *)ret_value)->stack); - ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); - ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + ((H5FL_track_t *)ret_value)->file = call_file; + ((H5FL_track_t *)ret_value)->func = call_func; ((H5FL_track_t *)ret_value)->line = call_line; /* Add to "outstanding allocations" list */ @@ -850,7 +855,7 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) { H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ - void * ret_value = NULL; /* Pointer to the block to return to the user */ + void *ret_value = NULL; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(NULL) @@ -908,8 +913,11 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) /* Copy allocation location information */ ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); HDassert(((H5FL_track_t *)ret_value)->stack); - ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); - ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + ((H5FL_track_t *)ret_value)->file = call_file; + ((H5FL_track_t *)ret_value)->func = call_func; ((H5FL_track_t *)ret_value)->line = call_line; /* Add to "outstanding allocations" list */ @@ -988,7 +996,7 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ H5FL_blk_list_t *temp; /* Temp. ptr to the new free list node allocated */ size_t free_size; /* Size of the block freed */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_blk_malloc/calloc * -NAF */ @@ -1000,24 +1008,32 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) #ifdef H5FL_TRACK { - H5FL_track_t *trk = block = ((unsigned char *)block) - sizeof(H5FL_track_t); + unsigned char *block_ptr = ((unsigned char *)block) - sizeof(H5FL_track_t); + H5FL_track_t trk; + + HDmemcpy(&trk, block_ptr, sizeof(H5FL_track_t)); /* Free tracking information about the allocation location */ - H5CS_close_stack(trk->stack); - trk->file = H5MM_xfree(trk->file); - trk->func = H5MM_xfree(trk->func); + H5CS_close_stack(trk.stack); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk.file = NULL; + trk.func = NULL; /* Remove from "outstanding allocations" list */ - if (trk == H5FL_out_head_g) { + if ((void *)block_ptr == (void *)H5FL_out_head_g) { H5FL_out_head_g = H5FL_out_head_g->next; if (H5FL_out_head_g) H5FL_out_head_g->prev = NULL; } /* end if */ else { - trk->prev->next = trk->next; - if (trk->next) - trk->next->prev = trk->prev; + trk.prev->next = trk.next; + if (trk.next) + trk.next->prev = trk.prev; } /* end else */ + + HDmemcpy(block_ptr, &trk, sizeof(H5FL_track_t)); } #endif /* H5FL_TRACK */ @@ -1116,19 +1132,30 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_ else { #ifdef H5FL_TRACK { - H5FL_track_t *trk = (H5FL_track_t *)(((unsigned char *)block) - sizeof(H5FL_track_t)); + unsigned char *block_ptr = ((unsigned char *)block) - sizeof(H5FL_track_t); + H5FL_track_t trk; + + HDmemcpy(&trk, block_ptr, sizeof(H5FL_track_t)); /* Release previous tracking information */ - H5CS_close_stack(trk->stack); - trk->file = H5MM_xfree(trk->file); - trk->func = H5MM_xfree(trk->func); + H5CS_close_stack(trk.stack); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk.file = NULL; + trk.func = NULL; /* Store new tracking information */ - trk->stack = H5CS_copy_stack(); - HDassert(trk->stack); - trk->file = H5MM_strdup(call_file); - trk->func = H5MM_strdup(call_func); - trk->line = call_line; + trk.stack = H5CS_copy_stack(); + HDassert(trk.stack); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + trk.file = call_file; + trk.func = call_func; + trk.line = call_line; + + HDmemcpy(block_ptr, &trk, sizeof(H5FL_track_t)); } #endif /* H5FL_TRACK */ ret_value = block; @@ -1400,7 +1427,7 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ size_t mem_size; /* Size of memory being freed */ size_t free_nelem; /* Number of elements in node being free'd */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ /* NOINIT OK here because this must be called after H5FL_arr_malloc/calloc * -NAF */ @@ -1416,10 +1443,42 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) /* Make certain that the free list is initialized */ HDassert(head->init); +#ifdef H5FL_TRACK + { + unsigned char *block_ptr = ((unsigned char *)obj) - sizeof(H5FL_track_t); + H5FL_track_t trk; + + HDmemcpy(&trk, block_ptr, sizeof(H5FL_track_t)); + + /* Free tracking information about the allocation location */ + H5CS_close_stack(trk.stack); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk.file = NULL; + trk.func = NULL; + + /* Remove from "outstanding allocations" list */ + if ((void *)block_ptr == H5FL_out_head_g) { + H5FL_out_head_g = H5FL_out_head_g->next; + if (H5FL_out_head_g) + H5FL_out_head_g->prev = NULL; + } /* end if */ + else { + trk.prev->next = trk.next; + if (trk.next) + trk.next->prev = trk.prev; + } /* end else */ + + HDmemcpy(block_ptr, &trk, sizeof(H5FL_track_t)); + } +#endif + /* Get the pointer to the info header in front of the block to free */ temp = (H5FL_arr_list_t *)(( void *)((unsigned char *)obj - - sizeof(H5FL_arr_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + (sizeof(H5FL_arr_list_t) + + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Get the number of elements */ free_nelem = temp->nelem; @@ -1472,11 +1531,11 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj) *------------------------------------------------------------------------- */ void * -H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) +H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS) { H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */ size_t mem_size; /* Size of memory block being recycled */ - void * ret_value = NULL; /* Pointer to the block to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1513,7 +1572,8 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) } /* end if */ /* Otherwise allocate a node */ else { - if (NULL == (new_obj = (H5FL_arr_list_t *)H5FL__malloc(sizeof(H5FL_arr_list_t) + mem_size))) + if (NULL == + (new_obj = (H5FL_arr_list_t *)H5FL__malloc(sizeof(H5FL_arr_list_t) + H5FL_TRACK_SIZE + mem_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Increment the number of blocks of this size */ @@ -1529,6 +1589,28 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) /* Get a pointer to the new block */ ret_value = ((char *)new_obj) + sizeof(H5FL_arr_list_t); +#ifdef H5FL_TRACK + /* Copy allocation location information */ + ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); + HDassert(((H5FL_track_t *)ret_value)->stack); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + ((H5FL_track_t *)ret_value)->file = call_file; + ((H5FL_track_t *)ret_value)->func = call_func; + ((H5FL_track_t *)ret_value)->line = call_line; + + /* Add to "outstanding allocations" list */ + ((H5FL_track_t *)ret_value)->prev = NULL; + ((H5FL_track_t *)ret_value)->next = H5FL_out_head_g; + if (H5FL_out_head_g) + H5FL_out_head_g->prev = (H5FL_track_t *)ret_value; + H5FL_out_head_g = (H5FL_track_t *)ret_value; + + /* Adjust for allocation tracking information */ + ret_value = ((unsigned char *)ret_value) + sizeof(H5FL_track_t); +#endif + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FL_arr_malloc() */ @@ -1547,7 +1629,7 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) *------------------------------------------------------------------------- */ void * -H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) +H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS) { void *ret_value = NULL; /* Pointer to the block to return */ @@ -1558,7 +1640,7 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) HDassert(elem); /* Allocate the array */ - if (NULL == (ret_value = H5FL_arr_malloc(head, elem))) + if (NULL == (ret_value = H5FL_arr_malloc(head, elem H5FL_TRACK_INFO_INT))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Clear to zeros */ @@ -1582,7 +1664,7 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) *------------------------------------------------------------------------- */ void * -H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem) +H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS) { void *ret_value = NULL; /* Pointer to the block to return */ @@ -1594,7 +1676,7 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem) /* Check if we are really allocating the object */ if (obj == NULL) - ret_value = H5FL_arr_malloc(head, new_elem); + ret_value = H5FL_arr_malloc(head, new_elem H5FL_TRACK_INFO_INT); else { H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */ @@ -1604,14 +1686,15 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem) /* Get the pointer to the info header in front of the block to free */ temp = (H5FL_arr_list_t *)(( void *)((unsigned char *)obj - - sizeof(H5FL_arr_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ + (sizeof(H5FL_arr_list_t) + + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */ /* Check if the size is really changing */ if (temp->nelem != new_elem) { size_t blk_size; /* Size of block */ /* Get the new array of objects */ - ret_value = H5FL_arr_malloc(head, new_elem); + ret_value = H5FL_arr_malloc(head, new_elem H5FL_TRACK_INFO_INT); /* Copy the appropriate amount of elements */ blk_size = head->list_arr[MIN(temp->nelem, new_elem)].size; @@ -1620,8 +1703,35 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem) /* Free the old block */ H5FL_arr_free(head, obj); } /* end if */ - else + else { +#ifdef H5FL_TRACK + unsigned char *block_ptr = ((unsigned char *)obj) - sizeof(H5FL_track_t); + H5FL_track_t trk; + + HDmemcpy(&trk, block_ptr, sizeof(H5FL_track_t)); + + /* Release previous tracking information */ + H5CS_close_stack(trk.stack); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk.file = NULL; + trk.func = NULL; + + /* Store new tracking information */ + trk.stack = H5CS_copy_stack(); + HDassert(trk.stack); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + trk.file = call_file; + trk.func = call_func; + trk.line = call_line; + + HDmemcpy(block_ptr, &trk, sizeof(H5FL_track_t)); +#endif ret_value = obj; + } } /* end else */ FUNC_LEAVE_NOAPI(ret_value) @@ -1932,8 +2042,8 @@ H5FL_fac_head_t * H5FL_fac_init(size_t size) { H5FL_fac_gc_node_t *new_node = NULL; /* Pointer to the node for the new list to garbage collect */ - H5FL_fac_head_t * factory = NULL; /* Pointer to new block factory */ - H5FL_fac_head_t * ret_value = NULL; /* Return value */ + H5FL_fac_head_t *factory = NULL; /* Pointer to new block factory */ + H5FL_fac_head_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2017,8 +2127,11 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj) /* Free tracking information about the allocation location */ H5CS_close_stack(trk->stack); - trk->file = H5MM_xfree(trk->file); - trk->func = H5MM_xfree(trk->func); + /* The 'func' & 'file' strings are statically allocated (by the compiler) + * and are not allocated, so there's no need to free them. + */ + trk->file = NULL; + trk->func = NULL; /* Remove from "outstanding allocations" list */ if (trk == H5FL_out_head_g) { @@ -2120,8 +2233,11 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) /* Copy allocation location information */ ((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack(); HDassert(((H5FL_track_t *)ret_value)->stack); - ((H5FL_track_t *)ret_value)->file = H5MM_strdup(call_file); - ((H5FL_track_t *)ret_value)->func = H5MM_strdup(call_func); + /* The 'call_func' & 'call_file' strings are statically allocated (by the compiler) + * there's no need to duplicate them. + */ + ((H5FL_track_t *)ret_value)->file = call_file; + ((H5FL_track_t *)ret_value)->func = call_func; ((H5FL_track_t *)ret_value)->line = call_line; /* Add to "outstanding allocations" list */ diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index 42581acb7cc..41bb1b70e95 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -50,6 +49,11 @@ */ /* #define H5FL_TRACK */ #ifdef H5FL_TRACK + +#ifndef H5_HAVE_CODESTACK +#error "Free list tracking requires code stack to be enabled" +#endif + /* Macro for inclusion in the free list allocation calls */ #define H5FL_TRACK_INFO , __FILE__, FUNC, __LINE__ @@ -64,9 +68,9 @@ struct H5CS_t; /* Tracking information for each block */ typedef struct H5FL_track_t { - struct H5CS_t * stack; /* Function stack */ - char * file; /* Name of file containing calling function */ - char * func; /* Name of calling function */ + struct H5CS_t *stack; /* Function stack */ + char *file; /* Name of file containing calling function */ + char *func; /* Name of calling function */ int line; /* Line # within calling function */ struct H5FL_track_t *next; /* Pointer to next tracking block */ struct H5FL_track_t *prev; /* Pointer to previous tracking block */ @@ -96,7 +100,7 @@ typedef struct H5FL_reg_head_t { hbool_t init; /* Whether the free list has been initialized */ unsigned allocated; /* Number of blocks allocated */ unsigned onlist; /* Number of blocks on free list */ - const char * name; /* Name of the type */ + const char *name; /* Name of the type */ size_t size; /* Size of the blocks in the list */ H5FL_reg_node_t *list; /* List of free blocks */ } H5FL_reg_head_t; @@ -148,8 +152,8 @@ typedef struct H5FL_reg_head_t { typedef union H5FL_blk_list_t { size_t size; /* Size of the page */ union H5FL_blk_list_t *next; /* Pointer to next block in free list */ - double unused1; /* Unused normally, just here for aligment */ - haddr_t unused2; /* Unused normally, just here for aligment */ + double unused1; /* Unused normally, just here for alignment */ + haddr_t unused2; /* Unused normally, just here for alignment */ } H5FL_blk_list_t; /* Data structure for priority queue node of block free lists */ @@ -157,7 +161,7 @@ typedef struct H5FL_blk_node_t { size_t size; /* Size of the blocks in the list */ unsigned allocated; /* Number of blocks of this size allocated */ unsigned onlist; /* Number of blocks on free list */ - H5FL_blk_list_t * list; /* List of free blocks */ + H5FL_blk_list_t *list; /* List of free blocks */ struct H5FL_blk_node_t *next; /* Pointer to next free list in queue */ struct H5FL_blk_node_t *prev; /* Pointer to previous free list in queue */ } H5FL_blk_node_t; @@ -168,7 +172,7 @@ typedef struct H5FL_blk_head_t { unsigned allocated; /* Total number of blocks allocated */ unsigned onlist; /* Total number of blocks on free list */ size_t list_mem; /* Total amount of memory in blocks on free list */ - const char * name; /* Name of the type */ + const char *name; /* Name of the type */ H5FL_blk_node_t *head; /* Pointer to first free list in queue */ } H5FL_blk_head_t; @@ -202,7 +206,7 @@ typedef struct H5FL_blk_head_t { #define H5FL_BLK_REALLOC(t, blk, new_size) \ (uint8_t *)H5FL_blk_realloc(&(H5FL_BLK_NAME(t)), blk, new_size H5FL_TRACK_INFO) -/* Check if there is a free block available to re-use */ +/* Check if there is a free block available to reuse */ #define H5FL_BLK_AVAIL(t, size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)), size) #else /* H5_NO_BLK_FREE_LISTS */ @@ -223,8 +227,8 @@ typedef struct H5FL_blk_head_t { typedef union H5FL_arr_list_t { union H5FL_arr_list_t *next; /* Pointer to next block in free list */ size_t nelem; /* Number of elements in this array */ - double unused1; /* Unused normally, just here for aligment */ - haddr_t unused2; /* Unused normally, just here for aligment */ + double unused1; /* Unused normally, just here for alignment */ + haddr_t unused2; /* Unused normally, just here for alignment */ } H5FL_arr_list_t; /* Data structure for each size of array element */ @@ -241,7 +245,7 @@ typedef struct H5FL_arr_head_t { hbool_t init; /* Whether the free list has been initialized */ unsigned allocated; /* Total number of blocks allocated */ size_t list_mem; /* Amount of memory in block on free list */ - const char * name; /* Name of the type */ + const char *name; /* Name of the type */ int maxelem; /* Maximum number of elements in an array */ size_t base_size; /* Size of the "base" object in the list */ size_t elem_size; /* Size of the array elements in the list */ @@ -273,16 +277,17 @@ typedef struct H5FL_arr_head_t { #define H5FL_BARR_DEFINE_STATIC(b, t, m) static H5FL_ARR_DEFINE_COMMON(sizeof(b), t, m) /* Allocate an array of type 't' */ -#define H5FL_ARR_MALLOC(t, elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)), elem) +#define H5FL_ARR_MALLOC(t, elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)), elem H5FL_TRACK_INFO) /* Allocate an array of type 't' and clear it to all zeros */ -#define H5FL_ARR_CALLOC(t, elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)), elem) +#define H5FL_ARR_CALLOC(t, elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)), elem H5FL_TRACK_INFO) /* Free an array of type 't' */ #define H5FL_ARR_FREE(t, obj) (t *)H5FL_arr_free(&(H5FL_ARR_NAME(t)), obj) /* Re-allocate an array of type 't' */ -#define H5FL_ARR_REALLOC(t, obj, new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)), obj, new_elem) +#define H5FL_ARR_REALLOC(t, obj, new_elem) \ + H5FL_arr_realloc(&(H5FL_ARR_NAME(t)), obj, new_elem H5FL_TRACK_INFO) #else /* H5_NO_ARR_FREE_LISTS */ /* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC (and H5FL_BARR variants) */ @@ -362,7 +367,7 @@ typedef struct H5FL_fac_head_t { unsigned allocated; /* Number of blocks allocated */ unsigned onlist; /* Number of blocks on free list */ size_t size; /* Size of the blocks in the list */ - H5FL_fac_node_t * list; /* List of free blocks */ + H5FL_fac_node_t *list; /* List of free blocks */ H5FL_fac_gc_node_t *prev_gc; /* Previous garbage collection node in list */ } H5FL_fac_head_t; @@ -393,10 +398,10 @@ typedef struct H5FL_fac_head_t { * Library prototypes. */ /* Block free lists */ -H5_DLL void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_blk_free(H5FL_blk_head_t *head, void *block); -H5_DLL void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_blk_free(H5FL_blk_head_t *head, void *block); +H5_DLL void *H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_PARAMS); H5_DLL htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size); /* Regular free lists */ @@ -405,10 +410,10 @@ H5_DLL void *H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS); H5_DLL void *H5FL_reg_free(H5FL_reg_head_t *head, void *obj); /* Array free lists */ -H5_DLL void *H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem); -H5_DLL void *H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem); +H5_DLL void *H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS); H5_DLL void *H5FL_arr_free(H5FL_arr_head_t *head, void *obj); -H5_DLL void *H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem); +H5_DLL void *H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS); /* Sequence free lists */ H5_DLL void *H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS); @@ -418,9 +423,9 @@ H5_DLL void *H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem /* Factory free lists */ H5_DLL H5FL_fac_head_t *H5FL_fac_init(size_t size); -H5_DLL void * H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); -H5_DLL void * H5FL_fac_free(H5FL_fac_head_t *head, void *obj); +H5_DLL void *H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS); +H5_DLL void *H5FL_fac_free(H5FL_fac_head_t *head, void *obj); H5_DLL herr_t H5FL_fac_term(H5FL_fac_head_t *head); /* General free list routines */ diff --git a/src/H5FO.c b/src/H5FO.c index 441d2847b7d..72903c15539 100644 --- a/src/H5FO.c +++ b/src/H5FO.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -32,7 +31,7 @@ /* Information about open objects in a file */ typedef struct H5FO_open_obj_t { haddr_t addr; /* Address of object header for object */ - void * obj; /* Pointer to the object */ + void *obj; /* Pointer to the object */ hbool_t deleted; /* Flag to indicate that the object was deleted from the file */ } H5FO_open_obj_t; @@ -109,7 +108,7 @@ void * H5FO_opened(const H5F_t *f, haddr_t addr) { H5FO_open_obj_t *open_obj; /* Information about open object */ - void * ret_value; /* Return value */ + void *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOERR diff --git a/src/H5FOprivate.h b/src/H5FOprivate.h index 7b512668169..9db0b0dd743 100644 --- a/src/H5FOprivate.h +++ b/src/H5FOprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -35,7 +34,7 @@ typedef H5SL_t H5FO_t; /* Currently, all open objects are stored in skip list */ /* Private routines */ H5_DLL herr_t H5FO_create(const H5F_t *f); -H5_DLL void * H5FO_opened(const H5F_t *f, haddr_t addr); +H5_DLL void *H5FO_opened(const H5F_t *f, haddr_t addr); H5_DLL herr_t H5FO_insert(const H5F_t *f, haddr_t addr, void *obj, hbool_t delete_flag); H5_DLL herr_t H5FO_delete(H5F_t *f, haddr_t addr); H5_DLL herr_t H5FO_mark(const H5F_t *f, haddr_t addr, hbool_t deleted); diff --git a/src/H5FS.c b/src/H5FS.c index c85790c06da..cf5c11f7a3b 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -146,7 +145,7 @@ H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t /* Set the return value */ ret_value = fspace; #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: fspace = %p, fspace->addr = %a\n", FUNC, fspace, fspace->addr); + HDfprintf(stderr, "%s: fspace = %p, fspace->addr = %" PRIuHADDR "\n", FUNC, (void *)fspace, fspace->addr); #endif /* H5FS_DEBUG */ done: @@ -155,7 +154,7 @@ H5FS_create(H5F_t *f, haddr_t *fs_addr, const H5FS_create_t *fs_create, uint16_t HDONE_ERROR(H5E_FSPACE, H5E_CANTFREE, NULL, "unable to destroy free space header") #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving, ret_value = %p\n", FUNC, (void *)ret_value); #endif /* H5FS_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS_create() */ @@ -177,14 +176,14 @@ H5FS_t * H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) { - H5FS_t * fspace = NULL; /* New free space structure */ + H5FS_t *fspace = NULL; /* New free space structure */ H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - H5FS_t * ret_value = NULL; /* Return value */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Opening free space manager, fs_addr = %a, nclasses = %Zu\n", FUNC, fs_addr, - nclasses); + HDfprintf(stderr, "%s: Opening free space manager, fs_addr = %" PRIuHADDR ", nclasses = %Zu\n", FUNC, + fs_addr, nclasses); #endif /* H5FS_DEBUG */ /* Check arguments. */ @@ -204,10 +203,10 @@ H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, const H5FS_section_class (fspace = (H5FS_t *)H5AC_protect(f, H5AC_FSPACE_HDR, fs_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_FSPACE, H5E_CANTPROTECT, NULL, "unable to load free space header") #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); - HDfprintf(stderr, "%s: fspace->sect_size = %Hu\n", FUNC, fspace->sect_size); - HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu\n", FUNC, fspace->alloc_sect_size); - HDfprintf(stderr, "%s: fspace->sinfo = %p\n", FUNC, fspace->sinfo); + HDfprintf(stderr, "%s: fspace->sect_addr = %" PRIuHADDR "\n", FUNC, fspace->sect_addr); + HDfprintf(stderr, "%s: fspace->sect_size = %" PRIuHSIZE "\n", FUNC, fspace->sect_size); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %" PRIuHSIZE "\n", FUNC, fspace->alloc_sect_size); + HDfprintf(stderr, "%s: fspace->sinfo = %p\n", FUNC, (void *)fspace->sinfo); HDfprintf(stderr, "%s: fspace->rc = %u\n", FUNC, fspace->rc); #endif /* H5FS_DEBUG */ @@ -245,13 +244,13 @@ H5FS_open(H5F_t *f, haddr_t fs_addr, uint16_t nclasses, const H5FS_section_class herr_t H5FS_delete(H5F_t *f, haddr_t fs_addr) { - H5FS_t * fspace = NULL; /* Free space header loaded from file */ + H5FS_t *fspace = NULL; /* Free space header loaded from file */ H5FS_hdr_cache_ud_t cache_udata; /* User-data for metadata cache callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Deleting free space manager, fs_addr = %a\n", FUNC, fs_addr); + HDfprintf(stderr, "%s: Deleting free space manager, fs_addr = %" PRIuHADDR "\n", FUNC, fs_addr); #endif /* H5FS_DEBUG */ /* Check arguments. */ @@ -321,7 +320,7 @@ H5FS_delete(H5F_t *f, haddr_t fs_addr) /* Delete serialized section storage, if there are any */ #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: fspace->sect_addr = %a\n", FUNC, fspace->sect_addr); + HDfprintf(stderr, "%s: fspace->sect_addr = %" PRIuHADDR "\n", FUNC, fspace->sect_addr); #endif /* H5FS_DEBUG */ if (fspace->serial_sect_count > 0) { unsigned sinfo_status = 0; /* Free space section info's status in the metadata cache */ @@ -407,8 +406,8 @@ H5FS_close(H5F_t *f, H5FS_t *fspace) HDassert(f); HDassert(fspace); #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Entering, fspace = %p, fspace->addr = %a, fspace->sinfo = %p\n", FUNC, fspace, - fspace->addr, fspace->sinfo); + HDfprintf(stderr, "%s: Entering, fspace = %p, fspace->addr = %" PRIuHADDR ", fspace->sinfo = %p\n", FUNC, + (void *)fspace, fspace->addr, (void *)fspace->sinfo); #endif /* H5FS_DEBUG */ /* Check if section info is valid */ @@ -416,10 +415,11 @@ H5FS_close(H5F_t *f, H5FS_t *fspace) if (fspace->sinfo) { #ifdef H5FS_DEBUG HDfprintf(stderr, - "%s: fspace->tot_sect_count = %Hu, fspace->serial_sect_count = %Hu, fspace->sect_addr = " - "%a, fspace->rc = %u\n", + "%s: fspace->tot_sect_count = %" PRIuHSIZE ", fspace->serial_sect_count = %" PRIuHSIZE + ", fspace->sect_addr = %" PRIuHADDR ", fspace->rc = %u\n", FUNC, fspace->tot_sect_count, fspace->serial_sect_count, fspace->sect_addr, fspace->rc); - HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, + HDfprintf(stderr, + "%s: fspace->alloc_sect_size = %" PRIuHSIZE ", fspace->sect_size = %" PRIuHSIZE "\n", FUNC, fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_DEBUG */ /* If there are sections to serialize, update them */ @@ -709,7 +709,8 @@ H5FS__incr(H5FS_t *fspace) FUNC_ENTER_PACKAGE #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fspace->addr, fspace->rc); + HDfprintf(stderr, "%s: Entering, fpace->addr = %" PRIuHADDR ", fspace->rc = %u\n", FUNC, fspace->addr, + fspace->rc); #endif /* H5FS_DEBUG */ /* @@ -748,7 +749,8 @@ H5FS__decr(H5FS_t *fspace) FUNC_ENTER_PACKAGE #ifdef H5FS_DEBUG - HDfprintf(stderr, "%s: Entering, fpace->addr = %a, fspace->rc = %u\n", FUNC, fspace->addr, fspace->rc); + HDfprintf(stderr, "%s: Entering, fpace->addr = %" PRIuHADDR ", fspace->rc = %u\n", FUNC, fspace->addr, + fspace->rc); #endif /* H5FS_DEBUG */ /* @@ -1069,7 +1071,7 @@ static herr_t H5FS__sinfo_free_sect_cb(void *_sect, void H5_ATTR_UNUSED *key, void *op_data) { H5FS_section_info_t *sect = (H5FS_section_info_t *)_sect; /* Section to free */ - const H5FS_sinfo_t * sinfo = (const H5FS_sinfo_t *)op_data; /* Free space manager for section */ + const H5FS_sinfo_t *sinfo = (const H5FS_sinfo_t *)op_data; /* Free space manager for section */ FUNC_ENTER_STATIC_NOERR diff --git a/src/H5FScache.c b/src/H5FScache.c index 39f0333757d..564730e7e2e 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -56,7 +55,7 @@ /* User data for skip list iterator callback for iterating over section size nodes when syncing */ typedef struct { H5FS_sinfo_t *sinfo; /* Free space section info */ - uint8_t ** image; /* Pointer to address of buffer pointer to serialize with */ + uint8_t **image; /* Pointer to address of buffer pointer to serialize with */ unsigned sect_cnt_size; /* # of bytes to encode section size counts in */ } H5FS_iter_ud_t; @@ -75,7 +74,7 @@ static herr_t H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *ke /* Metadata cache callbacks */ static herr_t H5FS__cache_hdr_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FS__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5FS__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5FS__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FS__cache_hdr_image_len(const void *thing, size_t *image_len); static herr_t H5FS__cache_hdr_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); @@ -85,7 +84,7 @@ static herr_t H5FS__cache_hdr_free_icr(void *thing); static herr_t H5FS__cache_sinfo_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5FS__cache_sinfo_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5FS__cache_sinfo_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5FS__cache_sinfo_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5FS__cache_sinfo_image_len(const void *thing, size_t *image_len); static herr_t H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); @@ -226,12 +225,12 @@ static void * H5FS__cache_hdr_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5FS_t * fspace = NULL; /* Free space header info */ + H5FS_t *fspace = NULL; /* Free space header info */ H5FS_hdr_cache_ud_t *udata = (H5FS_hdr_cache_ud_t *)_udata; /* User data for callback */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned nclasses; /* Number of section classes */ - H5FS_t * ret_value = NULL; /* Return value */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -386,7 +385,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_AT haddr_t H5_ATTR_NDEBUG_UNUSED *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len, unsigned *flags) { - H5FS_t * fspace = (H5FS_t *)_thing; /* Pointer to the object */ + H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ herr_t ret_value = SUCCEED; /* Return value */ @@ -436,7 +435,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_AT * * H5F_addr_defined(fspace->addr) * - * will both be TRUE. If this contition does not hold, then + * will both be TRUE. If this condition does not hold, then * either the free space info is not persistent * (!H5F_addr_defined(fspace->addr)???) or the section info * contains no free space data that must be written to file @@ -683,7 +682,7 @@ H5FS__cache_hdr_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_AT static herr_t H5FS__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5FS_t * fspace = (H5FS_t *)_thing; /* Pointer to the object */ + H5FS_t *fspace = (H5FS_t *)_thing; /* Pointer to the object */ uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t metadata_chksum; /* Computed metadata checksum value */ herr_t ret_value = SUCCEED; /* Return value */ @@ -887,7 +886,7 @@ H5FS__cache_hdr_free_icr(void *_thing) static herr_t H5FS__cache_sinfo_get_initial_load_size(void *_udata, size_t *image_len) { - const H5FS_t * fspace; /* free space manager */ + const H5FS_t *fspace; /* free space manager */ H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */ FUNC_ENTER_STATIC_NOERR @@ -961,14 +960,14 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l hbool_t H5_ATTR_NDEBUG_UNUSED *dirty) { H5FS_sinfo_cache_ud_t *udata = (H5FS_sinfo_cache_ud_t *)_udata; /* User data for callback */ - H5FS_t * fspace; /* free space manager */ - H5FS_sinfo_t * sinfo = NULL; /* Free space section info */ + H5FS_t *fspace; /* free space manager */ + H5FS_sinfo_t *sinfo = NULL; /* Free space section info */ haddr_t fs_addr; /* Free space header address */ size_t old_sect_size; /* Old section size */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - const uint8_t * chksum_image; /* Points to chksum location */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *chksum_image; /* Points to chksum location */ uint32_t stored_chksum; /* Stored metadata checksum */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1005,10 +1004,10 @@ H5FS__cache_sinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED l if (fspace->serial_sect_count > 0) { hsize_t old_tot_sect_count; /* Total section count from header */ hsize_t H5_ATTR_NDEBUG_UNUSED - old_serial_sect_count; /* Total serializable section count from header */ - hsize_t H5_ATTR_NDEBUG_UNUSED old_ghost_sect_count; /* Total ghost section count from header */ - hsize_t H5_ATTR_NDEBUG_UNUSED old_tot_space; /* Total space managed from header */ - unsigned sect_cnt_size; /* The size of the section size counts */ + old_serial_sect_count; /* Total serializable section count from header */ + hsize_t H5_ATTR_NDEBUG_UNUSED old_ghost_sect_count; /* Total ghost section count from header */ + hsize_t H5_ATTR_NDEBUG_UNUSED old_tot_space; /* Total space managed from header */ + unsigned sect_cnt_size; /* The size of the section size counts */ /* Compute the size of the section counts */ sect_cnt_size = H5VM_limit_enc_size((uint64_t)fspace->serial_sect_count); @@ -1159,7 +1158,7 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ haddr_t *new_addr, size_t H5_ATTR_NDEBUG_UNUSED *new_len, unsigned *flags) { H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ - H5FS_t * fspace; /* Free space header */ + H5FS_t *fspace; /* Free space header */ haddr_t sinfo_addr; /* Address for section info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1240,10 +1239,10 @@ H5FS__cache_sinfo_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ static herr_t H5FS__cache_sinfo_serialize(const H5F_t *f, void *_image, size_t len, void *_thing) { - H5FS_sinfo_t * sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ + H5FS_sinfo_t *sinfo = (H5FS_sinfo_t *)_thing; /* Pointer to the object */ H5FS_iter_ud_t udata; /* User data for callbacks */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ - uint8_t * chksum_image = NULL; /* Points to chksum location */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *chksum_image = NULL; /* Points to chksum location */ uint32_t metadata_chksum; /* Computed metadata checksum value */ unsigned bin; /* Current bin we are on */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1427,8 +1426,8 @@ static herr_t H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { H5FS_section_class_t *sect_cls; /* Class of section */ - H5FS_section_info_t * sect = (H5FS_section_info_t *)_item; /* Free space section to work on */ - H5FS_iter_ud_t * udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ + H5FS_section_info_t *sect = (H5FS_section_info_t *)_item; /* Free space section to work on */ + H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1481,7 +1480,7 @@ H5FS__sinfo_serialize_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udat static herr_t H5FS__sinfo_serialize_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { - H5FS_node_t * fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ + H5FS_node_t *fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c index 3862b53a005..769357e2212 100644 --- a/src/H5FSdbg.c +++ b/src/H5FSdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -82,7 +81,7 @@ herr_t H5FS_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) { - H5FS_t * fspace = NULL; /* Free space header info */ + H5FS_t *fspace = NULL; /* Free space header info */ H5FS_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -204,7 +203,7 @@ herr_t H5FS_sects_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int indent, int fwidth, haddr_t fs_addr, haddr_t client_addr) { - H5FS_t * fspace = NULL; /* Free space header info */ + H5FS_t *fspace = NULL; /* Free space header info */ H5FS_client_t client; /* The client of the free space */ H5FS_hdr_cache_ud_t cache_udata; /* User-data for cache callback */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5FSint.c b/src/H5FSint.c index 0ab975b5895..7e545b86dc3 100644 --- a/src/H5FSint.c +++ b/src/H5FSint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index ba2cf03cdb1..987e695e4ed 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -92,16 +91,16 @@ /* Callback info for loading a free space header into the cache */ typedef struct H5FS_hdr_cache_ud_t { - H5F_t * f; /* File that free space header is within */ + H5F_t *f; /* File that free space header is within */ uint16_t nclasses; /* Number of section classes */ const H5FS_section_class_t **classes; /* Array of section class info */ - void * cls_init_udata; /* Pointer to class init user data */ + void *cls_init_udata; /* Pointer to class init user data */ haddr_t addr; /* Address of header */ } H5FS_hdr_cache_ud_t; /* Callback info for loading free space section info into the cache */ typedef struct H5FS_sinfo_cache_ud_t { - H5F_t * f; /* File that free space section info is within */ + H5F_t *f; /* File that free space section info is within */ H5FS_t *fspace; /* free space manager */ } H5FS_sinfo_cache_ud_t; @@ -139,7 +138,7 @@ typedef struct H5FS_sinfo_t { unsigned sect_prefix_size; /* Size of the section serialization prefix (in bytes) */ unsigned sect_off_size; /* Size of a section offset (in bytes) */ unsigned sect_len_size; /* Size of a section length (in bytes) */ - H5FS_t * fspace; /* Pointer to free space manager that owns sections */ + H5FS_t *fspace; /* Pointer to free space manager that owns sections */ /* Memory data structures (not stored directly) */ H5SL_t *merge_list; /* Skip list to hold sections for detecting merges */ diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index fdc5c912bc9..7f10abeb053 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -100,7 +99,7 @@ typedef struct H5FS_section_class_t { const unsigned type; /* Type of free space section */ size_t serial_size; /* Size of serialized form of section */ unsigned flags; /* Class flags */ - void * cls_private; /* Class private information */ + void *cls_private; /* Class private information */ /* Class methods */ herr_t (*init_cls)(struct H5FS_section_class_t *, @@ -116,7 +115,7 @@ typedef struct H5FS_section_class_t { const struct H5FS_section_class_t *, const uint8_t *, haddr_t, hsize_t, unsigned *); /* Routine to deserialize a buffer into a "live" section */ htri_t (*can_merge)(const H5FS_section_info_t *, const H5FS_section_info_t *, - void *); /* Routine to determine if two nodes are mergable */ + void *); /* Routine to determine if two nodes are mergeable */ herr_t (*merge)(H5FS_section_info_t **, H5FS_section_info_t *, void *); /* Routine to merge two nodes */ htri_t (*can_shrink)(const H5FS_section_info_t *, void *); /* Routine to determine if node can shrink container */ diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 6ba1bc34ee4..d23d42cc414 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -47,9 +46,9 @@ /* User data for skip list iterator callback for iterating over section size nodes */ typedef struct { - H5FS_t * fspace; /* Free space manager info */ + H5FS_t *fspace; /* Free space manager info */ H5FS_operator_t op; /* Operator for the iteration */ - void * op_data; /* Information to pass to the operator */ + void *op_data; /* Information to pass to the operator */ } H5FS_iter_ud_t; /********************/ @@ -123,7 +122,7 @@ H5FS__sinfo_new(H5F_t *f, H5FS_t *fspace) HDassert(f); HDassert(fspace); #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: fspace->addr = %a\n", FUNC, fspace->addr); + HDfprintf(stderr, "%s: fspace->addr = %" PRIuHADDR "\n", FUNC, fspace->addr); #endif /* H5FS_SINFO_DEBUG */ /* Allocate the free space header */ @@ -136,7 +135,7 @@ H5FS__sinfo_new(H5F_t *f, H5FS_t *fspace) sinfo->sect_off_size = (fspace->max_sect_addr + 7) / 8; sinfo->sect_len_size = H5VM_limit_enc_size((uint64_t)fspace->max_sect_size); #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: fspace->max_sect_size = %Hu\n", FUNC, fspace->max_sect_size); + HDfprintf(stderr, "%s: fspace->max_sect_size = %" PRIuHSIZE "\n", FUNC, fspace->max_sect_size); HDfprintf(stderr, "%s: fspace->max_sect_addr = %u\n", FUNC, fspace->max_sect_addr); HDfprintf(stderr, "%s: sinfo->nbins = %u\n", FUNC, sinfo->nbins); HDfprintf(stderr, "%s: sinfo->sect_off_size = %u, sinfo->sect_len_size = %u\n", FUNC, @@ -200,10 +199,12 @@ H5FS__sinfo_lock(H5F_t *f, H5FS_t *fspace, unsigned accmode) FUNC_ENTER_STATIC #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: Called, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC, - fspace->addr, fspace->sinfo, fspace->sect_addr); - HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, - fspace->alloc_sect_size, fspace->sect_size); + HDfprintf(stderr, + "%s: Called, fspace->addr = %" PRIuHADDR ", fspace->sinfo = %p, fspace->sect_addr = %" PRIuHADDR + "\n", + FUNC, fspace->addr, (void *)fspace->sinfo, fspace->sect_addr); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %" PRIuHSIZE ", fspace->sect_size = %" PRIuHSIZE "\n", + FUNC, fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -251,7 +252,7 @@ H5FS__sinfo_lock(H5F_t *f, H5FS_t *fspace, unsigned accmode) HDassert(H5F_addr_defined(fspace->addr)); #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %a\n", FUNC, + HDfprintf(stderr, "%s: Reading in existing sections, fspace->sect_addr = %" PRIuHADDR "\n", FUNC, fspace->sect_addr); #endif /* H5FS_SINFO_DEBUG */ /* Protect the free space sections */ @@ -289,10 +290,12 @@ H5FS__sinfo_lock(H5F_t *f, H5FS_t *fspace, unsigned accmode) done: #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: Leaving, fspace->addr = %a, fspace->sinfo = %p, fspace->sect_addr = %a\n", FUNC, - fspace->addr, fspace->sinfo, fspace->sect_addr); - HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, - fspace->alloc_sect_size, fspace->sect_size); + HDfprintf(stderr, + "%s: Leaving, fspace->addr = %" PRIuHADDR + ", fspace->sinfo = %p, fspace->sect_addr = %" PRIuHADDR "\n", + FUNC, fspace->addr, (void *)fspace->sinfo, fspace->sect_addr); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %" PRIuHSIZE ", fspace->sect_size = %" PRIuHSIZE "\n", + FUNC, fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_SINFO_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* H5FS__sinfo_lock() */ @@ -331,14 +334,16 @@ H5FS__sinfo_unlock(H5F_t *f, H5FS_t *fspace, hbool_t modified) FUNC_ENTER_STATIC #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: Called, modified = %t, fspace->addr = %a, fspace->sect_addr = %a\n", FUNC, - modified, fspace->addr, fspace->sect_addr); + HDfprintf(stderr, + "%s: Called, modified = %d, fspace->addr = %" PRIuHADDR ", fspace->sect_addr = %" PRIuHADDR + "\n", + FUNC, modified, fspace->addr, fspace->sect_addr); HDfprintf( stderr, - "%s: fspace->sinfo_lock_count = %u, fspace->sinfo_modified = %t, fspace->sinfo_protected = %t\n", + "%s: fspace->sinfo_lock_count = %u, fspace->sinfo_modified = %d, fspace->sinfo_protected = %d\n", FUNC, fspace->sinfo_lock_count, fspace->sinfo_modified, fspace->sinfo_protected); - HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n", FUNC, - fspace->alloc_sect_size, fspace->sect_size); + HDfprintf(stderr, "%s: fspace->alloc_sect_size = %" PRIuHSIZE ", fspace->sect_size = %" PRIuHSIZE "\n", + FUNC, fspace->alloc_sect_size, fspace->sect_size); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -490,7 +495,8 @@ H5FS__sinfo_unlock(H5F_t *f, H5FS_t *fspace, hbool_t modified) #ifdef H5FS_SINFO_DEBUG HDfprintf(stderr, - "%s: Freeing section info on disk, old_sect_addr = %a, old_alloc_sect_size = %Hu\n", + "%s: Freeing section info on disk, old_sect_addr = %" PRIuHADDR + ", old_alloc_sect_size = %" PRIuHSIZE "\n", FUNC, old_sect_addr, old_alloc_sect_size); #endif /* H5FS_SINFO_DEBUG */ /* Release space for section info in file */ @@ -767,7 +773,7 @@ H5FS__size_node_decr(H5FS_sinfo_t *sinfo, unsigned bin, H5FS_node_t *fspace_node static herr_t H5FS__sect_unlink_size(H5FS_sinfo_t *sinfo, const H5FS_section_class_t *cls, H5FS_section_info_t *sect) { - H5FS_node_t * fspace_node; /* Free list size node */ + H5FS_node_t *fspace_node; /* Free list size node */ H5FS_section_info_t *tmp_sect_node; /* Temporary section node */ unsigned bin; /* Bin to put the free space section in */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1156,7 +1162,7 @@ H5FS__sect_merge(H5FS_t *fspace, H5FS_section_info_t **sect, void *op_data) do { H5SL_node_t *less_sect_node; /* Skip list node for section less than new section */ H5SL_node_t *greater_sect_node = NULL; /* Skip list node for section greater than new section */ - H5FS_section_info_t * tmp_sect; /* Temporary free space section */ + H5FS_section_info_t *tmp_sect; /* Temporary free space section */ H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */ hbool_t greater_sect_node_valid = FALSE; /* Indicate if 'greater than' section node is valid */ @@ -1343,8 +1349,8 @@ H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flag FUNC_ENTER_NOAPI(FAIL) #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: *sect = {%a, %Hu, %u, %s}\n", FUNC, sect->addr, sect->size, sect->type, - (sect->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); + HDfprintf(stderr, "%s: *sect = {%" PRIuHADDR ", %" PRIuHSIZE ", %u, %s}\n", FUNC, sect->addr, sect->size, + sect->type, (sect->state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED")); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -1384,7 +1390,7 @@ H5FS_sect_add(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, unsigned flag HGOTO_ERROR(H5E_FSPACE, H5E_CANTINSERT, FAIL, "can't insert free space section into skip list") #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: fspace->tot_space = %Hu\n", FUNC, fspace->tot_space); + HDfprintf(stderr, "%s: fspace->tot_space = %" PRIuHSIZE "\n", FUNC, fspace->tot_space); #endif /* H5FS_SINFO_DEBUG */ /* Mark free space sections as changed */ /* (if adding sections while deserializing sections, don't set the flag) */ @@ -1429,8 +1435,8 @@ H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, hsize_t size, hsize FUNC_ENTER_NOAPI(FAIL) #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: addr = %a, size = %Hu, extra_requested = %hu\n", FUNC, addr, size, - extra_requested); + HDfprintf(stderr, "%s: addr = %" PRIuHADDR ", size = %" PRIuHSIZE ", extra_requested = %" PRIuHSIZE "\n", + FUNC, addr, size, extra_requested); #endif /* H5FS_SINFO_DEBUG */ /* Check arguments. */ @@ -1442,9 +1448,9 @@ H5FS_sect_try_extend(H5F_t *f, H5FS_t *fspace, haddr_t addr, hsize_t size, hsize /* Check for any sections on free space list */ #ifdef H5FS_SINFO_DEBUG - HDfprintf(stderr, "%s: fspace->tot_sect_count = %Hu\n", FUNC, fspace->tot_sect_count); - HDfprintf(stderr, "%s: fspace->serial_sect_count = %Hu\n", FUNC, fspace->serial_sect_count); - HDfprintf(stderr, "%s: fspace->ghost_sect_count = %Hu\n", FUNC, fspace->ghost_sect_count); + HDfprintf(stderr, "%s: fspace->tot_sect_count = %" PRIuHSIZE "\n", FUNC, fspace->tot_sect_count); + HDfprintf(stderr, "%s: fspace->serial_sect_count = %" PRIuHSIZE "\n", FUNC, fspace->serial_sect_count); + HDfprintf(stderr, "%s: fspace->ghost_sect_count = %" PRIuHSIZE "\n", FUNC, fspace->ghost_sect_count); #endif /* H5FS_SINFO_DEBUG */ if (fspace->tot_sect_count > 0) { H5FS_section_info_t *sect; /* Temporary free space section */ @@ -1629,7 +1635,7 @@ H5FS__sect_find_node(H5FS_t *fspace, hsize_t request, H5FS_section_info_t **node unsigned bin; /* Bin to put the free space section in */ htri_t ret_value = FALSE; /* Return value */ - H5SL_node_t * curr_size_node = NULL; + H5SL_node_t *curr_size_node = NULL; const H5FS_section_class_t *cls; /* Class of section */ hsize_t alignment; @@ -1836,7 +1842,7 @@ static herr_t H5FS__iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { H5FS_section_info_t *sect_info = (H5FS_section_info_t *)_item; /* Free space section to work on */ - H5FS_iter_ud_t * udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ + H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1870,7 +1876,7 @@ H5FS__iterate_sect_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) static herr_t H5FS__iterate_node_cb(void *_item, void H5_ATTR_UNUSED *key, void *_udata) { - H5FS_node_t * fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ + H5FS_node_t *fspace_node = (H5FS_node_t *)_item; /* Free space size node to work on */ H5FS_iter_ud_t *udata = (H5FS_iter_ud_t *)_udata; /* Callback info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2082,11 +2088,11 @@ H5FS_sect_change_class(H5F_t *f, H5FS_t *fspace, H5FS_section_info_t *sect, uint } /* end else */ } /* end if */ - /* Check if the section's class change will affect the mergable list */ + /* Check if the section's class change will affect the mergeable list */ if ((old_cls->flags & H5FS_CLS_SEPAR_OBJ) != (new_cls->flags & H5FS_CLS_SEPAR_OBJ)) { - hbool_t to_mergable; /* Flag if the section is changing to a mergable section */ + hbool_t to_mergable; /* Flag if the section is changing to a mergeable section */ - /* Determine if this section is becoming mergable or is becoming separate */ + /* Determine if this section is becoming mergeable or is becoming separate */ if (old_cls->flags & H5FS_CLS_SEPAR_OBJ) to_mergable = TRUE; else @@ -2201,7 +2207,7 @@ H5FS__sect_assert(const H5FS_t *fspace) size_ghost_count = 0; while (curr_sect_node != NULL) { H5FS_section_class_t *cls; /* Class of section */ - H5FS_section_info_t * sect; /* Section */ + H5FS_section_info_t *sect; /* Section */ /* Get section node & it's class */ sect = (H5FS_section_info_t *)H5SL_item(curr_sect_node); @@ -2308,7 +2314,7 @@ H5FS_sect_try_shrink_eoa(H5F_t *f, H5FS_t *fspace, void *op_data) /* Check for last node in the merge list */ if (NULL != (last_node = H5SL_last(fspace->sinfo->merge_list))) { - H5FS_section_info_t * tmp_sect; /* Temporary free space section */ + H5FS_section_info_t *tmp_sect; /* Temporary free space section */ H5FS_section_class_t *tmp_sect_cls; /* Temporary section's class */ /* Get the pointer to the last section, from the last node */ diff --git a/src/H5FSstat.c b/src/H5FSstat.c index 2b181679d7f..91c9c13de26 100644 --- a/src/H5FSstat.c +++ b/src/H5FSstat.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5FStest.c b/src/H5FStest.c index cd452d1e1c8..d913480e479 100644 --- a/src/H5FStest.c +++ b/src/H5FStest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Faccum.c b/src/H5Faccum.c index aed5812e63e..21495e00103 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -852,7 +851,7 @@ herr_t H5F__accum_free(H5F_shared_t *f_sh, H5FD_mem_t H5_ATTR_UNUSED type, haddr_t addr, hsize_t size) { H5F_meta_accum_t *accum; /* Alias for file's metadata accumulator */ - H5FD_t * file; /* File driver pointer */ + H5FD_t *file; /* File driver pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Fcwfs.c b/src/H5Fcwfs.c index d689737566e..d048e413761 100644 --- a/src/H5Fcwfs.c +++ b/src/H5Fcwfs.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index 5157180e328..99dfca368e2 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -118,7 +117,7 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) if (f->shared->sblock->root_ent) /* Use real root group symbol table entry */ H5G__ent_debug(f->shared->sblock->root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL); else { - H5O_loc_t * root_oloc; /* Root object location */ + H5O_loc_t *root_oloc; /* Root object location */ H5G_entry_t root_ent; /* Constructed root symbol table entry */ /* Reset the root group entry */ diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index 81ffcdf51b6..1d241ae38f8 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 3f9a22ff49e..9d6ec174406 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -43,8 +42,8 @@ /* Structure for each entry in a file's external file cache */ typedef struct H5F_efc_ent_t { - char * name; /* Name of the file */ - H5F_t * file; /* File object */ + char *name; /* Name of the file */ + H5F_t *file; /* File object */ struct H5F_efc_ent_t *LRU_next; /* Next item in LRU list */ struct H5F_efc_ent_t *LRU_prev; /* Previous item in LRU list */ unsigned nopen; /* Number of times this file is currently opened by an EFC client */ @@ -52,14 +51,14 @@ typedef struct H5F_efc_ent_t { /* Structure for a shared file struct's external file cache */ struct H5F_efc_t { - H5SL_t * slist; /* Skip list of cached external files */ + H5SL_t *slist; /* Skip list of cached external files */ H5F_efc_ent_t *LRU_head; /* Head of LRU list. This is the least recently used file */ H5F_efc_ent_t *LRU_tail; /* Tail of LRU list. This is the most recently used file */ unsigned nfiles; /* Size of the external file cache */ unsigned max_nfiles; /* Maximum size of the external file cache */ unsigned nrefs; /* Number of times this file appears in another file's EFC */ int tag; /* Temporary variable used by H5F__efc_try_close() */ - H5F_shared_t * tmp_next; /* Next file in temporary list used by H5F__efc_try_close() */ + H5F_shared_t *tmp_next; /* Next file in temporary list used by H5F__efc_try_close() */ }; /* Private prototypes */ @@ -140,12 +139,12 @@ H5F__efc_create(unsigned max_nfiles) H5F_t * H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_efc_t * efc = NULL; /* External file cache for parent file */ - H5F_efc_ent_t * ent = NULL; /* Entry for target file in efc */ + H5F_efc_t *efc = NULL; /* External file cache for parent file */ + H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ hbool_t open_file = FALSE; /* Whether ent->file needs to be closed in case of error */ - H5P_genplist_t * plist; /* Property list pointer for FAPL */ + H5P_genplist_t *plist; /* Property list pointer for FAPL */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5F_t * ret_value = NULL; /* Return value */ + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -268,7 +267,7 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi else /* Allocate new entry */ if (NULL == (ent = H5FL_MALLOC(H5F_efc_ent_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Build new entry */ if (NULL == (ent->name = H5MM_strdup(name))) @@ -353,7 +352,7 @@ H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hi herr_t H5F_efc_close(H5F_t *parent, H5F_t *file) { - H5F_efc_t * efc = NULL; /* External file cache for parent file */ + H5F_efc_t *efc = NULL; /* External file cache for parent file */ H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ herr_t ret_value = SUCCEED; /* Return value */ @@ -450,7 +449,7 @@ H5F__efc_release_real(H5F_efc_t *efc) /* Sanity checks */ HDassert(efc); - /* Lock the EFC to prevent manipulation of the EFC wile we are releasing it. + /* Lock the EFC to prevent manipulation of the EFC while we are releasing it. * The EFC should never be locked when we enter this function because that * would require a cycle, a cycle would necessarily invoke * H5F__efc_try_close(), and that function checks the status of the lock @@ -650,7 +649,7 @@ static void H5F__efc_try_close_tag1(H5F_shared_t *sf, H5F_shared_t **tail) { H5F_efc_ent_t *ent = NULL; /* EFC entry */ - H5F_shared_t * esf; /* Convenience pointer to ent->file->shared */ + H5F_shared_t *esf; /* Convenience pointer to ent->file->shared */ FUNC_ENTER_STATIC_NOERR @@ -723,7 +722,7 @@ static void H5F__efc_try_close_tag2(H5F_shared_t *sf, H5F_shared_t **tail) { H5F_efc_ent_t *ent = NULL; /* EFC entry */ - H5F_shared_t * esf; /* Convenience pointer to ent->file->shared */ + H5F_shared_t *esf; /* Convenience pointer to ent->file->shared */ FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Ffake.c b/src/H5Ffake.c index 1aae0fd08a2..5e51293c50e 100644 --- a/src/H5Ffake.c +++ b/src/H5Ffake.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Fint.c b/src/H5Fint.c index a8039b2e853..e897d4f6509 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -51,13 +50,13 @@ /* Struct only used by functions H5F__get_objects and H5F__get_objects_cb */ typedef struct H5F_olist_t { H5I_type_t obj_type; /* Type of object to look for */ - hid_t * obj_id_list; /* Pointer to the list of open IDs to return */ - size_t * obj_id_count; /* Number of open IDs */ + hid_t *obj_id_list; /* Pointer to the list of open IDs to return */ + size_t *obj_id_count; /* Number of open IDs */ struct { hbool_t local; /* Set flag for "local" file searches */ union { H5F_shared_t *shared; /* Pointer to shared file to look inside */ - const H5F_t * file; /* Pointer to file to look inside */ + const H5F_t *file; /* Pointer to file to look inside */ } ptr; } file_info; size_t list_index; /* Current index in open ID array */ @@ -78,10 +77,10 @@ static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hbool_t app_ref, size_t *obj_id_count_ptr); static int H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name /*out*/); -static char * H5F__getenv_prefix_name(char **env_prefix /*in,out*/); +static char *H5F__getenv_prefix_name(char **env_prefix /*in,out*/); static H5F_t *H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); static herr_t H5F__check_if_using_file_locks(H5P_genplist_t *fapl, hbool_t *use_file_locking); -static herr_t H5F__dest(H5F_t *f, hbool_t flush); +static herr_t H5F__dest(H5F_t *f, hbool_t flush, hbool_t free_on_failure); static herr_t H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); static herr_t H5F__flush_phase1(H5F_t *f); @@ -304,7 +303,7 @@ static herr_t H5F__set_vol_conn(H5F_t *file) { H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - void * new_connector_info = NULL; /* Copy of connector info */ + void *new_connector_info = NULL; /* Copy of connector info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -360,8 +359,8 @@ H5F__set_vol_conn(H5F_t *file) hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref) { - H5P_genplist_t * new_plist; /* New property list */ - H5P_genplist_t * old_plist; /* Old property list */ + H5P_genplist_t *new_plist; /* New property list */ + H5P_genplist_t *old_plist; /* Old property list */ H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ @@ -840,9 +839,9 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c const char *file_name, unsigned file_intent, hid_t fapl_id) { H5F_t *src_file = NULL; /* Source file */ - char * full_name = NULL; /* File name with prefix */ - char * actual_file_name = NULL; /* File's actual name */ - char * temp_file_name = NULL; /* Temporary pointer to file name */ + char *full_name = NULL; /* File name with prefix */ + char *actual_file_name = NULL; /* File's actual name */ + char *temp_file_name = NULL; /* Temporary pointer to file name */ size_t temp_file_name_len; /* Length of temporary file name */ H5F_t *ret_value = NULL; /* Return value */ @@ -1058,9 +1057,9 @@ H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type, const c htri_t H5F__is_hdf5(const char *name, hid_t fapl_id) { - H5FD_t * file = NULL; /* Low-level file struct */ + H5FD_t *file = NULL; /* Low-level file struct */ H5F_shared_t *shared = NULL; /* Shared part of file */ - haddr_t sig_addr = HADDR_UNDEF; /* Addess of hdf5 file signature */ + haddr_t sig_addr = HADDR_UNDEF; /* Address of hdf5 file signature */ htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1157,7 +1156,7 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F /* Initialization for handling file space (for paged aggregation) */ f->shared->pgend_meta_thres = H5F_FILE_SPACE_PGEND_META_THRES; - /* intialize point of no return */ + /* initialize point of no return */ f->shared->point_of_no_return = FALSE; /* Copy the file creation and file access property lists into the @@ -1294,7 +1293,7 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; } - /* Determine the # of bins for metdata read retries */ + /* Determine the # of bins for metadata read retries */ if (H5F_set_retries(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't set retries and retries_nbins") @@ -1382,7 +1381,7 @@ H5F__new(H5F_shared_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F *------------------------------------------------------------------------- */ static herr_t -H5F__dest(H5F_t *f, hbool_t flush) +H5F__dest(H5F_t *f, hbool_t flush, hbool_t free_on_failure) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1648,7 +1647,9 @@ H5F__dest(H5F_t *f, hbool_t flush) if (H5FO_top_dest(f) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "problems closing file") f->shared = NULL; - f = H5FL_FREE(H5F_t, f); + + if ((ret_value >= 0) || free_on_failure) + f = H5FL_FREE(H5F_t, f); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__dest() */ @@ -1774,12 +1775,12 @@ H5F__check_if_using_file_locks(H5P_genplist_t *fapl, hbool_t *use_file_locking) H5F_t * H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_t * file = NULL; /*the success return value */ - H5F_shared_t * shared = NULL; /*shared part of `file' */ - H5FD_t * lf = NULL; /*file driver part of `shared' */ + H5F_t *file = NULL; /*the success return value */ + H5F_shared_t *shared = NULL; /*shared part of `file' */ + H5FD_t *lf = NULL; /*file driver part of `shared' */ unsigned tent_flags; /*tentative flags */ - H5FD_class_t * drvr; /*file driver class info */ - H5P_genplist_t * a_plist; /*file access property list */ + H5FD_class_t *drvr; /*file driver class info */ + H5P_genplist_t *a_plist; /*file access property list */ H5F_close_degree_t fc_degree; /*file close degree */ size_t page_buf_size; unsigned page_buf_min_meta_perc = 0; @@ -1790,7 +1791,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) hbool_t use_file_locking = TRUE; /* Using file locks? */ hbool_t ci_load = FALSE; /* whether MDC ci load requested */ hbool_t ci_write = FALSE; /* whether MDC CI write requested */ - H5F_t * ret_value = NULL; /*actual return value */ + H5F_t *ret_value = NULL; /*actual return value */ FUNC_ENTER_NOAPI(NULL) @@ -1819,7 +1820,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * or creating it) so we can compare it with files that are already * open. If that fails then we try again with the full set of flags * (only if they're different than the original failed attempt). - * However, if the file driver can't distinquish between files then + * However, if the file driver can't distinguish between files then * there's no reason to open the file tentatively because it's the * application's responsibility to prevent this situation (there's no * way for us to detect it here anyway). @@ -1829,16 +1830,52 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) else tent_flags = flags; - if (NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { - if (tent_flags == flags) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", - name, tent_flags) - H5E_clear_stack(NULL); - tent_flags = flags; + /* + * When performing a tentative open of a file where we have stripped away + * flags such as H5F_ACC_CREAT from the specified file access flags, the + * H5E_BEGIN/END_TRY macros are used to suppress error output since there + * is an expectation that the tentative open might fail. Even though we + * explicitly clear the error stack after such a failure, the underlying + * file driver might maintain its own error stack and choose whether to + * display errors based on whether the library has disabled error reporting. + * Since we wish to suppress that error output as well for the case of + * tentative file opens, surrounding the file open call with the + * H5E_BEGIN/END_TRY macros is an explicit instruction to the file driver + * not to display errors. If the tentative file open call fails, another + * attempt at opening the file will be made without error output being + * suppressed. + * + * However, if stripping away the H5F_ACC_CREAT flag and others left us + * with the same file access flags as before, then we will skip this + * tentative file open and only make a single attempt at opening the file. + * In this case, we don't want to suppress error output since the underlying + * file driver might provide more details on why the file open failed. + */ + if (tent_flags != flags) { + /* Make tentative attempt to open file */ + H5E_BEGIN_TRY + { + lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF); + } + H5E_END_TRY; + } + + /* + * If a tentative attempt to open the file wasn't necessary, attempt + * to open the file now. Otherwise, if the tentative open failed, clear + * the error stack and reset the file access flags, then make another + * attempt at opening the file. + */ + if ((tent_flags == flags) || (lf == NULL)) { + if (tent_flags != flags) { + H5E_clear_stack(NULL); + tent_flags = flags; + } + if (NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) - } /* end if */ + } /* Is the file already open? */ if ((shared = H5F__sfile_search(lf)) != NULL) { @@ -2108,7 +2145,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) done: if ((NULL == ret_value) && file) - if (H5F__dest(file, FALSE) < 0) + if (H5F__dest(file, FALSE, TRUE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) @@ -2518,7 +2555,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) * shared H5F_shared_t struct. If the reference count for the H5F_shared_t * struct reaches zero then destroy it also. */ - if (H5F__dest(f, TRUE) < 0) + if (H5F__dest(f, TRUE, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") /* Since we closed the file, this should be set to TRUE */ @@ -2686,7 +2723,7 @@ H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *n /* Check for symbolic link */ if (S_IFLNK == (lst.st_mode & S_IFMT)) { H5P_genplist_t *new_fapl; /* Duplicated FAPL */ - int * fd; /* POSIX I/O file descriptor */ + int *fd; /* POSIX I/O file descriptor */ h5_stat_t st; /* Stat info from stat() call */ h5_stat_t fst; /* Stat info from fstat() call */ hbool_t want_posix_fd; /* Flag for retrieving file descriptor from VFD */ @@ -2708,10 +2745,13 @@ H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *n if (NULL == (new_fapl = (H5P_genplist_t *)H5I_object(new_fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "can't get property list") - /* Set the character encoding on the new property list */ + /* + * Set the private property for retrieving the backing store + * POSIX file descriptor from the Core VFD + */ want_posix_fd = TRUE; if (H5P_set(new_fapl, H5F_ACS_WANT_POSIX_FD_NAME, &want_posix_fd) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set character encoding") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set property for retrieving file descriptor") /* Retrieve the file handle */ if (H5F_get_vfd_handle(f, new_fapl_id, (void **)&fd) < 0) @@ -3116,7 +3156,7 @@ H5F__get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * file driver. However, this test will not work if there is some * other file driver sitting on top of the multi file driver. * - * I'm not sure if this is possible at present, but in all likelyhood, + * I'm not sure if this is possible at present, but in all likelihood, * it will become possible in the future. On the other hand, we may * remove the split/multi file drivers before then. * @@ -3570,7 +3610,7 @@ H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info) * 1) The file being opened has v3 superblock * 2) The file is opened with H5F_ACC_RDWR * 3) The file is not already marked for SWMR writing - * 4) Current implementaion for opened objects: + * 4) Current implementation for opened objects: * --only allow datasets and groups without attributes * --disallow named datatype with/without attributes * --disallow opened attributes attached to objects @@ -3592,13 +3632,14 @@ H5F__start_swmr_write(H5F_t *f) hbool_t ci_write = FALSE; /* whether MDC CI write requested */ size_t grp_dset_count = 0; /* # of open objects: groups & datasets */ size_t nt_attr_count = 0; /* # of opened named datatypes + opened attributes */ - hid_t * obj_ids = NULL; /* List of ids */ - H5G_loc_t * obj_glocs = NULL; /* Group location of the object */ - H5O_loc_t * obj_olocs = NULL; /* Object location */ + hid_t *obj_ids = NULL; /* List of ids */ + hid_t *obj_apl_ids = NULL; /* List of access property lists */ + H5G_loc_t *obj_glocs = NULL; /* Group location of the object */ + H5O_loc_t *obj_olocs = NULL; /* Object location */ H5G_name_t *obj_paths = NULL; /* Group hierarchy path */ size_t u; /* Local index variable */ hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ - H5VL_t * vol_connector = NULL; /* VOL connector for the file */ + H5VL_t *vol_connector = NULL; /* VOL connector for the file */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3651,13 +3692,20 @@ H5F__start_swmr_write(H5F_t *f) if (grp_dset_count > 0) { /* Allocate space for group and object locations */ if ((obj_ids = (hid_t *)H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t") + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate buffer for hid_t") if ((obj_glocs = (H5G_loc_t *)H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_loc_t") + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate buffer for object group locations") if ((obj_olocs = (H5O_loc_t *)H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5O_loc_t") + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate buffer for object locations") if ((obj_paths = (H5G_name_t *)H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_name_t") + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate buffer for object paths") + + /* Taking a shortcut here to use calloc to initialize obj_apl_ids to all H5P_DEFAULT. If + * this changes in the future we'll need to either initialize this array to all H5P_DEFAULT + * or ensure 0 cannot be a valid value and check for 0 at cleanup. */ + if ((obj_apl_ids = (hid_t *)H5MM_calloc(grp_dset_count * sizeof(hid_t))) == NULL) + HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "can't allocate buffer for hid_t") + HDassert(obj_apl_ids[0] == H5P_DEFAULT); /* Get the list of opened object ids (groups & datasets) */ if (H5F_get_obj_ids(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, @@ -3679,20 +3727,67 @@ H5F__start_swmr_write(H5F_t *f) /* Gather information about opened objects (groups, datasets) in the file */ /* (For refresh later on) */ for (u = 0; u < grp_dset_count; u++) { - H5O_loc_t *oloc; /* object location */ + void *obj = NULL; /* VOL object */ + H5I_type_t type; /* Type of object for the ID */ H5G_loc_t tmp_loc; + /* Get object's type */ + type = H5I_get_type(obj_ids[u]); + + /* Get the object from the VOL */ + if (NULL == (obj = H5VL_object(obj_ids[u]))) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the object's access property list, if it is a dataset (access + * properties are not needed to reopen other object types currently) + */ + switch (type) { + case H5I_GROUP: + /* Access properties not needed currently */ + break; + + case H5I_DATATYPE: + /* Access properties not needed currently */ + break; + + case H5I_DATASET: + + /* Get dataset access properties */ + if ((obj_apl_ids[u] = H5D_get_access_plist(obj)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, + "unable to get dataset access property list") + break; + + case H5I_MAP: + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector") + + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_DATASPACE: + case H5I_ATTR: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_SPACE_SEL_ITER: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, + "not a valid file object ID (dataset, group, or datatype)") + break; + } /* end switch */ + /* Set up the id's group location */ obj_glocs[u].oloc = &obj_olocs[u]; obj_glocs[u].path = &obj_paths[u]; H5G_loc_reset(&obj_glocs[u]); - /* get the id's object location */ - if ((oloc = H5O_get_loc(obj_ids[u])) == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object") - /* Make deep local copy of object's location information */ - H5G_loc(obj_ids[u], &tmp_loc); + H5G_loc_real(obj, type, &tmp_loc); H5G_loc_copy(&obj_glocs[u], &tmp_loc, H5_COPY_DEEP); /* Close the object */ @@ -3752,7 +3847,7 @@ H5F__start_swmr_write(H5F_t *f) /* Refresh (reopen) the objects (groups & datasets) in the file */ for (u = 0; u < grp_dset_count; u++) - if (H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], vol_connector, TRUE) < 0) + if (H5O_refresh_metadata_reopen(obj_ids[u], obj_apl_ids[u], &obj_glocs[u], vol_connector, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object") /* Unlock the file */ @@ -3761,7 +3856,6 @@ H5F__start_swmr_write(H5F_t *f) done: if (ret_value < 0 && setup) { - /* Re-enable accumulator */ f->shared->feature_flags |= (unsigned)H5FD_FEAT_ACCUMULATE_METADATA; if (H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) @@ -3797,6 +3891,14 @@ H5F__start_swmr_write(H5F_t *f) if (obj_paths) H5MM_xfree(obj_paths); + /* Free access property lists */ + if (obj_apl_ids) { + for (u = 0; u < grp_dset_count; u++) + if (obj_apl_ids[u] != H5P_DEFAULT && obj_apl_ids[u] >= 0 && H5I_dec_ref(obj_apl_ids[u]) < 0) + HDONE_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "decrementing property list ID failed") + H5MM_xfree(obj_apl_ids); + } + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__start_swmr_write() */ @@ -3877,7 +3979,7 @@ H5F__format_convert(H5F_t *f) hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref) { - void * vol_obj_file = NULL; /* File object pointer */ + void *vol_obj_file = NULL; /* File object pointer */ H5VL_loc_params_t loc_params; /* Location parameters */ hid_t file_id = H5I_INVALID_HID; /* File ID for object */ hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ diff --git a/src/H5Fio.c b/src/H5Fio.c index 5a9d2c17c87..f51df0588f5 100644 --- a/src/H5Fio.c +++ b/src/H5Fio.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Fmodule.h b/src/H5Fmodule.h index 7f0299a0b05..6939f4ac23d 100644 --- a/src/H5Fmodule.h +++ b/src/H5Fmodule.h @@ -29,8 +29,1166 @@ #define H5_MY_PKG_ERR H5E_FILE #define H5_MY_PKG_INIT YES +/** \page H5F_UG The HDF5 File + * + * \section sec_file The HDF5 File + * \subsection subsec_file_intro Introduction + * The purpose of this chapter is to describe how to work with HDF5 data files. + * + * If HDF5 data is to be written to or read from a file, the file must first be explicitly created or + * opened with the appropriate file driver and access privileges. Once all work with the file is + * complete, the file must be explicitly closed. + * + * This chapter discusses the following: + * \li File access modes + * \li Creating, opening, and closing files + * \li The use of file creation property lists + * \li The use of file access property lists + * \li The use of low-level file drivers + * + * This chapter assumes an understanding of the material presented in the data model chapter. For + * more information, @see @ref sec_data_model. + * + * \subsection subsec_file_access_modes File Access Modes + * There are two issues regarding file access: + *
  • What should happen when a new file is created but a file of the same name already + * exists? Should the create action fail, or should the existing file be overwritten?
  • + *
  • Is a file to be opened with read-only or read-write access?
+ * + * Four access modes address these concerns. Two of these modes can be used with #H5Fcreate, and + * two modes can be used with #H5Fopen. + * \li #H5Fcreate accepts #H5F_ACC_EXCL or #H5F_ACC_TRUNC + * \li #H5Fopen accepts #H5F_ACC_RDONLY or #H5F_ACC_RDWR + * + * The access modes are described in the table below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Access flags and modes
Access FlagResulting Access Mode
#H5F_ACC_EXCLIf the file already exists, #H5Fcreate fails. If the file does not exist, + * it is created and opened with read-write access. (Default)
#H5F_ACC_TRUNCIf the file already exists, the file is opened with read-write access, + * and new data will overwrite any existing data. If the file does not exist, + * it is created and opened with read-write access.
#H5F_ACC_RDONLYAn existing file is opened with read-only access. If the file does not + * exist, #H5Fopen fails. (Default)
#H5F_ACC_RDWRAn existing file is opened with read-write access. If the file does not + * exist, #H5Fopen fails.
+ * + * By default, #H5Fopen opens a file for read-only access; passing #H5F_ACC_RDWR allows + * read-write access to the file. + * + * By default, #H5Fcreate fails if the file already exists; only passing #H5F_ACC_TRUNC allows + * the truncating of an existing file. + * + * \subsection subsec_file_creation_access File Creation and File Access Properties + * File creation and file access property lists control the more complex aspects of creating and + * accessing files. + * + * File creation property lists control the characteristics of a file such as the size of the userblock, + * a user-definable data block; the size of data address parameters; properties of the B-trees that are + * used to manage the data in the file; and certain HDF5 Library versioning information. + * + * For more information, @see @ref subsubsec_file_property_lists_props. + * + * This section has a more detailed discussion of file creation properties. If you have no special + * requirements for these file characteristics, you can simply specify #H5P_DEFAULT for the default + * file creation property list when a file creation property list is called for. + * + * File access property lists control properties and means of accessing a file such as data alignment + * characteristics, metadata block and cache sizes, data sieve buffer size, garbage collection + * settings, and parallel I/O. Data alignment, metadata block and cache sizes, and data sieve buffer + * size are factors in improving I/O performance. + * + * For more information, @see @ref subsubsec_file_property_lists_access. + * + * This section has a more detailed discussion of file access properties. If you have no special + * requirements for these file access characteristics, you can simply specify #H5P_DEFAULT for the + * default file access property list when a file access property list is called for. + * + * + * + * + * + * + *
Figure 10 - More sample file structures
+ * \image html UML_FileAndProps.gif "UML model for an HDF5 file and its property lists" + *
+ * + * \subsection subsec_file_drivers Low-level File Drivers + * The concept of an HDF5 file is actually rather abstract: the address space for what is normally + * thought of as an HDF5 file might correspond to any of the following at the storage level: + * \li Single file on a standard file system + * \li Multiple files on a standard file system + * \li Multiple files on a parallel file system + * \li Block of memory within an application’s memory space + * \li More abstract situations such as virtual files + * + * This HDF5 address space is generally referred to as an HDF5 file regardless of its organization at + * the storage level. + * + * HDF5 accesses a file (the address space) through various types of low-level file drivers. The + * default HDF5 file storage layout is as an unbuffered permanent file which is a single, contiguous + * file on local disk. Alternative layouts are designed to suit the needs of a variety of systems, + * environments, and applications. + * + * \subsection subsec_file_program_model Programming Model for Files + * Programming models for creating, opening, and closing HDF5 files are described in the + * sub-sections below. + * + * \subsubsection subsubsec_file_program_model_create Creating a New File + * The programming model for creating a new HDF5 file can be summarized as follows: + * \li Define the file creation property list + * \li Define the file access property list + * \li Create the file + * + * First, consider the simple case where we use the default values for the property lists. See the + * example below. + * + * Creating an HDF5 file using property list defaults + * \code + * file_id = H5Fcreate ("SampleFile.h5", H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT) + * \endcode + * + * Note: The example above specifies that #H5Fcreate should fail if SampleFile.h5 already exists. + * + * A more complex case is shown in the example below. In this example, we define file creation + * and access property lists (though we do not assign any properties), specify that #H5Fcreate + * should fail if SampleFile.h5 already exists, and create a new file named SampleFile.h5. The example + * does not specify a driver, so the default driver, #H5FD_SEC2, will be used. + * + * Creating an HDF5 file using property lists + * \code + * fcplist_id = H5Pcreate (H5P_FILE_CREATE) + * <...set desired file creation properties...> + * faplist_id = H5Pcreate (H5P_FILE_ACCESS) + * <...set desired file access properties...> + * file_id = H5Fcreate ("SampleFile.h5", H5F_ACC_EXCL, fcplist_id, faplist_id) + * \endcode + * Notes: + * 1. A root group is automatically created in a file when the file is first created. + * + * 2. File property lists, once defined, can be reused when another file is created within the same + * application. + * + * \subsubsection subsubsec_file_program_model_open Opening an Existing File + * The programming model for opening an existing HDF5 file can be summarized as follows: + *
  • Define or modify the file access property list including a low-level file driver (optional)
  • + *
  • Open the file
+ * + * The code in the example below shows how to open an existing file with read-only access. + * + * Opening an HDF5 file + * \code + * faplist_id = H5Pcreate (H5P_FILE_ACCESS) + * status = H5Pset_fapl_stdio (faplist_id) + * file_id = H5Fopen ("SampleFile.h5", H5F_ACC_RDONLY, faplist_id) + * \endcode + * + * \subsubsection subsubsec_file_program_model_close Closing a File + * The programming model for closing an HDF5 file is very simple: + * \li Close file + * + * We close SampleFile.h5 with the code in the example below. + * + * Closing an HDF5 file + * \code + * status = H5Fclose (file_id) + * \endcode + * Note that #H5Fclose flushes all unwritten data to storage and that file_id is the identifier returned + * for SampleFile.h5 by #H5Fopen. + * + * More comprehensive discussions regarding all of these steps are provided below. + * + * \subsection subsec_file_h5dump Using h5dump to View a File + * h5dump is a command-line utility that is included in the HDF5 distribution. This program + * provides a straight-forward means of inspecting the contents of an HDF5 file. You can use + * h5dump to verify that a program is generating the intended HDF5 file. h5dump displays ASCII + * output formatted according to the HDF5 DDL grammar. + * + * The following h5dump command will display the contents of SampleFile.h5: + * \code + * h5dump SampleFile.h5 + * \endcode + * + * If no datasets or groups have been created in and no data has been written to the file, the output + * will look something like the following: + * \code + * HDF5 "SampleFile.h5" { + * GROUP "/" { + * } + * } + * \endcode + * + * Note that the root group, indicated above by /, was automatically created when the file was created. + * + * h5dump is described on the + * Tools + * page under + * + * Libraries and Tools Reference. + * The HDF5 DDL grammar is described in the document \ref DDLBNF110. + * + * \subsection subsec_file_summary File Function Summaries + * General library (\ref H5 functions and macros), (\ref H5F functions), file related + * (\ref H5P functions), and file driver (\ref H5P functions) are listed below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
General library functions and macros
FunctionPurpose
#H5check_versionVerifies that HDF5 library versions are consistent.
#H5closeFlushes all data to disk, closes all open identifiers, and cleans up memory.
#H5dont_atexitInstructs the library not to install the atexit cleanup routine.
#H5garbage_collectGarbage collects on all free-lists of all types.
#H5get_libversionReturns the HDF library release number.
#H5openInitializes the HDF5 library.
#H5set_free_list_limitsSets free-list size limits.
#H5_VERSION_GEDetermines whether the version of the library being used is greater than or equal + * to the specified version.
#H5_VERSION_LEDetermines whether the version of the library being used is less than or equal + * to the specified version.
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
File functions
FunctionPurpose
#H5Fclear_elink_file_cacheClears the external link open file cache for a file.
#H5FcloseCloses HDF5 file.
#H5FcreateCreates new HDF5 file.
#H5FflushFlushes data to HDF5 file on storage medium.
#H5Fget_access_plistReturns a file access property list identifier.
#H5Fget_create_plistReturns a file creation property list identifier.
#H5Fget_file_imageRetrieves a copy of the image of an existing, open file.
#H5Fget_filesizeReturns the size of an HDF5 file.
#H5Fget_freespaceReturns the amount of free space in a file.
#H5Fget_infoReturns global information for a file.
#H5Fget_intentDetermines the read/write or read-only status of a file.
#H5Fget_mdc_configObtain current metadata cache configuration for target file.
#H5Fget_mdc_hit_rateObtain target file’s metadata cache hit rate.
#H5Fget_mdc_sizeObtain current metadata cache size data for specified file.
#H5Fget_mpi_atomicityRetrieves the atomicity mode in use.
#H5Fget_nameRetrieves the name of the file to which the object belongs.
#H5Fget_obj_countReturns the number of open object identifiers for an open file.
#H5Fget_obj_idsReturns a list of open object identifiers.
#H5Fget_vfd_handleReturns pointer to the file handle from the virtual file driver.
#H5Fis_hdf5Determines whether a file is in the HDF5 format.
#H5FmountMounts a file.
#H5FopenOpens an existing HDF5 file.
#H5FreopenReturns a new identifier for a previously-opened HDF5 file.
#H5Freset_mdc_hit_rate_statsReset hit rate statistics counters for the target file.
#H5Fset_mdc_configUse to configure metadata cache of target file.
#H5Fset_mpi_atomicityUse to set the MPI atomicity mode.
#H5FunmountUnmounts a file.
+ * + * \anchor fcpl_table_tag File creation property list functions (H5P) + * \snippet{doc} tables/propertyLists.dox fcpl_table + * + * \anchor fapl_table_tag File access property list functions (H5P) + * \snippet{doc} tables/propertyLists.dox fapl_table + * + * \anchor fd_pl_table_tag File driver property list functions (H5P) + * \snippet{doc} tables/propertyLists.dox fd_pl_table + * + * + * \subsection subsec_file_create Creating or Opening an HDF5 File + * This section describes in more detail how to create and how to open files. + * + * New HDF5 files are created and opened with #H5Fcreate; existing files are opened with + * #H5Fopen. Both functions return an object identifier which must eventually be released by calling + * #H5Fclose. + * + * To create a new file, call #H5Fcreate: + * \code + * hid_t H5Fcreate (const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) + * \endcode + * + * #H5Fcreate creates a new file named name in the current directory. The file is opened with read + * and write access; if the #H5F_ACC_TRUNC flag is set, any pre-existing file of the same name in + * the same directory is truncated. If #H5F_ACC_TRUNC is not set or #H5F_ACC_EXCL is set and + * if a file of the same name exists, #H5Fcreate will fail. + * + * The new file is created with the properties specified in the property lists fcpl_id and fapl_id. + * fcpl is short for file creation property list. fapl is short for file access property list. Specifying + * #H5P_DEFAULT for either the creation or access property list will use the library’s default + * creation or access properties. + * + * If #H5Fcreate successfully creates the file, it returns a file identifier for the new file. This + * identifier will be used by the application any time an object identifier, an OID, for the file is + * required. Once the application has finished working with a file, the identifier should be released + * and the file closed with #H5Fclose. + * + * To open an existing file, call #H5Fopen: + * \code + * hid_t H5Fopen (const char *name, unsigned flags, hid_t fapl_id) + * \endcode + * + * #H5Fopen opens an existing file with read-write access if #H5F_ACC_RDWR is set and read-only + * access if #H5F_ACC_RDONLY is set. + * + * fapl_id is the file access property list identifier. Alternatively, #H5P_DEFAULT indicates that the + * application relies on the default I/O access parameters. Creating and changing access property + * lists is documented further below. + * + * A file can be opened more than once via multiple #H5Fopen calls. Each such call returns a unique + * file identifier and the file can be accessed through any of these file identifiers as long as they + * remain valid. Each of these file identifiers must be released by calling #H5Fclose when it is no + * longer needed. + * + * For more information, @see @ref subsubsec_file_property_lists_access. + * For more information, @see @ref subsec_file_property_lists. + * + * \subsection subsec_file_closes Closing an HDF5 File + * #H5Fclose both closes a file and releases the file identifier returned by #H5Fopen or #H5Fcreate. + * #H5Fclose must be called when an application is done working with a file; while the HDF5 + * Library makes every effort to maintain file integrity, failure to call #H5Fclose may result in the + * file being abandoned in an incomplete or corrupted state. + * + * To close a file, call #H5Fclose: + * \code + * herr_t H5Fclose (hid_t file_id) + * \endcode + * This function releases resources associated with an open file. After closing a file, the file + * identifier, file_id, cannot be used again as it will be undefined. + * + * #H5Fclose fulfills three purposes: to ensure that the file is left in an uncorrupted state, to ensure + * that all data has been written to the file, and to release resources. Use #H5Fflush if you wish to + * ensure that all data has been written to the file but it is premature to close it. + * + * Note regarding serial mode behavior: When #H5Fclose is called in serial mode, it closes the file + * and terminates new access to it, but it does not terminate access to objects that remain + * individually open within the file. That is, if #H5Fclose is called for a file but one or more objects + * within the file remain open, those objects will remain accessible until they are individually + * closed. To illustrate, assume that a file, fileA, contains a dataset, data_setA, and that both are + * open when #H5Fclose is called for fileA. data_setA will remain open and accessible, including + * writable, until it is explicitly closed. The file will be automatically and finally closed once all + * objects within it have been closed. + * + * Note regarding parallel mode behavior: Once #H5Fclose has been called in parallel mode, access + * is no longer available to any object within the file. + * + * \subsection subsec_file_property_lists File Property Lists + * Additional information regarding file structure and access are passed to #H5Fcreate and + * #H5Fopen through property list objects. Property lists provide a portable and extensible method of + * modifying file properties via simple API functions. There are two kinds of file-related property + * lists: + * \li File creation property lists + * \li File access property lists + * + * In the following sub-sections, we discuss only one file creation property, userblock size, in detail + * as a model for the user. Other file creation and file access properties are mentioned and defined + * briefly, but the model is not expanded for each; complete syntax, parameter, and usage + * information for every property list function is provided in the \ref H5P + * section of the HDF5 Reference Manual. + * + * For more information, @see @ref sec_plist. + * + * \subsubsection subsubsec_file_property_lists_create Creating a Property List + * If you do not wish to rely on the default file creation and access properties, you must first create + * a property list with #H5Pcreate. + * \code + * hid_t H5Pcreate (hid_t cls_id) + * \endcode + * cls_id is the type of property list being created. In this case, the appropriate values are + * #H5P_FILE_CREATE for a file creation property list and #H5P_FILE_ACCESS for a file access + * property list. + * + * Thus, the following calls create a file creation property list and a file access property list with + * identifiers fcpl_id and fapl_id, respectively: + * \code + * fcpl_id = H5Pcreate (H5P_FILE_CREATE) + * fapl_id = H5Pcreate (H5P_FILE_ACCESS) + * \endcode + * + * Once the property lists have been created, the properties themselves can be modified via the + * functions described in the following sub-sections. + * + * \subsubsection subsubsec_file_property_lists_props File Creation Properties + * File creation property lists control the file metadata, which is maintained in the superblock of the + * file. These properties are used only when a file is first created. + * + *

Userblock Size

+ * \code + * herr_t H5Pset_userblock (hid_t plist, hsize_t size) + * herr_t H5Pget_userblock (hid_t plist, hsize_t *size) + * \endcode + * + * The userblock is a fixed-length block of data located at the beginning of the file and is ignored + * by the HDF5 library. This block is specifically set aside for any data or information that + * developers determine to be useful to their applications but that will not be used by the HDF5 + * library. The size of the userblock is defined in bytes and may be set to any power of two with a + * minimum size of 512 bytes. In other words, userblocks might be 512, 1024, or 2048 bytes in + * size. + * + * This property is set with #H5Pset_userblock and queried via #H5Pget_userblock. For example, if + * an application needed a 4K userblock, then the following function call could be used: + * \code + * status = H5Pset_userblock(fcpl_id, 4096) + * \endcode + * + * The property list could later be queried with: + * \code + * status = H5Pget_userblock(fcpl_id, size) + * \endcode + * and the value 4096 would be returned in the parameter size. + * + * Other properties, described below, are set and queried in exactly the same manner. Syntax and + * usage are detailed in the @ref H5P section of the HDF5 Reference Manual. + * + *

Offset and Length Sizes

+ * This property specifies the number of bytes used to store the offset and length of objects in the + * HDF5 file. Values of 2, 4, and 8 bytes are currently supported to accommodate 16-bit, 32-bit, + * and 64-bit file address spaces. + * + * These properties are set and queried via #H5Pset_sizes and #H5Pget_sizes. + * + *

Symbol Table Parameters

+ * The size of symbol table B-trees can be controlled by setting the 1/2-rank and 1/2-node size + * parameters of the B-tree. + * + * These properties are set and queried via #H5Pset_sym_k and #H5Pget_sym_k + * + *

Indexed Storage Parameters

+ * The size of indexed storage B-trees can be controlled by setting the 1/2-rank and 1/2-node size + * parameters of the B-tree. + * + * These properties are set and queried via #H5Pset_istore_k and #H5Pget_istore_k. + * + *

Version Information

+ * Various objects in an HDF5 file may over time appear in different versions. The HDF5 Library + * keeps track of the version of each object in the file. + * + * Version information is retrieved via #H5Pget_version. + * + * \subsubsection subsubsec_file_property_lists_access File Access Properties + * This section discusses file access properties that are not related to the low-level file drivers. File + * drivers are discussed separately later in this chapter. + * For more information, @see @ref subsec_file_alternate_drivers. + * + * File access property lists control various aspects of file I/O and structure. + * + *

Data Alignment

+ * Sometimes file access is faster if certain data elements are aligned in a specific manner. This can + * be controlled by setting alignment properties via the #H5Pset_alignment function. There are two + * values involved: + * \li A threshold value + * \li An alignment interval + * + * Any allocation request at least as large as the threshold will be aligned on an address that is a + * multiple of the alignment interval. + * + *

Metadata Block Allocation Size

+ * Metadata typically exists as very small chunks of data; storing metadata elements in a file + * without blocking them can result in hundreds or thousands of very small data elements in the + * file. This can result in a highly fragmented file and seriously impede I/O. By blocking metadata + * elements, these small elements can be grouped in larger sets, thus alleviating both problems. + * + * #H5Pset_meta_block_size sets the minimum size in bytes of metadata block allocations. + * #H5Pget_meta_block_size retrieves the current minimum metadata block allocation size. + * + *

Metadata Cache

+ * Metadata and raw data I/O speed are often governed by the size and frequency of disk reads and + * writes. In many cases, the speed can be substantially improved by the use of an appropriate + * cache. + * + * #H5Pset_cache sets the minimum cache size for both metadata and raw data and a preemption + * value for raw data chunks. #H5Pget_cache retrieves the current values. + * + *

Data Sieve Buffer Size

+ * Data sieve buffering is used by certain file drivers to speed data I/O and is most commonly when + * working with dataset hyperslabs. For example, using a buffer large enough to hold several pieces + * of a dataset as it is read in for hyperslab selections will boost performance noticeably. + * + * #H5Pset_sieve_buf_size sets the maximum size in bytes of the data sieve buffer. + * #H5Pget_sieve_buf_size retrieves the current maximum size of the data sieve buffer. + * + *

Garbage Collection References

+ * Dataset region references and other reference types use space in an HDF5 file’s global heap. If + * garbage collection is on (1) and the user passes in an uninitialized value in a reference structure, + * the heap might become corrupted. When garbage collection is off (0), however, and the user reuses + * a reference, the previous heap block will be orphaned and not returned to the free heap + * space. When garbage collection is on, the user must initialize the reference structures to 0 or risk + * heap corruption. + * + * #H5Pset_gc_references sets the garbage collecting references flag. + * + * \subsection subsec_file_alternate_drivers Alternate File Storage Layouts and Low-level File Drivers + * The concept of an HDF5 file is actually rather abstract: the address space for what is normally + * thought of as an HDF5 file might correspond to any of the following: + * \li Single file on standard file system + * \li Multiple files on standard file system + * \li Multiple files on parallel file system + * \li Block of memory within application’s memory space + * \li More abstract situations such as virtual files + * + * This HDF5 address space is generally referred to as an HDF5 file regardless of its organization at + * the storage level. + * + * HDF5 employs an extremely flexible mechanism called the virtual file layer, or VFL, for file + * I/O. A full understanding of the VFL is only necessary if you plan to write your own drivers + * @see \ref VFL in the HDF5 Technical Notes. + * + * For our + * purposes here, it is sufficient to know that the low-level drivers used for file I/O reside in the + * VFL, as illustrated in the following figure. Note that H5FD_STREAM is not available with 1.8.x + * and later versions of the library. + * + * + * + * + * + *
+ * \image html VFL_Drivers.gif "I/O path from application to VFL and low-level drivers to storage" + *
+ * + * As mentioned above, HDF5 applications access HDF5 files through various low-level file + * drivers. The default driver for that layout is the POSIX driver (also known as the SEC2 driver), + * #H5FD_SEC2. Alternative layouts and drivers are designed to suit the needs of a variety of + * systems, environments, and applications. The drivers are listed in the table below. + * + * \snippet{doc} tables/fileDriverLists.dox supported_file_driver_table + * + * For more information, see the HDF5 Reference Manual entries for the function calls shown in + * the column on the right in the table above. + * + * Note that the low-level file drivers manage alternative file storage layouts. Dataset storage + * layouts (chunking, compression, and external dataset storage) are managed independently of file + * storage layouts. + * + * If an application requires a special-purpose low-level driver, the VFL provides a public API for + * creating one. For more information on how to create a driver, + * @see @ref VFL in the HDF5 Technical Notes. + * + * \subsubsection subsubsec_file_alternate_drivers_id Identifying the Previouslyâ€used File Driver + * When creating a new HDF5 file, no history exists, so the file driver must be specified if it is to be + * other than the default. + * + * When opening existing files, however, the application may need to determine which low-level + * driver was used to create the file. The function #H5Pget_driver is used for this purpose. See the + * example below. + * + * Identifying a driver + * \code + * hid_t H5Pget_driver (hid_t fapl_id) + * \endcode + * + * #H5Pget_driver returns a constant identifying the low-level driver for the access property list + * fapl_id. For example, if the file was created with the POSIX (aka SEC2) driver, + * #H5Pget_driver returns #H5FD_SEC2. + * + * If the application opens an HDF5 file without both determining the driver used to create the file + * and setting up the use of that driver, the HDF5 Library will examine the superblock and the + * driver definition block to identify the driver. + * See the HDF5 File Format Specification + * for detailed descriptions of the superblock and the driver definition block. + * + * \subsubsection subsubsec_file_alternate_drivers_sec2 The POSIX (aka SEC2) Driver + * The POSIX driver, #H5FD_SEC2, uses functions from section 2 of the POSIX manual to access + * unbuffered files stored on a local file system. This driver is also known as the SEC2 driver. The + * HDF5 Library buffers metadata regardless of the low-level driver, but using this driver prevents + * data from being buffered again by the lowest layers of the library. + * + * The function #H5Pset_fapl_sec2 sets the file access properties to use the POSIX driver. See the + * example below. + * + * Using the POSIX, aka SEC2, driver + * \code + * herr_t H5Pset_fapl_sec2 (hid_t fapl_id) + * \endcode + * + * Any previously-defined driver properties are erased from the property list. + * + * Additional parameters may be added to this function in the future. Since there are no additional + * variable settings associated with the POSIX driver, there is no H5Pget_fapl_sec2 function. + * + * \subsubsection subsubsec_file_alternate_drivers_direct The Direct Driver + * The Direct driver, #H5FD_DIRECT, functions like the POSIX driver except that data is written to + * or read from the file synchronously without being cached by the system. + * + * The functions #H5Pset_fapl_direct and #H5Pget_fapl_direct are used to manage file access properties. + * See the example below. + * + * Using the Direct driver + * \code + * herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t alignment, size_t block_size, size_t cbuf_size) + * herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *alignment, size_t *block_size, size_t *cbuf_size) + * \endcode + * + * #H5Pset_fapl_direct sets the file access properties to use the Direct driver; any previously defined + * driver properties are erased from the property list. #H5Pget_fapl_direct retrieves the file access + * properties used with the Direct driver. fapl_id is the file access property list identifier. + * alignment is the memory alignment boundary. block_size is the file system block size. + * cbuf_size is the copy buffer size. + * + * Additional parameters may be added to this function in the future. + * + * \subsubsection subsubsec_file_alternate_drivers_log The Log Driver + * The Log driver, #H5FD_LOG, is designed for situations where it is necessary to log file access + * activity. + * + * The function #H5Pset_fapl_log is used to manage logging properties. See the example below. + * + * Logging file access + * \code + * herr_t H5Pset_fapl_log (hid_t fapl_id, const char *logfile, unsigned int flags, size_t buf_size) + * \endcode + * + * #H5Pset_fapl_log sets the file access property list to use the Log driver. File access characteristics + * are identical to access via the POSIX driver. Any previously defined driver properties are erased + * from the property list. + * + * Log records are written to the file logfile. + * + * The logging levels set with the verbosity parameter are shown in the table below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Logging levels
LevelComments
0Performs no logging.
1Records where writes and reads occur in the file.
2Records where writes and reads occur in the file and what kind of data is written + * at each location. This includes raw data or any of several types of metadata + * (object headers, superblock, B-tree data, local headers, or global headers).
+ * + * There is no H5Pget_fapl_log function. + * + * Additional parameters may be added to this function in the future. + * + * \subsubsection subsubsec_file_alternate_drivers_win The Windows Driver + * The Windows driver, #H5FD_WINDOWS, was modified in HDF5-1.8.8 to be a wrapper of the + * POSIX driver, #H5FD_SEC2. In other words, if the Windows drivers is used, any file I/O will + * instead use the functionality of the POSIX driver. This change should be transparent to all user + * applications. The Windows driver used to be the default driver for Windows systems. The + * POSIX driver is now the default. + * + * The function #H5Pset_fapl_windows sets the file access properties to use the Windows driver. + * See the example below. + * + * Using the Windows driver + * \code + * herr_t H5Pset_fapl_windows (hid_t fapl_id) + * \endcode + * + * Any previously-defined driver properties are erased from the property list. + * + * Additional parameters may be added to this function in the future. Since there are no additional + * variable settings associated with the POSIX driver, there is no H5Pget_fapl_windows function. + * + * \subsubsection subsubsec_file_alternate_drivers_stdio The STDIO Driver + * The STDIO driver, #H5FD_STDIO, accesses permanent files in a local file system like the + * POSIX driver does. The STDIO driver also has an additional layer of buffering beneath the + * HDF5 Library. + * + * The function #H5Pset_fapl_stdio sets the file access properties to use the STDIO driver. See the + * example below. + * + * Using the STDIO driver + * \code + * herr_t H5Pset_fapl_stdio (hid_t fapl_id) + * \endcode + * + * Any previously defined driver properties are erased from the property list. + * + * Additional parameters may be added to this function in the future. Since there are no additional + * variable settings associated with the STDIO driver, there is no H5Pget_fapl_stdio function. + * + * \subsubsection subsubsec_file_alternate_drivers_mem The Memory (aka Core) Driver + * There are several situations in which it is reasonable, sometimes even required, to maintain a file + * entirely in system memory. You might want to do so if, for example, either of the following + * conditions apply: + *
  • Performance requirements are so stringent that disk latency is a limiting factor
  • + *
  • You are working with small, temporary files that will not be retained and, thus, + * need not be written to storage media
+ * + * The Memory driver, #H5FD_CORE, provides a mechanism for creating and managing such in memory files. + * The functions #H5Pset_fapl_core and #H5Pget_fapl_core manage file access + * properties. See the example below. + * + * Managing file access for in-memory files + * \code + * herr_t H5Pset_fapl_core (hid_t access_properties, size_t block_size, hbool_t backing_store) + * herr_t H5Pget_fapl_core (hid_t access_properties, size_t *block_size), hbool_t *backing_store) + * \endcode + * + * #H5Pset_fapl_core sets the file access property list to use the Memory driver; any previously + * defined driver properties are erased from the property list. + * + * Memory for the file will always be allocated in units of the specified block_size. + * + * The backing_store Boolean flag is set when the in-memory file is created. + * backing_store indicates whether to write the file contents to disk when the file is closed. If + * backing_store is set to 1 (TRUE), the file contents are flushed to a file with the same name as the + * in-memory file when the file is closed or access to the file is terminated in memory. If + * backing_store is set to 0 (FALSE), the file is not saved. + * + * The application is allowed to open an existing file with the #H5FD_CORE driver. While using + * #H5Fopen to open an existing file, if backing_store is set to 1 and the flag for #H5Fopen is set to + * #H5F_ACC_RDWR, changes to the file contents will be saved to the file when the file is closed. + * If backing_store is set to 0 and the flag for #H5Fopen is set to #H5F_ACC_RDWR, changes to the + * file contents will be lost when the file is closed. If the flag for #H5Fopen is set to + * #H5F_ACC_RDONLY, no change to the file will be allowed either in memory or on file. + * + * If the file access property list is set to use the Memory driver, #H5Pget_fapl_core will return + * block_size and backing_store with the relevant file access property settings. + * + * Note the following important points regarding in-memory files: + *
  • Local temporary files are created and accessed directly from memory without ever + * being written to disk
  • + *
  • Total file size must not exceed the available virtual memory
  • + *
  • Only one HDF5 file identifier can be opened for the file, the identifier returned by + * #H5Fcreate or #H5Fopen
  • + *
  • The changes to the file will be discarded when access is terminated unless + * backing_store is set to 1
+ * + * Additional parameters may be added to these functions in the future. + * + * @see + * HDF5 File Image Operations + * section for information on more advanced usage of the Memory file driver, and + * @see + * Modified Region Writes + * section for information on how to set write operations so that only modified regions are written + * to storage. + * + * \subsubsection subsubsec_file_alternate_drivers_family The Family Driver + * HDF5 files can become quite large, and this can create problems on systems that do not support + * files larger than 2 gigabytes. The HDF5 file family mechanism is designed to solve the problems + * this creates by splitting the HDF5 file address space across several smaller files. This structure + * does not affect how metadata and raw data are stored: they are mixed in the address space just as + * they would be in a single, contiguous file. + * + * HDF5 applications access a family of files via the Family driver, #H5FD_FAMILY. The + * functions #H5Pset_fapl_family and #H5Pget_fapl_family are used to manage file family + * properties. See the example below. + * + * Managing file family properties + * \code + * herr_t H5Pset_fapl_family (hid_t fapl_id, + * hsize_t memb_size, hid_t member_properties) + * herr_t H5Pget_fapl_family (hid_t fapl_id, + * hsize_t *memb_size, hid_t *member_properties) + * \endcode + * + * Each member of the family is the same logical size though the size and disk storage reported by + * file system listing tools may be substantially smaller. Examples of file system listing tools are + * \code + * ls -l + * \endcode + * on a Unix system or the detailed folder listing on an Apple or Microsoft Windows + * system. The name passed to #H5Fcreate or #H5Fopen should include a printf(3c)-style integer + * format specifier which will be replaced with the family member number. The first family + * member is numbered zero (0). + * + * #H5Pset_fapl_family sets the access properties to use the Family driver; any previously defined + * driver properties are erased from the property list. member_properties will serve as the file + * access property list for each member of the file family. memb_size specifies the logical size, in + * bytes, of each family member. memb_size is used only when creating a new file or truncating an + * existing file; otherwise the member size is determined by the size of the first member of the + * family being opened. Note: If the size of the off_t type is four bytes, the maximum family + * member size is usually 2^31-1 because the byte at offset 2,147,483,647 is generally inaccessible. + * + * #H5Pget_fapl_family is used to retrieve file family properties. If the file access property list is set + * to use the Family driver, member_properties will be returned with a pointer to a copy of the + * appropriate member access property list. If memb_size is non-null, it will contain the logical + * size, in bytes, of family members. + * + * Additional parameters may be added to these functions in the future. + * + *

Unix Tools and an HDF5 Utility

+ * It occasionally becomes necessary to repartition a file family. A command-line utility for this + * purpose, h5repart, is distributed with the HDF5 library. + * + * \code + * h5repart [-v] [-b block_size[suffix]] [-m member_size[suffix]] source destination + * \endcode + * + * h5repart repartitions an HDF5 file by copying the source file or file family to the destination file + * or file family, preserving holes in the underlying UNIX files. Families are used for the source + * and/or destination if the name includes a printf-style integer format such as %d. The -v switch + * prints input and output file names on the standard error stream for progress monitoring, -b sets + * the I/O block size (the default is 1KB), and -m sets the output member size if the destination is a + * family name (the default is 1GB). block_size and member_size may be suffixed with the letters + * g, m, or k for GB, MB, or KB respectively. + * + * The h5repart utility is described on the Tools page of the HDF5 Reference Manual. + * + * An existing HDF5 file can be split into a family of files by running the file through split(1) on a + * UNIX system and numbering the output files. However, the HDF5 Library is lazy about + * extending the size of family members, so a valid file cannot generally be created by + * concatenation of the family members. + * + * Splitting the file and rejoining the segments by concatenation (split(1) and cat(1) on UNIX + * systems) does not generate files with holes; holes are preserved only through the use of h5repart. + * + * \subsubsection subsubsec_file_alternate_drivers_multi The Multi Driver + * In some circumstances, it is useful to separate metadata from raw data and some types of + * metadata from other types of metadata. Situations that would benefit from use of the Multi driver + * include the following: + *
  • In networked situations where the small metadata files can be kept on local disks but + * larger raw data files must be stored on remote media
  • + *
  • In cases where the raw data is extremely large
  • + *
  • In situations requiring frequent access to metadata held in RAM while the raw data + * can be efficiently held on disk
+ * + * In either case, access to the metadata is substantially easier with the smaller, and possibly more + * localized, metadata files. This often results in improved application performance. + * + * The Multi driver, #H5FD_MULTI, provides a mechanism for segregating raw data and different + * types of metadata into multiple files. The functions #H5Pset_fapl_multi and + * #H5Pget_fapl_multi are used to manage access properties for these multiple files. See the example + * below. + * + * Managing access properties for multiple files + * \code + * herr_t H5Pset_fapl_multi (hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_fapl, + * const char * const *memb_name, const haddr_t *memb_addr, + * hbool_t relax) + * herr_t H5Pget_fapl_multi (hid_t fapl_id, const H5FD_mem_t *memb_map, const hid_t *memb_fapl, + * const char **memb_name, const haddr_t *memb_addr, hbool_t *relax) + * \endcode + * + * #H5Pset_fapl_multi sets the file access properties to use the Multi driver; any previously defined + * driver properties are erased from the property list. With the Multi driver invoked, the application + * will provide a base name to #H5Fopen or #H5Fcreate. The files will be named by that base name as + * modified by the rule indicated in memb_name. File access will be governed by the file access + * property list memb_properties. + * + * See #H5Pset_fapl_multi and #H5Pget_fapl_multi in the HDF5 Reference Manual for descriptions + * of these functions and their usage. + * + * Additional parameters may be added to these functions in the future. + * + * \subsubsection subsubsec_file_alternate_drivers_split The Split Driver + * The Split driver, H5FD_SPLIT, is a limited case of the Multi driver where only two files are + * created. One file holds metadata, and the other file holds raw data. + * The function #H5Pset_fapl_split is used to manage Split file access properties. See the example + * below. + * + * Managing access properties for split files + * \code + * herr_t H5Pset_fapl_split (hid_t access_properties, const char *meta_extension, + * hid_t meta_properties,const char *raw_extension, hid_t raw_properties) + * \endcode + * + * #H5Pset_fapl_split sets the file access properties to use the Split driver; any previously defined + * driver properties are erased from the property list. + * + * With the Split driver invoked, the application will provide a base file name such as file_name to + * #H5Fcreate or #H5Fopen. The metadata and raw data files in storage will then be named + * file_name.meta_extension and file_name.raw_extension, respectively. For example, if + * meta_extension is defined as .meta and raw_extension is defined as .raw, the final filenames will + * be file_name.meta and file_name.raw. + * + * Each file can have its own file access property list. This allows the creative use of other lowlevel + * file drivers. For instance, the metadata file can be held in RAM and accessed via the + * Memory driver while the raw data file is stored on disk and accessed via the POSIX driver. + * Metadata file access will be governed by the file access property list in meta_properties. Raw + * data file access will be governed by the file access property list in raw_properties. + * + * Additional parameters may be added to these functions in the future. Since there are no + * additional variable settings associated with the Split driver, there is no H5Pget_fapl_split + * function. + * + * \subsubsection subsubsec_file_alternate_drivers_par The Parallel Driver + * Parallel environments require a parallel low-level driver. HDF5’s default driver for parallel + * systems is called the Parallel driver, #H5FD_MPIO. This driver uses the MPI standard for both + * communication and file I/O. + * + * The functions #H5Pset_fapl_mpio and #H5Pget_fapl_mpio are used to manage file access + * properties for the #H5FD_MPIO driver. See the example below. + * + * Managing parallel file access properties + * \code + * herr_t H5Pset_fapl_mpio (hid_t fapl_id, MPI_Comm comm, MPI_info info) + * herr_t H5Pget_fapl_mpio (hid_t fapl_id, MPI_Comm *comm, MPI_info *info) + * \endcode + * + * The file access properties managed by #H5Pset_fapl_mpio and retrieved by + * #H5Pget_fapl_mpio are the MPI communicator, comm, and the MPI info object, info. comm and + * info are used for file open. info is an information object much like an HDF5 property list. Both + * are defined in MPI_FILE_OPEN of MPI-2. + * + * The communicator and the info object are saved in the file access property list fapl_id. + * fapl_id can then be passed to MPI_FILE_OPEN to create and/or open the file. + * + * #H5Pset_fapl_mpio and #H5Pget_fapl_mpio are available only in the parallel HDF5 Library and + * are not collective functions. The Parallel driver is available only in the parallel HDF5 Library. + * + * Additional parameters may be added to these functions in the future. + * + * \subsection subsec_file_examples Code Examples for Opening and Closing Files + * \subsubsection subsubsec_file_examples_trunc Example Using the H5F_ACC_TRUNC Flag + * The following example uses the #H5F_ACC_TRUNC flag when it creates a new file. The default + * file creation and file access properties are also used. Using #H5F_ACC_TRUNC means the + * function will look for an existing file with the name specified by the function. In this case, that + * name is FILE. If the function does not find an existing file, it will create one. If it does find an + * existing file, it will empty the file in preparation for a new set of data. The identifier for the + * "new" file will be passed back to the application program. + * For more information, @see @ref subsec_file_access_modes. + * + * Creating a file with default creation and access properties + * \code + * hid_t file; // identifier + * + * // Create a new file using H5F_ACC_TRUNC access, default + * // file creation properties, and default file access + * // properties. + * file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + * + * // Close the file. + * status = H5Fclose(file); + * \endcode + * + * \subsubsection subsubsec_file_examples_props Example with the File Creation Property List + * The example below shows how to create a file with 64-bit object offsets and lengths. + * + * Creating a file with 64-bit offsets + * \code + * hid_t create_plist; + * hid_t file_id; + * + * create_plist = H5Pcreate(H5P_FILE_CREATE); + * H5Pset_sizes(create_plist, 8, 8); + * file_id = H5Fcreate(“test.h5â€, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT); + * . + * . + * . + * + * H5Fclose(file_id); + * \endcode + * + * \subsubsection subsubsec_file_examples_access Example with the File Access Property List + * This example shows how to open an existing file for independent datasets access by MPI parallel + * I/O: + * + * Opening an existing file for parallel I/O + * \code + * hid_t access_plist; + * hid_t file_id; + * + * access_plist = H5Pcreate(H5P_FILE_ACCESS); + * H5Pset_fapl_mpi(access_plist, MPI_COMM_WORLD, MPI_INFO_NULL); + * + * // H5Fopen must be called collectively + * file_id = H5Fopen(“test.h5â€, H5F_ACC_RDWR, access_plist); + * . + * . + * . + * + * // H5Fclose must be called collectively + * H5Fclose(file_id); + * \endcode + * + * \subsection subsec_file_multiple Working with Multiple HDF5 Files + * Multiple HDF5 files can be associated so that the files can be worked with as though all the + * information is in a single HDF5 file. A temporary association can be set up by means of the + * #H5Fmount function. A permanent association can be set up by means of the external link + * function #H5Lcreate_external. + * + * The purpose of this section is to describe what happens when the #H5Fmount function is used to + * mount one file on another. + * + * When a file is mounted on another, the mounted file is mounted at a group, and the root group of + * the mounted file takes the place of that group until the mounted file is unmounted or until the + * files are closed. + * + * The figure below shows two files before one is mounted on the other. File1 has two groups and + * three datasets. The group that is the target of the A link has links, Z and Y, to two of the datasets. + * The group that is the target of the B link has a link, W, to the other dataset. File2 has three + * groups and three datasets. The groups in File2 are the targets of the AA, BB, and CC links. The + * datasets in File2 are the targets of the ZZ, YY, and WW links. + * + * + * + * + * + *
+ * \image html Files_fig3.gif "Two separate files" + *
+ * + * The figure below shows the two files after File2 has been mounted File1 at the group that is the + * target of the B link. + * + * + * + * + * + *
+ * \image html Files_fig4.gif "File2 mounted on File1" + *
+ * + * Note: In the figure above, the dataset that is the target of the W link is not shown. That dataset is + * masked by the mounted file. + * + * If a file is mounted on a group that has members, those members are hidden until the mounted + * file is unmounted. There are two ways around this if you need to work with a group member. + * One is to mount the file on an empty group. Another is to open the group member before you + * mount the file. Opening the group member will return an identifier that you can use to locate the + * group member. + * + * The example below shows how #H5Fmount might be used to mount File2 onto File1. + * + * Using H5Fmount + * \code + * status = H5Fmount(loc_id, "/B", child_id, plist_id) + * \endcode + * + * Note: In the code example above, loc_id is the file identifier for File1, /B is the link path to the + * group where File2 is mounted, child_id is the file identifier for File2, and plist_id is a property + * list identifier. + * For more information, @see @ref sec_group. + * + * See the entries for #H5Fmount, #H5Funmount, and #H5Lcreate_external in the HDF5 Reference Manual. + * + * Previous Chapter \ref sec_program - Next Chapter \ref sec_group + * + */ + /** - * \defgroup H5F H5F + * \defgroup H5F Files (H5F) * * Use the functions in this module to manage HDF5 files. * @@ -41,15 +1199,23 @@ * creation or access \c mode control the interaction with the underlying * storage such as file systems. * - * \Emph{Proper error handling is part of the life cycle.} * - * + * + * + * + * + * + * * * * * *
CreateOpen
CreateRead
+ * \snippet{lineno} H5F_examples.c create + * + * \snippet{lineno} H5F_examples.c read + *
UpdateDelete
- * \snippet H5F_examples.c life_cycle + * \snippet{lineno} H5F_examples.c update * - * \snippet H5F_examples.c life_cycle_w_open + * \snippet{lineno} H5F_examples.c delete *
diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 06f2a63f29d..fa1076167fe 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -99,12 +98,12 @@ H5F__close_mounts(H5F_t *f) herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED plist_id) { - H5G_t * mount_point = NULL; /*mount point group */ - H5F_t * ancestor = NULL; /*ancestor files */ - H5F_t * parent = NULL; /*file containing mount point */ + H5G_t *mount_point = NULL; /*mount point group */ + H5F_t *ancestor = NULL; /*ancestor files */ + H5F_t *parent = NULL; /*file containing mount point */ unsigned lt, rt, md; /*binary search indices */ int cmp; /*binary search comparison value*/ - H5G_loc_t mp_loc; /* entry of moint point to be opened */ + H5G_loc_t mp_loc; /* entry of mount point to be opened */ H5G_name_t mp_path; /* Mount point group hier. path */ H5O_loc_t mp_oloc; /* Mount point object location */ H5G_loc_t root_loc; /* Group location of root of file to mount */ @@ -263,9 +262,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED herr_t H5F__unmount(H5G_loc_t *loc, const char *name) { - H5G_t * child_group = NULL; /* Child's group in parent mtab */ - H5F_t * child = NULL; /*mounted file */ - H5F_t * parent = NULL; /*file where mounted */ + H5G_t *child_group = NULL; /* Child's group in parent mtab */ + H5F_t *child = NULL; /*mounted file */ + H5F_t *parent = NULL; /*file where mounted */ H5O_loc_t *mnt_oloc; /* symbol table entry for root of mounted file */ H5G_name_t mp_path; /* Mount point group hier. path */ H5O_loc_t mp_oloc; /* Mount point object location */ @@ -489,7 +488,7 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) /*------------------------------------------------------------------------- * Function: H5Funmount * - * Purpose: Given a mount point, dissassociate the mount point's file + * Purpose: Given a mount point, disassociate the mount point's file * from the file mounted there. Do not close either file. * * The mount point can either be the group in the parent or the diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 97bfefdcd0a..7ee1792e7ba 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -31,11 +30,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ #include "H5VLnative_private.h" /* Native VOL connector */ @@ -361,7 +361,7 @@ H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm) attached to the loc_id */ if (H5I_INVALID_HID != loc_id) { H5G_loc_t loc; - H5F_t * f = NULL; + H5F_t *f = NULL; /* Retrieve the file structure */ if (H5G_loc(loc_id, &loc) < 0) @@ -391,4 +391,189 @@ H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mpi_retrieve_comm */ + +/*------------------------------------------------------------------------- + * Function: H5F_get_coll_metadata_reads + * + * Purpose: Determines whether collective metadata reads should be + * performed. This routine is meant to be the single source of + * truth for the collective metadata reads status, as it + * coordinates between the file-global flag and the flag set + * for the current operation in the current API context. + * + * Return: TRUE/FALSE (can't fail) + * + *------------------------------------------------------------------------- + */ +hbool_t +H5F_get_coll_metadata_reads(const H5F_t *file) +{ + H5P_coll_md_read_flag_t file_flag = H5P_USER_FALSE; + hbool_t ret_value = FALSE; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(file && file->shared); + + /* Retrieve the file-global flag */ + file_flag = H5F_COLL_MD_READ(file); + + /* If file flag is set to H5P_FORCE_FALSE, exit early + * with FALSE, since collective metadata reads have + * been explicitly disabled somewhere in the library. + */ + if (H5P_FORCE_FALSE == file_flag) + ret_value = FALSE; + else { + /* If file flag is set to H5P_USER_TRUE, ignore + * any settings in the API context. A file-global + * setting of H5P_USER_TRUE for collective metadata + * reads should ignore any settings on an Access + * Property List for an individual operation. + */ + if (H5P_USER_TRUE == file_flag) + ret_value = TRUE; + else { + /* Get the collective metadata reads flag from + * the current API context. + */ + ret_value = H5CX_get_coll_metadata_read(); + } + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_coll_metadata_reads() */ + +/*------------------------------------------------------------------------- + * Function: H5F_set_coll_metadata_reads + * + * Purpose: Used to temporarily modify the collective metadata reads + * status. This is useful for cases where either: + * + * * Collective metadata reads are enabled, but need to be + * disabled for an operation about to occur that may trigger + * an independent metadata read (such as only rank 0 doing + * something) + * + * * Metadata reads are currently independent, but it is + * guaranteed that the application has maintained + * collectivity at the interface level (e.g., an operation + * that modifies metadata is being performed). In this case, + * it should be safe to enable collective metadata reads, + * barring any internal library issues that may occur + * + * After completion, the `file_flag` parameter will be set to + * the previous value of the file-global collective metadata + * reads flag. The `context_flag` parameter will be set to the + * previous value of the API context's collective metadata + * reads flag. Another call to this routine should be made to + * restore these values (see below warning). + * + * !! WARNING !! + * It is dangerous to modify the collective metadata reads + * status, as this can cause crashes, hangs and corruption in + * the HDF5 file when improperly done. Therefore, the + * `file_flag` and `context_flag` parameters are both + * mandatory, and it is assumed that the caller will guarantee + * these settings are restored with another call to this + * routine once the bracketed operation is complete. + * !! WARNING !! + * + * Return: Nothing + * + *------------------------------------------------------------------------- + */ +void +H5F_set_coll_metadata_reads(H5F_t *file, H5P_coll_md_read_flag_t *file_flag, hbool_t *context_flag) +{ + H5P_coll_md_read_flag_t prev_file_flag = H5P_USER_FALSE; + hbool_t prev_context_flag = FALSE; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(file && file->shared); + HDassert(file_flag); + HDassert(context_flag); + + /* Save old state */ + prev_file_flag = H5F_COLL_MD_READ(file); + prev_context_flag = H5CX_get_coll_metadata_read(); + + /* Set new desired state */ + if (prev_file_flag != *file_flag) { + file->shared->coll_md_read = *file_flag; + *file_flag = prev_file_flag; + } + if (prev_context_flag != *context_flag) { + H5CX_set_coll_metadata_read(*context_flag); + *context_flag = prev_context_flag; + } + + FUNC_LEAVE_NOAPI_VOID +} /* end H5F_set_coll_metadata_reads() */ + +/*------------------------------------------------------------------------- + * Function: H5F_mpi_get_file_block_type + * + * Purpose: Creates an MPI derived datatype for communicating an + * H5F_block_t structure. If `commit` is specified as TRUE, + * the resulting datatype will be committed and ready for + * use in communication. Otherwise, the type is only suitable + * for building other derived types. + * + * If TRUE is returned through `new_type_derived`, this lets + * the caller know that the datatype has been derived and + * should be freed with MPI_Type_free once it is no longer + * needed. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_mpi_get_file_block_type(hbool_t commit, MPI_Datatype *new_type, hbool_t *new_type_derived) +{ + MPI_Datatype types[2]; + MPI_Aint displacements[2]; + int block_lengths[2]; + int field_count; + int mpi_code; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(new_type); + HDassert(new_type_derived); + + *new_type_derived = FALSE; + + field_count = 2; + HDassert(field_count == sizeof(types) / sizeof(MPI_Datatype)); + + block_lengths[0] = 1; + block_lengths[1] = 1; + displacements[0] = offsetof(H5F_block_t, offset); + displacements[1] = offsetof(H5F_block_t, length); + types[0] = HADDR_AS_MPI_TYPE; + types[1] = HSIZE_AS_MPI_TYPE; + if (MPI_SUCCESS != + (mpi_code = MPI_Type_create_struct(field_count, block_lengths, displacements, types, new_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_struct failed", mpi_code) + *new_type_derived = TRUE; + + if (commit && MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) + +done: + if (ret_value < 0) { + if (*new_type_derived) { + if (MPI_SUCCESS != (mpi_code = MPI_Type_free(new_type))) + HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) + *new_type_derived = FALSE; + } + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_mpi_get_file_block_type() */ + #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 087c9c9ae9b..6c8b939ba50 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -78,7 +77,7 @@ #define H5F_SUPERBLOCK_FIXED_SIZE (H5F_SIGNATURE_LEN + 1) /* superblock version */ /* The H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE is the minimal amount of super block - * variable length data guarnateed to load the sizeof offsets and the sizeof + * variable length data guaranteed to load the sizeof offsets and the sizeof * lengths fields in all versions of the superblock. * * This is necessary in the V3 cache, as on the initial load, we need to @@ -159,7 +158,7 @@ typedef struct H5F_efc_t H5F_efc_t; /* Structure for passing 'user data' to superblock cache callbacks */ typedef struct H5F_superblock_cache_ud_t { /* IN: */ - H5F_t * f; /* Pointer to file */ + H5F_t *f; /* Pointer to file */ hbool_t ignore_drvrinfo; /* Indicate if the driver info should be ignored */ /* OUT: */ unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */ @@ -173,7 +172,7 @@ typedef struct H5F_superblock_cache_ud_t { /* Structure for passing 'user data' to driver info block cache callbacks */ typedef struct H5F_drvrinfo_cache_ud_t { - H5F_t * f; /* Pointer to file */ + H5F_t *f; /* Pointer to file */ haddr_t driver_addr; /* address of driver info block */ } H5F_drvrinfo_cache_ud_t; @@ -240,8 +239,8 @@ typedef struct H5F_super_t { * pointing to this struct. */ struct H5F_shared_t { - H5FD_t * lf; /* Lower level file handle for I/O */ - H5F_super_t * sblock; /* Pointer to (pinned) superblock for file */ + H5FD_t *lf; /* Lower level file handle for I/O */ + H5F_super_t *sblock; /* Pointer to (pinned) superblock for file */ H5O_drvinfo_t *drvinfo; /* Pointer to the (pinned) driver info * cache entry. This field is only defined * for older versions of the super block, @@ -271,8 +270,8 @@ struct H5F_shared_t { unsigned long feature_flags; /* VFL Driver feature Flags */ haddr_t maxaddr; /* Maximum address for file */ - H5PB_t * page_buf; /* The page buffer cache */ - H5AC_t * cache; /* The object cache */ + H5PB_t *page_buf; /* The page buffer cache */ + H5AC_t *cache; /* The object cache */ H5AC_cache_config_t mdc_initCacheCfg; /* initial configuration for the */ /* metadata cache. This structure is */ /* fixed at creation time and should */ @@ -285,7 +284,7 @@ struct H5F_shared_t { hbool_t use_mdc_logging; /* Set when metadata logging is desired */ hbool_t start_mdc_log_on_access; /* set when mdc logging should */ /* begin on file access/create */ - char * mdc_log_location; /* location of mdc log */ + char *mdc_log_location; /* location of mdc log */ hid_t fcpl_id; /* File creation property list ID */ H5F_close_degree_t fc_degree; /* File close behavior degree */ hbool_t evict_on_close; /* If the file's objects should be evicted from the metadata cache on close */ @@ -301,16 +300,16 @@ struct H5F_shared_t { hbool_t store_msg_crt_idx; /* Store creation index for object header messages? */ unsigned ncwfs; /* Num entries on cwfs list */ struct H5HG_heap_t **cwfs; /* Global heap cache */ - struct H5G_t * root_grp; /* Open root group */ - H5FO_t * open_objs; /* Open objects in file */ - H5UC_t * grp_btree_shared; /* Ref-counted group B-tree node info */ + struct H5G_t *root_grp; /* Open root group */ + H5FO_t *open_objs; /* Open objects in file */ + H5UC_t *grp_btree_shared; /* Ref-counted group B-tree node info */ hbool_t use_file_locking; /* Whether or not to use file locking */ hbool_t closing; /* File is in the process of being closed */ /* Cached VOL connector ID & info */ hid_t vol_id; /* ID of VOL connector for the container */ const H5VL_class_t *vol_cls; /* Pointer to VOL connector class for the container */ - void * vol_info; /* Copy of VOL connector info for container */ + void *vol_info; /* Copy of VOL connector info for container */ /* File space allocation information */ H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ @@ -326,7 +325,7 @@ struct H5F_shared_t { H5F_fs_state_t fs_state[H5F_MEM_PAGE_NTYPES]; /* State of free space manager for each type */ haddr_t fs_addr[H5F_MEM_PAGE_NTYPES]; /* Address of free space manager info for each type */ - H5FS_t * fs_man[H5F_MEM_PAGE_NTYPES]; /* Free space manager for each file space type */ + H5FS_t *fs_man[H5F_MEM_PAGE_NTYPES]; /* Free space manager for each file space type */ hbool_t null_fsm_addr; /* Used by h5clear tool to tell the library */ /* to drop free-space to the floor */ haddr_t eoa_fsm_fsalloc; /* eoa after file space allocation */ @@ -351,7 +350,7 @@ struct H5F_shared_t { /* Metadata retry info */ unsigned read_attempts; /* The # of reads to try when reading metadata with checksum */ unsigned retries_nbins; /* # of bins for each retries[] */ - uint32_t *retries[H5AC_NTYPES]; /* Track # of read retries for metdata items with checksum */ + uint32_t *retries[H5AC_NTYPES]; /* Track # of read retries for metadata items with checksum */ /* Object flush info */ H5F_object_flush_t object_flush; /* Information for object flush callback */ @@ -371,15 +370,15 @@ struct H5F_shared_t { * to shared H5F_shared_t structs. */ struct H5F_t { - char * open_name; /* Name used to open file */ - char * actual_name; /* Actual name of the file, after resolving symlinks, etc. */ - H5F_shared_t * shared; /* The shared file info */ + char *open_name; /* Name used to open file */ + char *actual_name; /* Actual name of the file, after resolving symlinks, etc. */ + H5F_shared_t *shared; /* The shared file info */ H5VL_object_t *vol_obj; /* VOL object */ unsigned nopen_objs; /* Number of open object headers */ - H5FO_t * obj_count; /* # of time each object is opened through top file structure */ + H5FO_t *obj_count; /* # of time each object is opened through top file structure */ hbool_t id_exists; /* Whether an ID for this struct exists */ hbool_t closing; /* File is in the process of being closed */ - struct H5F_t * parent; /* Parent file that this file is mounted to */ + struct H5F_t *parent; /* Parent file that this file is mounted to */ unsigned nmounts; /* Number of children mounted to this file */ }; @@ -403,8 +402,8 @@ H5_DLLVAR htri_t use_locks_env_g; /******************************/ /* General routines */ -H5_DLL herr_t H5F__post_open(H5F_t *f); -H5_DLL H5F_t * H5F__reopen(H5F_t *f); +H5_DLL herr_t H5F__post_open(H5F_t *f); +H5_DLL H5F_t *H5F__reopen(H5F_t *f); H5_DLL herr_t H5F__flush(H5F_t *f); H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t fapl_id); H5_DLL ssize_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); @@ -444,13 +443,13 @@ H5_DLL herr_t H5F__accum_flush(H5F_shared_t *f_sh); H5_DLL herr_t H5F__accum_reset(H5F_shared_t *f_sh, hbool_t flush); /* Shared file list related routines */ -H5_DLL herr_t H5F__sfile_add(H5F_shared_t *shared); +H5_DLL herr_t H5F__sfile_add(H5F_shared_t *shared); H5_DLL H5F_shared_t *H5F__sfile_search(H5FD_t *lf); H5_DLL herr_t H5F__sfile_remove(H5F_shared_t *shared); /* External file cache routines */ H5_DLL H5F_efc_t *H5F__efc_create(unsigned max_nfiles); -H5_DLL H5F_t * H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL H5F_t *H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL unsigned H5F__efc_max_nfiles(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_release(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_destroy(H5F_efc_t *efc); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 5c5937b038a..93220e419ef 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -771,7 +770,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; /* Structure for object flush callback property (H5Pset_object_flush_cb)*/ typedef struct H5F_object_flush_t { H5F_flush_cb_t func; /* The callback function */ - void * udata; /* User data */ + void *udata; /* User data */ } H5F_object_flush_t; /* Concise info about a block of bytes in a file */ @@ -832,35 +831,35 @@ H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/); H5_DLL hid_t H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref); /* Functions that retrieve values from the file struct */ -H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f); -H5_DLL H5F_libver_t H5F_get_high_bound(const H5F_t *f); -H5_DLL unsigned H5F_shared_get_intent(const H5F_shared_t *f); -H5_DLL unsigned H5F_get_intent(const H5F_t *f); -H5_DLL char * H5F_get_open_name(const H5F_t *f); -H5_DLL char * H5F_get_actual_name(const H5F_t *f); -H5_DLL char * H5F_get_extpath(const H5F_t *f); +H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f); +H5_DLL H5F_libver_t H5F_get_high_bound(const H5F_t *f); +H5_DLL unsigned H5F_shared_get_intent(const H5F_shared_t *f); +H5_DLL unsigned H5F_get_intent(const H5F_t *f); +H5_DLL char *H5F_get_open_name(const H5F_t *f); +H5_DLL char *H5F_get_actual_name(const H5F_t *f); +H5_DLL char *H5F_get_extpath(const H5F_t *f); H5_DLL H5F_shared_t *H5F_get_shared(const H5F_t *f); H5_DLL hbool_t H5F_same_shared(const H5F_t *f1, const H5F_t *f2); H5_DLL unsigned H5F_get_nopen_objs(const H5F_t *f); H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f); H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f); H5_DLL hbool_t H5F_file_id_exists(const H5F_t *f); -H5_DLL H5F_t * H5F_get_parent(const H5F_t *f); -H5_DLL unsigned H5F_get_nmounts(const H5F_t *f); -H5_DLL unsigned H5F_get_read_attempts(const H5F_t *f); -H5_DLL hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref); -H5_DLL hid_t H5F_get_id(H5F_t *file); -H5_DLL herr_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr); -H5_DLL herr_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list, - hbool_t app_ref, size_t *obj_id_count_ptr); -H5_DLL hsize_t H5F_get_pgend_meta_thres(const H5F_t *f); -H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f); -H5_DLL hbool_t H5F_get_null_fsm_addr(const H5F_t *f); -H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f); -H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize); +H5_DLL H5F_t *H5F_get_parent(const H5F_t *f); +H5_DLL unsigned H5F_get_nmounts(const H5F_t *f); +H5_DLL unsigned H5F_get_read_attempts(const H5F_t *f); +H5_DLL hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref); +H5_DLL hid_t H5F_get_id(H5F_t *file); +H5_DLL herr_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr); +H5_DLL herr_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list, + hbool_t app_ref, size_t *obj_id_count_ptr); +H5_DLL hsize_t H5F_get_pgend_meta_thres(const H5F_t *f); +H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f); +H5_DLL hbool_t H5F_get_null_fsm_addr(const H5F_t *f); +H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f); +H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize); H5_DLL const H5VL_class_t *H5F_get_vol_cls(const H5F_t *f); -H5_DLL H5VL_object_t *H5F_get_vol_obj(const H5F_t *f); -H5_DLL hbool_t H5F_get_file_locking(const H5F_t *f); +H5_DLL H5VL_object_t *H5F_get_vol_obj(const H5F_t *f); +H5_DLL hbool_t H5F_get_file_locking(const H5F_t *f); /* Functions than retrieve values set/cached from the superblock/FCPL */ H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); @@ -885,7 +884,7 @@ H5_DLL size_t H5F_sieve_buf_size(const H5F_t *f); H5_DLL unsigned H5F_gc_ref(const H5F_t *f); H5_DLL hbool_t H5F_store_msg_crt_idx(const H5F_t *f); H5_DLL herr_t H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag); -H5_DLL struct H5UC_t * H5F_grp_btree_shared(const H5F_t *f); +H5_DLL struct H5UC_t *H5F_grp_btree_shared(const H5F_t *f); H5_DLL herr_t H5F_set_grp_btree_shared(H5F_t *f, struct H5UC_t *rc); H5_DLL hbool_t H5F_use_tmp_space(const H5F_t *f); H5_DLL hbool_t H5F_is_tmp_addr(const H5F_t *f, haddr_t addr); @@ -896,7 +895,7 @@ H5_DLL H5P_coll_md_read_flag_t H5F_coll_md_read(const H5F_t *f); #endif /* H5_HAVE_PARALLEL */ H5_DLL hbool_t H5F_use_mdc_logging(const H5F_t *f); H5_DLL hbool_t H5F_start_mdc_log_on_access(const H5F_t *f); -H5_DLL char * H5F_mdc_log_location(const H5F_t *f); +H5_DLL char *H5F_mdc_log_location(const H5F_t *f); /* Functions that retrieve values from VFD layer */ H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); @@ -962,6 +961,9 @@ H5_DLL int H5F_mpi_get_size(const H5F_t *f); H5_DLL herr_t H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm); H5_DLL herr_t H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag); H5_DLL herr_t H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag); +H5_DLL herr_t H5F_mpi_get_file_block_type(hbool_t commit, MPI_Datatype *new_type, hbool_t *new_type_derived); +H5_DLL hbool_t H5F_get_coll_metadata_reads(const H5F_t *f); +H5_DLL void H5F_set_coll_metadata_reads(H5F_t *f, H5P_coll_md_read_flag_t *file_flag, hbool_t *context_flag); #endif /* H5_HAVE_PARALLEL */ /* External file cache routines */ diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 89238b6dc80..65b30b8727f 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -84,7 +83,7 @@ (0x0020u) /**< Restrict search to objects opened through current file ID \ (as opposed to objects opened through any file ID accessing this file) */ -#define H5F_FAMILY_DEFAULT (hsize_t)0 +#define H5F_FAMILY_DEFAULT 0 /* (hsize_t) */ #ifdef H5_HAVE_PARALLEL /** @@ -189,7 +188,7 @@ typedef enum H5F_libver_t { H5F_LIBVER_V18 = 1, /**< Use the latest v18 format for storing objects */ H5F_LIBVER_V110 = 2, /**< Use the latest v110 format for storing objects */ H5F_LIBVER_V112 = 3, /**< Use the latest v112 format for storing objects */ - H5F_LIBVER_NBOUNDS + H5F_LIBVER_NBOUNDS /**< Sentinel */ } H5F_libver_t; #define H5F_LIBVER_LATEST H5F_LIBVER_V112 @@ -386,7 +385,7 @@ H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_ * opened. * * The \p fapl_id parameter specifies the file access property list. - * Use of #H5P_DEFAULT specifies that default I/O access properties + * The use of #H5P_DEFAULT specifies that default I/O access properties * are to be used. * * The \p flags parameter specifies whether the file will be opened in @@ -496,7 +495,7 @@ H5_DLL hid_t H5Freopen(hid_t file_id); * \snippet H5F_examples.c flush * * \attention HDF5 does not possess full control over buffering. H5Fflush() - * flushes the internal HDF5 buffers then asks the operating system + * flushes the internal HDF5 buffers and then asks the operating system * (the OS) to flush the system buffers for the open files. After * that, the OS is responsible for ensuring that the data is * actually flushed to disk. @@ -523,7 +522,7 @@ H5_DLL herr_t H5Fflush(hid_t object_id, H5F_scope_t scope); * \snippet H5F_examples.c minimal * * \note \Bold{Delayed close:} Note the following deviation from the - * above-described behavior. If H5Fclose() is called for a file but one + * above-described behavior. If H5Fclose() is called for a file, but one * or more objects within the file remain open, those objects will remain * accessible until they are individually closed. Thus, if the dataset * \c data_sample is open when H5Fclose() is called for the file @@ -532,7 +531,7 @@ H5_DLL herr_t H5Fflush(hid_t object_id, H5F_scope_t scope); * automatically closed once all objects in the file have been closed.\n * Be warned, however, that there are circumstances where it is not * possible to delay closing a file. For example, an MPI-IO file close is - * a collective call; all of the processes that opened the file must + * a collective call; all of the processes that open the file must * close it collectively. The file cannot be closed at some time in the * future by each process in an independent fashion. Another example is * that an application using an AFS token-based file access privilege may @@ -1304,7 +1303,7 @@ H5_DLL herr_t H5Fstart_swmr_write(hid_t file_id); * \snippet this H5F_sect_info_t_snip * * This routine retrieves free-space section information for \p nsects - * sections or at most the maximum number of sections in the specified + * sections or, at most, the maximum number of sections in the specified * free-space manager. If the number of sections is not known, a * preliminary H5Fget_free_sections() call can be made by setting \p * sect_info to NULL and the total number of free-space sections for @@ -1570,7 +1569,7 @@ H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], u * \brief Obtains information about a cache image if it exists * * \file_id - * \param[out] image_addr Offset of the cache image if it exists, or \c HADDR_UNDEF if it does not + * \param[out] image_addr Offset of the cache image if it exists, or HADDR_UNDEF if it does not * \param[out] image_size Length of the cache image if it exists, or 0 if it does not * \returns \herr_t * @@ -1612,7 +1611,7 @@ H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t * file_id. This setting is used to inform the library to create * minimized dataset object headers when \c TRUE. * - * The setting's value is returned in the boolean pointer minimize. + * The setting's value is returned in the boolean pointer minimized. * * \since 1.10.5 * @@ -1811,7 +1810,7 @@ H5_DLL herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *file_info); /** * \ingroup H5F * - * \brief Sets thelatest version of the library to be used for writing objects + * \brief Sets the latest version of the library to be used for writing objects * * \file_id * \param[in] latest_format Latest format flag @@ -1820,6 +1819,7 @@ H5_DLL herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *file_info); * * \deprecated When? * + * \todo In which version was this function introduced? * \todo In which version was this function deprecated? * */ diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 04792b42750..784d0afd1ad 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Fsfile.c b/src/H5Fsfile.c index be45e786466..978d4dc67e0 100644 --- a/src/H5Fsfile.c +++ b/src/H5Fsfile.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -24,7 +23,7 @@ /* Struct for tracking "shared" file structs */ typedef struct H5F_sfile_node_t { - H5F_shared_t * shared; /* Pointer to "shared" file struct */ + H5F_shared_t *shared; /* Pointer to "shared" file struct */ struct H5F_sfile_node_t *next; /* Pointer to next node */ } H5F_sfile_node_t; @@ -136,7 +135,7 @@ H5F_shared_t * H5F__sfile_search(H5FD_t *lf) { H5F_sfile_node_t *curr; /* Current shared file node */ - H5F_shared_t * ret_value = NULL; /* Return value */ + H5F_shared_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_NOERR diff --git a/src/H5Fspace.c b/src/H5Fspace.c index 29495f181c3..1e2b238524e 100644 --- a/src/H5Fspace.c +++ b/src/H5Fspace.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 0c71dd275c6..020c378d862 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -317,10 +316,10 @@ herr_t H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) { H5AC_ring_t orig_ring = H5AC_RING_INV; - H5F_super_t * sblock = NULL; /* Superblock structure */ + H5F_super_t *sblock = NULL; /* Superblock structure */ H5F_superblock_cache_ud_t udata; /* User data for cache callbacks */ - H5P_genplist_t * c_plist; /* File creation property list */ - H5FD_t * file; /* File driver pointer */ + H5P_genplist_t *c_plist; /* File creation property list */ + H5FD_t *file; /* File driver pointer */ unsigned sblock_flags = H5AC__NO_FLAGS_SET; /* flags used in superblock unprotect call */ haddr_t super_addr; /* Absolute address of superblock */ haddr_t eof; /* End of file address */ @@ -374,7 +373,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) if (0 == mpi_rank) { herr_t status; - /* Try detecting file's siganture */ + /* Try detecting file's signature */ /* (Don't leave before Bcast, to avoid hang on error) */ H5E_BEGIN_TRY { @@ -466,7 +465,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) * * After upgrading low_bound, the library will check to ensure that the * superblock version does not exceed the version allowed by high_bound. - * Otherise fail file open. + * Otherwise fail file open. * * For details, please see RFC:Setting Bounds for Object Creation in HDF5 1.10.0. */ @@ -627,7 +626,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* Decode the optional driver information block */ if (H5F_addr_defined(sblock->driver_addr)) { - H5O_drvinfo_t * drvinfo; /* Driver info */ + H5O_drvinfo_t *drvinfo; /* Driver info */ H5F_drvrinfo_cache_ud_t drvrinfo_udata; /* User data for metadata callbacks */ unsigned drvinfo_flags = H5AC__NO_FLAGS_SET; /* Flags used in driver info block unprotect call */ @@ -686,7 +685,9 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) /* Sanity check - superblock extension should only be defined for * superblock version >= 2. */ - HDassert(sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2); + if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, + "invalid superblock - extension message should not be defined for version < 2") /* Check for superblock extension being located "outside" the stored * 'eoa' value, which can occur with the split/multi VFD. @@ -1042,7 +1043,7 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read) HDONE_ERROR(H5E_FILE, H5E_CANTUNPIN, FAIL, "unable to unpin driver info") /* Evict the driver info block from the cache */ - if (H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) + if (sblock && H5AC_expunge_entry(f, H5AC_DRVRINFO, sblock->driver_addr, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTEXPUNGE, FAIL, "unable to expunge driver info block") } /* end if */ @@ -1086,8 +1087,9 @@ H5F__super_init(H5F_t *f) FALSE; /* Whether the driver info block has been inserted into the metadata cache */ H5P_genplist_t *plist; /* File creation property list */ H5AC_ring_t orig_ring = H5AC_RING_INV; - hsize_t userblock_size; /* Size of userblock, in bytes */ - hsize_t superblock_size; /* Size of superblock, in bytes */ + hsize_t userblock_size; /* Size of userblock, in bytes */ + hsize_t superblock_size = 0; /* Size of superblock, in bytes */ + haddr_t superblock_addr = HADDR_UNDEF; size_t driver_size; /* Size of driver info block (bytes) */ unsigned super_vers = HDF5_SUPERBLOCK_VERSION_DEF; /* Superblock version for file */ H5O_loc_t ext_loc; /* Superblock extension object location */ @@ -1287,7 +1289,7 @@ H5F__super_init(H5F_t *f) f->shared->sblock = sblock; /* Allocate space for the superblock */ - if (HADDR_UNDEF == H5MF_alloc(f, H5FD_MEM_SUPER, superblock_size)) + if (HADDR_UNDEF == (superblock_addr = H5MF_alloc(f, H5FD_MEM_SUPER, superblock_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for superblock") /* set the drvinfo filed to NULL -- will overwrite this later if needed */ @@ -1478,6 +1480,19 @@ H5F__super_init(H5F_t *f) /* Check if the superblock has been allocated yet */ if (sblock) { + if (non_default_fs_settings && H5F_addr_defined(superblock_addr)) { + /* + * For non-default free-space settings, the allocation of + * space in the file for the superblock may have have allocated + * memory for the free-space manager and inserted it into the + * metadata cache. Clean that up before returning or we may fail + * to close the file later due to the metadata cache's metadata + * free space manager ring (H5AC_RING_MDFSM) not being clean. + */ + if (H5MF_try_close(f) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "can't close file free space manager"); + } + /* Check if we've cached it already */ if (sblock_in_cache) { /* Unpin superblock in cache */ @@ -1491,7 +1506,7 @@ H5F__super_init(H5F_t *f) else /* Free superblock */ if (H5F__super_free(sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") + HDONE_ERROR(H5E_FILE, H5E_CANTFREE, FAIL, "unable to destroy superblock") /* Reset variables in file structure */ f->shared->sblock = NULL; diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 28ff82f8452..0c297564d6b 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -63,7 +62,7 @@ static herr_t H5F__cache_superblock_get_initial_load_size(void *udata, size_t *i static herr_t H5F__cache_superblock_get_final_load_size(const void *image_ptr, size_t image_len, void *udata, size_t *actual_len); static htri_t H5F__cache_superblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5F__cache_superblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5F__cache_superblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5F__cache_superblock_image_len(const void *thing, size_t *image_len); static herr_t H5F__cache_superblock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5F__cache_superblock_free_icr(void *thing); @@ -71,7 +70,7 @@ static herr_t H5F__cache_superblock_free_icr(void *thing); static herr_t H5F__cache_drvrinfo_get_initial_load_size(void *udata, size_t *image_len); static herr_t H5F__cache_drvrinfo_get_final_load_size(const void *image_ptr, size_t image_len, void *udata, size_t *actual_len); -static void * H5F__cache_drvrinfo_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5F__cache_drvrinfo_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5F__cache_drvrinfo_image_len(const void *thing, size_t *image_len); static herr_t H5F__cache_drvrinfo_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5F__cache_drvrinfo_free_icr(void *thing); @@ -326,7 +325,7 @@ static herr_t H5F__cache_superblock_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, size_t *actual_len) { - const uint8_t * image = _image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ H5F_super_t sblock; /* Temporary file superblock */ htri_t ret_value = SUCCEED; /* Return value */ @@ -371,7 +370,7 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t H5_ATTR_NDE static htri_t H5F__cache_superblock_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t * image = _image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ @@ -410,13 +409,13 @@ H5F__cache_superblock_verify_chksum(const void *_image, size_t len, void *_udata *------------------------------------------------------------------------- */ static void * -H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5F_super_t * sblock = NULL; /* File's superblock */ + H5F_super_t *sblock = NULL; /* File's superblock */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ - const uint8_t * image = _image; /* Pointer into raw data buffer */ - H5F_super_t * ret_value = NULL; /* Return value */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ + const uint8_t *end = image + len - 1; /* Pointer to end of buffer */ + H5F_super_t *ret_value = NULL; FUNC_ENTER_STATIC @@ -428,11 +427,11 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS /* Allocate space for the superblock */ if (NULL == (sblock = H5FL_CALLOC(H5F_super_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Deserialize the file superblock's prefix */ if (H5F__superblock_prefix_decode(sblock, &image, udata, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file superblock prefix") + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file superblock prefix"); /* Check for older version of superblock format */ if (sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) { @@ -442,85 +441,113 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS unsigned chunk_btree_k; /* B-tree chunk internal node 'K' value */ /* Freespace version (hard-wired) */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); if (HDF5_FREESPACE_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad free space version number") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad free space version number"); /* Root group version number (hard-wired) */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); if (HDF5_OBJECTDIR_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad object directory version number") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad object directory version number"); /* Skip over reserved byte */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); image++; /* Shared header version number (hard-wired) */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); if (HDF5_SHAREDHEADER_VERSION != *image++) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number"); /* Skip over size of file addresses (already decoded) */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); image++; udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */ /* Skip over size of file sizes (already decoded) */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); image++; udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ /* Skip over reserved byte */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); image++; /* Various B-tree sizes */ + if (H5_IS_BUFFER_OVERFLOW(image, 2, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); UINT16DECODE(image, sym_leaf_k); if (sym_leaf_k == 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad symbol table leaf node 1/2 rank") + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad symbol table leaf node 1/2 rank"); udata->sym_leaf_k = sym_leaf_k; /* Keep a local copy also */ /* Need 'get' call to set other array values */ + if (H5_IS_BUFFER_OVERFLOW(image, 2, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); UINT16DECODE(image, snode_btree_k); if (snode_btree_k == 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad 1/2 rank for btree internal nodes") + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad 1/2 rank for btree internal nodes"); udata->btree_k[H5B_SNODE_ID] = snode_btree_k; - /* - * Delay setting the value in the property list until we've checked + /* Delay setting the value in the property list until we've checked * for the indexed storage B-tree internal 'K' value later. */ /* File status flags (not really used yet) */ + if (H5_IS_BUFFER_OVERFLOW(image, 4, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); UINT32DECODE(image, status_flags); - HDassert(status_flags <= 255); + if (status_flags > 255) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad superblock status flags"); sblock->status_flags = (uint8_t)status_flags; if (sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock"); - /* - * If the superblock version # is greater than 0, read in the indexed + /* If the superblock version # is greater than 0, read in the indexed * storage B-tree internal 'K' value */ if (sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) { + if (H5_IS_BUFFER_OVERFLOW(image, 2, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); UINT16DECODE(image, chunk_btree_k); /* Reserved bytes are present only in version 1 */ - if (sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1) - image += 2; /* reserved */ - } /* end if */ + if (sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1) { + /* Reserved */ + if (H5_IS_BUFFER_OVERFLOW(image, 2, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); + image += 2; + } + } else chunk_btree_k = HDF5_BTREE_CHUNK_IK_DEF; udata->btree_k[H5B_CHUNK_ID] = chunk_btree_k; /* Remainder of "variable-sized" portion of superblock */ + if (H5_IS_BUFFER_OVERFLOW(image, H5F_sizeof_addr(udata->f) * 4, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr /*out*/); H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->ext_addr /*out*/); H5F_addr_decode(udata->f, (const uint8_t **)&image, &udata->stored_eof /*out*/); H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->driver_addr /*out*/); /* Allocate space for the root group symbol table entry */ - HDassert(!sblock->root_ent); + if (sblock->root_ent) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "root entry should not exist yet"); if (NULL == (sblock->root_ent = (H5G_entry_t *)H5MM_calloc(sizeof(H5G_entry_t)))) HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, - "can't allocate space for root group symbol table entry") + "can't allocate space for root group symbol table entry"); - /* decode the root group symbol table entry */ + /* Decode the root group symbol table entry */ if (H5G_ent_decode(udata->f, (const uint8_t **)&image, sblock->root_ent) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode root group symbol table entry") + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode root group symbol table entry"); /* Set the root group address to the correct value */ sblock->root_addr = sblock->root_ent->header; @@ -534,26 +561,32 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS /* Eliminate the driver info */ sblock->driver_addr = HADDR_UNDEF; udata->drvrinfo_removed = TRUE; - } /* end if */ + } /* NOTE: Driver info block is decoded separately, later */ - - } /* end if */ + } else { uint32_t read_chksum; /* Checksum read from file */ /* Skip over size of file addresses (already decoded) */ image++; udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */ - /* Skip over size of file sizes (already decoded) */ image++; udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */ + /* Check whether the image pointer is out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); + /* File status flags (not really used yet) */ sblock->status_flags = *image++; if (sblock->status_flags & ~H5F_SUPER_ALL_FLAGS) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad flag value for superblock"); + + /* Check whether the image pointer will be out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, H5F_SIZEOF_ADDR(udata->f) * 4, end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); /* Base, superblock extension, end of file & root group object header addresses */ H5F_addr_decode(udata->f, (const uint8_t **)&image, &sblock->base_addr /*out*/); @@ -563,6 +596,10 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS /* checksum verification already done in verify_chksum cb */ + /* Check whether the image pointer will be out of bounds */ + if (H5_IS_BUFFER_OVERFLOW(image, sizeof(uint32_t), end)) + HGOTO_ERROR(H5E_FILE, H5E_OVERFLOW, NULL, "image pointer is out of bounds"); + /* Decode checksum */ UINT32DECODE(image, read_chksum); @@ -572,19 +609,19 @@ H5F__cache_superblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUS * any attempt to load the Driver Information Block. */ sblock->driver_addr = HADDR_UNDEF; - } /* end else */ + } - /* Sanity check */ - HDassert((size_t)(image - (const uint8_t *)_image) <= len); + /* Size check */ + if ((size_t)(image - (const uint8_t *)_image) > len) + HDONE_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad decoded superblock size"); - /* Set return value */ ret_value = sblock; done: /* Release the [possibly partially initialized] superblock on error */ if (!ret_value && sblock) if (H5F__super_free(sblock) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data") + HDONE_ERROR(H5E_FILE, H5E_CANTFREE, NULL, "unable to destroy superblock data"); FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__cache_superblock_deserialize() */ @@ -636,7 +673,7 @@ static herr_t H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len, void *_thing) { H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ - uint8_t * image = _image; /* Pointer into raw data buffer */ + uint8_t *image = _image; /* Pointer into raw data buffer */ haddr_t rel_eof; /* Relative EOF for file */ herr_t ret_value = SUCCEED; /* Return value */ @@ -698,7 +735,7 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "driver get_eoa request failed") H5F_addr_encode(f, &image, (rel_eof + sblock->base_addr)); - /* Encode the driver informaton block address */ + /* Encode the driver information block address */ H5F_addr_encode(f, &image, sblock->driver_addr); /* Encode the root group object entry, including the cached stab info */ @@ -797,7 +834,7 @@ H5F__cache_superblock_free_icr(void *_thing) /*------------------------------------------------------------------------- * Function: H5F__cache_drvrinfo_get_initial_load_size * - * Purpose: Compute the intiial size of the data structure on disk. + * Purpose: Compute the initial size of the data structure on disk. * * Return: Non-negative on success/Negative on failure * @@ -836,7 +873,7 @@ static herr_t H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, void *_udata, size_t *actual_len) { - const uint8_t * image = _image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ H5O_drvinfo_t drvrinfo; /* Driver info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -878,11 +915,11 @@ static void * H5F__cache_drvrinfo_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5O_drvinfo_t * drvinfo = NULL; /* Driver info */ + H5O_drvinfo_t *drvinfo = NULL; /* Driver info */ H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ - const uint8_t * image = _image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ char drv_name[9]; /* Name of driver */ - H5O_drvinfo_t * ret_value = NULL; /* Return value */ + H5O_drvinfo_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -969,8 +1006,8 @@ static herr_t H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ - uint8_t * image = _image; /* Pointer into raw data buffer */ - uint8_t * dbuf; /* Pointer to beginning of driver info */ + uint8_t *image = _image; /* Pointer into raw data buffer */ + uint8_t *dbuf; /* Pointer to beginning of driver info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 1f5e7e2f53c..f482117c8ce 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -88,7 +87,7 @@ herr_t H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_count) { - H5F_t * file; /* File info */ + H5F_t *file; /* File info */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ @@ -132,7 +131,7 @@ H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_coun herr_t H5F__check_cached_stab_test(hid_t file_id) { - H5F_t * file; /* File info */ + H5F_t *file; /* File info */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5G.c b/src/H5G.c index f5d1dc523f1..e3ef9f10e82 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -324,8 +323,8 @@ H5G__close_cb(H5VL_object_t *grp_vol_obj) hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - void * grp = NULL; /* Structure for new group */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *grp = NULL; /* Structure for new group */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -417,8 +416,8 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t g hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) { - void * grp = NULL; /* Structure for new group */ - H5VL_object_t * vol_obj = NULL; /* Object for loc_id */ + void *grp = NULL; /* Structure for new group */ + H5VL_object_t *vol_obj = NULL; /* Object for loc_id */ H5VL_loc_params_t loc_params; /* Location parameters for object access */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -479,8 +478,8 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { - void * grp = NULL; /* Group opened */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *grp = NULL; /* Group opened */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -568,7 +567,7 @@ H5Gget_create_plist(hid_t group_id) herr_t H5Gget_info(hid_t loc_id, H5G_info_t *group_info) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5I_type_t id_type; /* Type of ID */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -611,7 +610,7 @@ H5Gget_info(hid_t loc_id, H5G_info_t *group_info) herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info, hid_t lapl_id) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -663,7 +662,7 @@ herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *group_info, hid_t lapl_id) { - H5VL_object_t * vol_obj; + H5VL_object_t *vol_obj; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index dd147ae084e..bc335784331 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -50,10 +49,10 @@ */ typedef struct H5G_fh_ud_cmp_t { /* downward */ - H5F_t * f; /* Pointer to file that fractal heap is in */ - const char * name; /* Name of link to compare */ + H5F_t *f; /* Pointer to file that fractal heap is in */ + const char *name; /* Name of link to compare */ H5B2_found_t found_op; /* Callback when correct link is found */ - void * found_op_data; /* Callback data when correct link is found */ + void *found_op_data; /* Callback data when correct link is found */ /* upward */ int cmp; /* Comparison of two link names */ @@ -146,7 +145,7 @@ static herr_t H5G__dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata) { H5G_fh_ud_cmp_t *udata = (H5G_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */ - H5O_link_t * lnk; /* Pointer to link created from heap object */ + H5O_link_t *lnk; /* Pointer to link created from heap object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -188,7 +187,7 @@ H5G__dense_fh_name_cmp(const void *obj, size_t obj_len, void *_udata) static herr_t H5G__dense_btree2_name_store(void *_nrecord, const void *_udata) { - const H5G_bt2_ud_ins_t * udata = (const H5G_bt2_ud_ins_t *)_udata; + const H5G_bt2_ud_ins_t *udata = (const H5G_bt2_ud_ins_t *)_udata; H5G_dense_bt2_name_rec_t *nrecord = (H5G_dense_bt2_name_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -217,7 +216,7 @@ H5G__dense_btree2_name_store(void *_nrecord, const void *_udata) static herr_t H5G__dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { - const H5G_bt2_ud_common_t * bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; + const H5G_bt2_ud_common_t *bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; const H5G_dense_bt2_name_rec_t *bt2_rec = (const H5G_dense_bt2_name_rec_t *)_bt2_rec; herr_t ret_value = SUCCEED; /* Return value */ @@ -359,7 +358,7 @@ H5G__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_ static herr_t H5G__dense_btree2_corder_store(void *_nrecord, const void *_udata) { - const H5G_bt2_ud_ins_t * udata = (const H5G_bt2_ud_ins_t *)_udata; + const H5G_bt2_ud_ins_t *udata = (const H5G_bt2_ud_ins_t *)_udata; H5G_dense_bt2_corder_rec_t *nrecord = (H5G_dense_bt2_corder_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -388,7 +387,7 @@ H5G__dense_btree2_corder_store(void *_nrecord, const void *_udata) static herr_t H5G__dense_btree2_corder_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { - const H5G_bt2_ud_common_t * bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; + const H5G_bt2_ud_common_t *bt2_udata = (const H5G_bt2_ud_common_t *)_bt2_udata; const H5G_dense_bt2_corder_rec_t *bt2_rec = (const H5G_dense_bt2_corder_rec_t *)_bt2_rec; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 471319360e0..27f945aa7d6 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -58,7 +57,7 @@ /* Metadata cache (H5AC) callbacks */ static herr_t H5G__cache_node_get_initial_load_size(void *udata, size_t *image_len); -static void * H5G__cache_node_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5G__cache_node_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5G__cache_node_image_len(const void *thing, size_t *image_len); static herr_t H5G__cache_node_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5G__cache_node_free_icr(void *thing); @@ -134,7 +133,7 @@ H5G__cache_node_get_initial_load_size(void *_udata, size_t *image_len) * Function: H5G__cache_node_deserialize * * Purpose: Given a buffer containing the on disk image of a symbol table - * node, allocate an instance of H5G_node_t, load the contence of the + * node, allocate an instance of H5G_node_t, load the contents of the * image into it, and return a pointer to the instance. * * Note that deserializing the image requires access to the file @@ -154,11 +153,11 @@ H5G__cache_node_get_initial_load_size(void *_udata, size_t *image_len) static void * H5G__cache_node_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5F_t * f = (H5F_t *)_udata; /* User data for callback */ - H5G_node_t * sym = NULL; /* Symbol table node created */ + H5F_t *f = (H5F_t *)_udata; /* User data for callback */ + H5G_node_t *sym = NULL; /* Symbol table node created */ const uint8_t *image = (const uint8_t *)_image; /* Pointer to image to deserialize */ const uint8_t *image_end = image + len - 1; /* Pointer to end of image buffer */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -240,7 +239,7 @@ H5G__cache_node_image_len(const void *_thing, size_t *image_len) /*------------------------------------------------------------------------- * Function: H5G__cache_node_serialize * - * Purpose: Given a correctly sized buffer and an instace of H5G_node_t, + * Purpose: Given a correctly sized buffer and an instance of H5G_node_t, * serialize the contents of the instance of H5G_node_t, and write * this data into the supplied buffer. This buffer will be written * to disk. @@ -257,7 +256,7 @@ static herr_t H5G__cache_node_serialize(const H5F_t *f, void *_image, size_t len, void *_thing) { H5G_node_t *sym = (H5G_node_t *)_thing; /* Pointer to object */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index af188d8cedf..1482f695a13 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -40,7 +39,7 @@ typedef struct { /* User data for deleting a link in the link messages */ typedef struct { /* downward */ - H5F_t * file; /* File that object header is located within */ + H5F_t *file; /* File that object header is located within */ H5RS_str_t *grp_full_path_r; /* Full path for group of link */ const char *name; /* Link name to search for */ } H5G_iter_rm_t; @@ -80,7 +79,7 @@ static herr_t H5G__compact_build_table_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_iter_bt_t * udata = (H5G_iter_bt_t *)_udata; /* 'User data' passed in */ + H5G_iter_bt_t *udata = (H5G_iter_bt_t *)_udata; /* 'User data' passed in */ herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -263,7 +262,7 @@ static herr_t H5G__compact_remove_common_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_iter_rm_t * udata = (H5G_iter_rm_t *)_udata; /* 'User data' passed in */ + H5G_iter_rm_t *udata = (H5G_iter_rm_t *)_udata; /* 'User data' passed in */ herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -419,7 +418,7 @@ H5G__compact_iterate(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t * Function: H5G__compact_lookup_cb * * Purpose: Callback routine for searching 'link' messages for a particular - * name & gettting object location for it + * name & getting object location for it * * Return: SUCCEED/FAIL * @@ -432,7 +431,7 @@ static herr_t H5G__compact_lookup_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ - H5G_iter_lkp_t * udata = (H5G_iter_lkp_t *)_udata; /* 'User data' passed in */ + H5G_iter_lkp_t *udata = (H5G_iter_lkp_t *)_udata; /* 'User data' passed in */ herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 6100361f177..4f0fd71e5e2 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -80,14 +79,14 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t * f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ H5HF_t *fheap; /* Fractal heap handle */ hsize_t count; /* # of links examined */ /* downward (from application) */ hsize_t skip; /* Number of links to skip */ H5G_lib_iterate_t op; /* Callback for each link */ - void * op_data; /* Callback data for each link */ + void *op_data; /* Callback data for each link */ /* upward */ int op_ret; /* Return value from callback */ @@ -114,7 +113,7 @@ typedef struct { H5G_bt2_ud_common_t common; /* Common info for B-tree user data (must be first) */ hbool_t rem_from_fheap; /* Whether to remove the link from the fractal heap */ haddr_t corder_bt2_addr; /* Address of v2 B-tree indexing creation order */ - H5RS_str_t * grp_full_path_r; /* Full path of group where link is removed */ + H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ hbool_t replace_names; /* Whether to replace the names of open objects */ } H5G_bt2_ud_rm_t; @@ -124,7 +123,7 @@ typedef struct { */ typedef struct { /* downward */ - H5F_t * f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ haddr_t corder_bt2_addr; /* Address of v2 B-tree indexing creation order */ H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ hbool_t replace_names; /* Whether to replace the names of open objects */ @@ -136,8 +135,8 @@ typedef struct { */ typedef struct { /* downward */ - H5F_t * f; /* Pointer to file that fractal heap is in */ - H5HF_t * fheap; /* Fractal heap handle */ + H5F_t *f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle */ H5_index_t idx_type; /* Primary index for removing link */ haddr_t other_bt2_addr; /* Address of "other" v2 B-tree indexing link */ H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ @@ -161,11 +160,11 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t * f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ H5HF_t *fheap; /* Fractal heap handle */ /* downward (from application) */ - char * name; /* Name buffer to fill */ + char *name; /* Name buffer to fill */ size_t name_size; /* Size of name buffer to fill */ /* upward */ @@ -181,7 +180,7 @@ typedef struct { H5F_t *f; /* Pointer to file that fractal heap is in */ /* downward (from application) */ - char * name; /* Name buffer to fill */ + char *name; /* Name buffer to fill */ size_t name_size; /* Size of name buffer to fill */ /* upward */ @@ -194,7 +193,7 @@ typedef struct { */ typedef struct { /* downward (internal) */ - H5F_t * f; /* Pointer to file that fractal heap is in */ + H5F_t *f; /* Pointer to file that fractal heap is in */ H5HF_t *fheap; /* Fractal heap handle */ /* upward */ @@ -250,9 +249,9 @@ H5G__dense_create(H5F_t *f, H5O_linfo_t *linfo, const H5O_pline_t *pline) { H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for names */ - H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for names */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order */ size_t fheap_id_len; /* Fractal heap ID length */ herr_t ret_value = SUCCEED; /* Return value */ @@ -353,13 +352,13 @@ herr_t H5G__dense_insert(H5F_t *f, const H5O_linfo_t *linfo, const H5O_link_t *lnk) { H5G_bt2_ud_ins_t udata; /* User data for v2 B-tree insertion */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ size_t link_size; /* Size of serialized link in the heap */ - H5WB_t * wb = NULL; /* Wrapped buffer for link data */ + H5WB_t *wb = NULL; /* Wrapped buffer for link data */ uint8_t link_buf[H5G_LINK_BUF_SIZE]; /* Buffer for serializing link */ - void * link_ptr = NULL; /* Pointer to serialized link */ + void *link_ptr = NULL; /* Pointer to serialized link */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -455,7 +454,7 @@ static herr_t H5G__dense_lookup_cb(const void *_lnk, void *_user_lnk) { const H5O_link_t *lnk = (const H5O_link_t *)_lnk; /* Record from B-tree */ - H5O_link_t * user_lnk = (H5O_link_t *)_user_lnk; /* User data from v2 B-tree link lookup */ + H5O_link_t *user_lnk = (H5O_link_t *)_user_lnk; /* User data from v2 B-tree link lookup */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -490,8 +489,8 @@ htri_t H5G__dense_lookup(H5F_t *f, const H5O_linfo_t *linfo, const char *name, H5O_link_t *lnk) { H5G_bt2_ud_common_t udata; /* User data for v2 B-tree link lookup */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -551,7 +550,7 @@ static herr_t H5G__dense_lookup_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) { H5G_fh_ud_lbi_t *udata = (H5G_fh_ud_lbi_t *)_udata; /* User data for fractal heap 'op' callback */ - H5O_link_t * tmp_lnk = NULL; /* Temporary pointer to link */ + H5O_link_t *tmp_lnk = NULL; /* Temporary pointer to link */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -589,7 +588,7 @@ static herr_t H5G__dense_lookup_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; - H5G_bt2_ud_lbi_t * bt2_udata = (H5G_bt2_ud_lbi_t *)_bt2_udata; /* User data for callback */ + H5G_bt2_ud_lbi_t *bt2_udata = (H5G_bt2_ud_lbi_t *)_bt2_udata; /* User data for callback */ H5G_fh_ud_lbi_t fh_udata; /* User data for fractal heap 'op' callback */ int ret_value = H5_ITER_CONT; /* Return value */ @@ -625,9 +624,9 @@ herr_t H5G__dense_lookup_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ herr_t ret_value = SUCCEED; /* Return value */ @@ -866,7 +865,7 @@ static herr_t H5G__dense_iterate_bt2_cb(const void *_record, void *_bt2_udata) { const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; - H5G_bt2_ud_it_t * bt2_udata = (H5G_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ + H5G_bt2_ud_it_t *bt2_udata = (H5G_bt2_ud_it_t *)_bt2_udata; /* User data for callback */ herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -920,9 +919,9 @@ herr_t H5G__dense_iterate(H5F_t *f, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ herr_t ret_value = FAIL; /* Return value */ @@ -1034,7 +1033,7 @@ static herr_t H5G__dense_get_name_by_idx_fh_cb(const void *obj, size_t obj_len, void *_udata) { H5G_fh_ud_gnbi_t *udata = (H5G_fh_ud_gnbi_t *)_udata; /* User data for fractal heap 'op' callback */ - H5O_link_t * lnk; /* Pointer to link created from heap object */ + H5O_link_t *lnk; /* Pointer to link created from heap object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1077,7 +1076,7 @@ static herr_t H5G__dense_get_name_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; - H5G_bt2_ud_gnbi_t * bt2_udata = (H5G_bt2_ud_gnbi_t *)_bt2_udata; /* User data for callback */ + H5G_bt2_ud_gnbi_t *bt2_udata = (H5G_bt2_ud_gnbi_t *)_bt2_udata; /* User data for callback */ H5G_fh_ud_gnbi_t fh_udata; /* User data for fractal heap 'op' callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1117,9 +1116,9 @@ ssize_t H5G__dense_get_name_by_idx(H5F_t *f, H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name, size_t size) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ ssize_t ret_value = -1; /* Return value */ @@ -1232,8 +1231,8 @@ static herr_t H5G__dense_remove_fh_cb(const void *obj, size_t obj_len, void *_udata) { H5G_fh_ud_rm_t *udata = (H5G_fh_ud_rm_t *)_udata; /* User data for fractal heap 'op' callback */ - H5O_link_t * lnk = NULL; /* Pointer to link created from heap object */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5O_link_t *lnk = NULL; /* Pointer to link created from heap object */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1297,7 +1296,7 @@ static herr_t H5G__dense_remove_bt2_cb(const void *_record, void *_bt2_udata) { const H5G_dense_bt2_name_rec_t *record = (const H5G_dense_bt2_name_rec_t *)_record; - H5G_bt2_ud_rm_t * bt2_udata = (H5G_bt2_ud_rm_t *)_bt2_udata; /* User data for callback */ + H5G_bt2_ud_rm_t *bt2_udata = (H5G_bt2_ud_rm_t *)_bt2_udata; /* User data for callback */ H5G_fh_ud_rm_t fh_udata; /* User data for fractal heap 'op' callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1337,9 +1336,9 @@ H5G__dense_remove_bt2_cb(const void *_record, void *_bt2_udata) herr_t H5G__dense_remove(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, const char *name) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1433,8 +1432,8 @@ H5G__dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) { H5G_bt2_ud_rmbi_t *bt2_udata = (H5G_bt2_ud_rmbi_t *)_bt2_udata; /* User data for callback */ H5G_fh_ud_rmbi_t fh_udata; /* User data for fractal heap 'op' callback */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ - const uint8_t * heap_id; /* Heap ID for link */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ + const uint8_t *heap_id; /* Heap ID for link */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1539,9 +1538,9 @@ herr_t H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1660,7 +1659,7 @@ H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link) * the ref. count when transitioning back to compact storage) */ if (adj_link) { - H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_bt2_ud_rm_t udata; /* User data for v2 B-tree record removal */ /* Open the fractal heap */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 037669b1e76..bb0b0f3c524 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -59,7 +58,7 @@ typedef struct { H5G_stat_t *statbuf; /* Stat buffer about object */ hbool_t follow_link; /* Whether we are following a link or not */ - H5F_t * loc_file; /* Pointer to the file the location is in */ + H5F_t *loc_file; /* Pointer to the file the location is in */ } H5G_trav_goi_t; /********************/ @@ -162,8 +161,8 @@ H5G_map_obj_type(H5O_type_t obj_type) hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { - void * grp = NULL; /* New group created */ - H5VL_object_t * vol_obj; /* Object of loc_id */ + void *grp = NULL; /* New group created */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t tmp_gcpl = H5I_INVALID_HID; /* Temporary group creation property list */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -260,8 +259,8 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) hid_t H5Gopen1(hid_t loc_id, const char *name) { - void * grp = NULL; /* Group opened */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + void *grp = NULL; /* Group opened */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -325,7 +324,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new /* Create link */ if (type == H5L_TYPE_HARD) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; H5VL_object_t tmp_vol_obj; /* Temporary object */ @@ -354,7 +353,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if (type == H5L_TYPE_SOFT) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; loc_params.type = H5VL_OBJECT_BY_NAME; @@ -407,8 +406,8 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_ /* Create the appropriate kind of link */ if (type == H5L_TYPE_HARD) { - H5VL_object_t * vol_obj1; /* Object of loc_id */ - H5VL_object_t * vol_obj2; /* Object of loc_id */ + H5VL_object_t *vol_obj1; /* Object of loc_id */ + H5VL_object_t *vol_obj2; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; @@ -435,7 +434,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if (type == H5L_TYPE_SOFT) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Soft links only need one location, the new_loc_id, but it's possible that @@ -475,7 +474,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_ herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -519,9 +518,9 @@ H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { - H5VL_object_t * vol_obj1 = NULL; /* Object of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t * vol_obj2 = NULL; /* Object of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -572,7 +571,7 @@ H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *d herr_t H5Gunlink(hid_t loc_id, const char *name) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -616,7 +615,7 @@ H5Gunlink(hid_t loc_id, const char *name) herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -669,7 +668,7 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/) herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -728,7 +727,7 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment) int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; ssize_t op_ret; /* Return value from operation */ int ret_value; /* Return value */ @@ -794,7 +793,7 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) herr_t H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *op_data) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5G_link_iterate_t lnk_op; /* Link operator */ hsize_t last_obj; /* Index of last object looked at */ @@ -862,7 +861,7 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *o herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t id_type; /* Type of ID */ H5VL_loc_params_t loc_params; H5G_info_t grp_info; /* Group information */ @@ -918,7 +917,7 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf /*out*/) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1138,7 +1137,7 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5 ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ @@ -1189,7 +1188,7 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5O_info2_t oinfo; /* Object info (contains object type) */ H5G_obj_t ret_value; /* Return value */ diff --git a/src/H5Gent.c b/src/H5Gent.c index 2f1a2b44c5c..f58ef5c63d1 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -300,7 +299,7 @@ H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) *------------------------------------------------------------------------- */ void -H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) +H5G__ent_copy(H5G_entry_t *dst, H5G_entry_t *src, H5_copy_depth_t depth) { FUNC_ENTER_PACKAGE_NOERR @@ -318,8 +317,7 @@ H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) ; } else if (depth == H5_COPY_SHALLOW) { - /* Discarding 'const' qualifier OK - QAK */ - H5G__ent_reset((H5G_entry_t *)src); + H5G__ent_reset(src); } /* end if */ FUNC_LEAVE_NOAPI_VOID @@ -422,7 +420,7 @@ H5G__ent_convert(H5F_t *f, H5HL_t *heap, const char *name, const H5O_link_t *lnk else if (obj_type == H5O_TYPE_UNKNOWN) { /* Try to retrieve symbol table information for caching */ H5O_loc_t targ_oloc; /* Location of link target */ - H5O_t * oh; /* Link target object header */ + H5O_t *oh; /* Link target object header */ H5O_stab_t stab; /* Link target symbol table */ htri_t stab_exists; /* Whether the target symbol table exists */ diff --git a/src/H5Gint.c b/src/H5Gint.c index 74883577876..eb983cdad52 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -55,23 +54,23 @@ typedef struct { /* User data for application-style iteration over links in a group */ typedef struct { hid_t gid; /* The group ID for the application callback */ - H5O_loc_t * link_loc; /* The object location for the link */ + H5O_loc_t *link_loc; /* The object location for the link */ H5G_link_iterate_t lnk_op; /* Application callback */ - void * op_data; /* Application's op data */ + void *op_data; /* Application's op data */ } H5G_iter_appcall_ud_t; /* User data for recursive traversal over links from a group */ typedef struct { hid_t gid; /* The group ID for the starting group */ - H5G_loc_t * curr_loc; /* Location of starting group */ + H5G_loc_t *curr_loc; /* Location of starting group */ H5_index_t idx_type; /* Index to use */ H5_iter_order_t order; /* Iteration order within index */ - H5SL_t * visited; /* Skip list for tracking visited nodes */ - char * path; /* Path name of the link */ + H5SL_t *visited; /* Skip list for tracking visited nodes */ + char *path; /* Path name of the link */ size_t curr_path_len; /* Current length of the path in the buffer */ size_t path_buf_size; /* Size of path buffer */ H5L_iterate2_t op; /* Application callback */ - void * op_data; /* Application's op data */ + void *op_data; /* Application's op data */ } H5G_iter_visit_ud_t; /********************/ @@ -123,7 +122,7 @@ H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, hid_t g { H5O_obj_create_t ocrt_info; /* Information for object creation */ H5G_obj_create_t gcrt_info; /* Information for group creation */ - H5G_t * ret_value = NULL; /* Return value */ + H5G_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -175,9 +174,9 @@ H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, hid_t g H5G_t * H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info) { - H5G_t * grp = NULL; /*new group */ + H5G_t *grp = NULL; /*new group */ unsigned oloc_init = 0; /* Flag to indicate that the group object location was created successfully */ - H5G_t * ret_value = NULL; /* Return value */ + H5G_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -246,13 +245,13 @@ H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info) H5G_t * H5G__open_name(const H5G_loc_t *loc, const char *name) { - H5G_t * grp = NULL; /* Group to open */ + H5G_t *grp = NULL; /* Group to open */ H5G_loc_t grp_loc; /* Location used to open group */ H5G_name_t grp_path; /* Opened object group hier. path */ H5O_loc_t grp_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ H5O_type_t obj_type; /* Type of object at location */ - H5G_t * ret_value = NULL; /* Return value */ + H5G_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -309,9 +308,9 @@ H5G__open_name(const H5G_loc_t *loc, const char *name) H5G_t * H5G_open(const H5G_loc_t *loc) { - H5G_t * grp = NULL; /* Group opened */ + H5G_t *grp = NULL; /* Group opened */ H5G_shared_t *shared_fo; /* Shared group object */ - H5G_t * ret_value = NULL; /* Return value */ + H5G_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -502,7 +501,7 @@ H5G_close(H5G_t *grp) else /* Free object location (i.e. "unhold" the file if appropriate) */ if (H5O_loc_free(&(grp->oloc)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "problem attempting to free location") + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "problem attempting to free location") /* If this group is a mount point and the mount point is the last open * reference to the group (i.e. fo_count == 1 now), then attempt to @@ -562,7 +561,7 @@ H5G_oloc(H5G_t *grp) *------------------------------------------------------------------------- */ H5G_name_t * -H5G_nameof(const H5G_t *grp) +H5G_nameof(H5G_t *grp) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -764,7 +763,7 @@ H5G_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter hsize_t *last_lnk, const H5G_link_iterate_t *lnk_op, void *op_data) { hid_t gid = H5I_INVALID_HID; /* ID of group to iterate over */ - H5G_t * grp = NULL; /* Pointer to group data structure to iterate over */ + H5G_t *grp = NULL; /* Pointer to group data structure to iterate over */ H5G_iter_appcall_ud_t udata; /* User data for callback */ herr_t ret_value = FAIL; /* Return value */ @@ -910,15 +909,13 @@ H5G__visit_cb(const H5O_link_t *lnk, void *_udata) /* Check if we've seen the object the link references before */ if (NULL == H5SL_search(udata->visited, &obj_pos)) { H5O_type_t otype; /* Basic object type (group, dataset, etc.) */ - unsigned rc; /* Reference count of object */ /* Get the object's reference count and type */ - if (H5O_get_rc_and_type(&obj_oloc, &rc, &otype) < 0) + if (H5O_get_rc_and_type(&obj_oloc, NULL, &otype) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info") - /* If its ref count is > 1, we add it to the list of visited objects */ - /* (because it could come up again during traversal) */ - if (rc > 1) { + /* Add it to the list of visited objects */ + { H5_obj_t *new_node; /* New object node for visited list */ /* Allocate new object "position" node */ @@ -932,11 +929,11 @@ H5G__visit_cb(const H5O_link_t *lnk, void *_udata) if (H5SL_insert(udata->visited, new_node, new_node) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert object node into visited list") - } /* end if */ + } /* If it's a group, we recurse into it */ if (otype == H5O_TYPE_GROUP) { - H5G_loc_t * old_loc = udata->curr_loc; /* Pointer to previous group location info */ + H5G_loc_t *old_loc = udata->curr_loc; /* Pointer to previous group location info */ H5_index_t idx_type = udata->idx_type; /* Type of index to use */ H5O_linfo_t linfo; /* Link info message */ htri_t linfo_exists; /* Whether the link info message exists */ @@ -1025,9 +1022,8 @@ H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_o H5O_linfo_t linfo; /* Link info message */ htri_t linfo_exists; /* Whether the link info message exists */ hid_t gid = H5I_INVALID_HID; /* Group ID */ - H5G_t * grp = NULL; /* Group opened */ + H5G_t *grp = NULL; /* Group opened */ H5G_loc_t start_loc; /* Location of starting group */ - unsigned rc; /* Reference count of object */ herr_t ret_value = FAIL; /* Return value */ /* Portably clear udata struct (before FUNC_ENTER) */ @@ -1069,13 +1065,8 @@ H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_o if ((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects") - /* Get the group's reference count */ - if (H5O_get_rc_and_type(&grp->oloc, &rc, NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object info") - - /* If its ref count is > 1, we add it to the list of visited objects */ - /* (because it could come up again during traversal) */ - if (rc > 1) { + /* Add it to the list of visited objects */ + { H5_obj_t *obj_pos; /* New object node for visited list */ /* Allocate new object "position" node */ @@ -1089,7 +1080,7 @@ H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_o /* Add to list of visited objects */ if (H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") - } /* end if */ + } /* Attempt to get the link info for this group */ if ((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo)) < 0) diff --git a/src/H5Glink.c b/src/H5Glink.c index 629cb119c2d..87b558c4864 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 54c2ceede43..93f1494d86f 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -99,7 +98,7 @@ typedef struct { /* User data for getting an object's comment in a group */ typedef struct { /* downward */ - char * comment; /* Object comment buffer */ + char *comment; /* Object comment buffer */ size_t bufsize; /* Size of object comment buffer */ /* upward */ @@ -258,7 +257,7 @@ H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc) { - void * obj = NULL; /* VOL object */ + void *obj = NULL; /* VOL object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -562,8 +561,7 @@ H5G_loc_find_by_idx(const H5G_loc_t *loc, const char *group_name, H5_index_t idx *------------------------------------------------------------------------- */ herr_t -H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, - const void *crt_info) +H5G__loc_insert(H5G_loc_t *grp_loc, char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info) { H5O_link_t lnk; /* Link for object to insert */ herr_t ret_value = SUCCEED; /* Return value */ @@ -580,9 +578,8 @@ H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_ty lnk.cset = H5F_DEFAULT_CSET; lnk.corder = 0; /* Will be reset if the group is tracking creation order */ lnk.corder_valid = FALSE; /* Indicate that the creation order isn't valid (yet) */ - /* Casting away const OK -QAK */ - lnk.name = (char *)name; - lnk.u.hard.addr = obj_loc->oloc->addr; + lnk.name = name; + lnk.u.hard.addr = obj_loc->oloc->addr; /* Insert new group into current group's symbol table */ if (H5G_obj_insert(grp_loc->oloc, name, &lnk, TRUE, obj_type, crt_info) < 0) @@ -911,10 +908,10 @@ H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ const H5O_link_t H5_ATTR_UNUSED *lnk, H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { - H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */ - H5O_name_t comment; /* Object header "comment" message */ - htri_t exists; /* Whether a "comment" message already exists */ - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */ + H5O_name_t comment = {0}; /* Object header "comment" message */ + htri_t exists; /* Whether a "comment" message already exists */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -934,13 +931,15 @@ H5G__loc_set_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ /* Add the new message */ if (udata->comment && *udata->comment) { - /* Casting away const OK -QAK */ - comment.s = (char *)udata->comment; + if (NULL == (comment.s = HDstrdup(udata->comment))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't copy group comment") if (H5O_msg_create(obj_loc->oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message") } /* end if */ done: + HDfree(comment.s); + /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; diff --git a/src/H5Gmodule.h b/src/H5Gmodule.h index fe26bd2a14d..3946110936f 100644 --- a/src/H5Gmodule.h +++ b/src/H5Gmodule.h @@ -29,8 +29,858 @@ #define H5_MY_PKG_ERR H5E_SYM #define H5_MY_PKG_INIT YES +/** \page H5G_UG HDF5 Groups + * + * \section sec_group HDF5 Groups + * \subsection subsec_group_intro Introduction + * As suggested by the name Hierarchical Data Format, an HDF5 file is hierarchically structured. + * The HDF5 group and link objects implement this hierarchy. + * + * In the simple and most common case, the file structure is a tree structure; in the general case, the + * file structure may be a directed graph with a designated entry point. The tree structure is very + * similar to the file system structures employed on UNIX systems, directories and files, and on + * Apple and Microsoft Windows systems, folders and files. HDF5 groups are analogous + * to the directories and folders; HDF5 datasets are analogous to the files. + * + * The one very important difference between the HDF5 file structure and the above-mentioned file + * system analogs is that HDF5 groups are linked as a directed graph, allowing circular references; + * the file systems are strictly hierarchical, allowing no circular references. The figures below + * illustrate the range of possibilities. + * + * In the first figure below, the group structure is strictly hierarchical, identical to the file system + * analogs. + * + * In the next two figures below, the structure takes advantage of the directed graph’s allowance of + * circular references. In the second figure, GroupA is not only a member of the root group, /, but a + * member of GroupC. Since Group C is a member of Group B and Group B is a member of Group + * A, Dataset1 can be accessed by means of the circular reference /Group A/Group B/Group + * C/Group A/Dataset1. The third figure below illustrates an extreme case in which GroupB is a + * member of itself, enabling a reference to a member dataset such as /Group A/Group B/Group + * B/Group B/Dataset2. + * + * + * + * + * + *
+ * \image html Groups_fig1.gif "A file with a strictly hierarchical group structure" + *
+ * + * + * + * + * + *
+ * \image html Groups_fig2.gif "A file with a circular reference" + *
+ * + * + * + * + * + *
+ * \image html Groups_fig3.gif "A file with one group as a member of itself" + *
+ * + * As becomes apparent upon reflection, directed graph structures can become quite complex; + * caution is advised! + * + * The balance of this chapter discusses the following topics: + * \li The HDF5 group object (or a group) and its structure in more detail + * \li HDF5 link objects (or links) + * \li The programming model for working with groups and links + * \li HDF5 functions provided for working with groups, group members, and links + * \li Retrieving information about objects in a group + * \li Discovery of the structure of an HDF5 file and the contained objects + * \li Examples of file structures + * + * \subsection subsec_group_descr Description of the Group Object + * \subsubsection subsubsec_group_descr_object The Group Object + * Abstractly, an HDF5 group contains zero or more objects and every object must be a member of + * at least one group. The root group, the sole exception, may not belong to any group. + * + * + * + * + * + *
+ * \image html Groups_fig4.gif "Abstract model of the HDF5 group object" + *
+ * + * Group membership is actually implemented via link objects. See the figure above. A link object + * is owned by a group and points to a named object. Each link has a name, and each link points to + * exactly one object. Each named object has at least one and possibly many links to it. + * + * There are three classes of named objects: group, dataset, and committed datatype (formerly + * called named datatype). See the figure below. Each of these objects is the member of at least one + * group, which means there is at least one link to it. + * + * + * + * + * + *
+ * \image html Groups_fig5.gif "Classes of named objects" + *
+ * + * The primary operations on a group are to add and remove members and to discover member + * objects. These abstract operations, as listed in the figure below, are implemented in the \ref H5G + * APIs. For more information, @see @ref subsec_group_function. + * + * To add and delete members of a group, links from the group to existing objects in the file are + * created and deleted with the link and unlink operations. When a new named object is created, the + * HDF5 Library executes the link operation in the background immediately after creating the + * object (in other words, a new object is added as a member of the group in which it is created + * without further user intervention). + * + * Given the name of an object, the get_object_info method retrieves a description of the object, + * including the number of references to it. The iterate method iterates through the members of the + * group, returning the name and type of each object. + * + * + * + * + * + *
+ * \image html Groups_fig6.gif "The group object" + *
+ * + * Every HDF5 file has a single root group, with the name /. The root group is identical to any other + * HDF5 group, except: + * \li The root group is automatically created when the HDF5 file is created (#H5Fcreate). + * \li The root group has no parent, but by convention has a reference count of 1. + * \li The root group cannot be deleted (in other words, unlinked)! + * + * \subsubsection subsubsec_group_descr_model The Hierarchy of Data Objects + * An HDF5 file is organized as a rooted, directed graph using HDF5 group objects. The named + * data objects are the nodes of the graph, and the links are the directed arcs. Each arc of the graph + * has a name, with the special name / reserved for the root group. New objects are created and then + * inserted into the graph with a link operation that is automatically executed by the library; + * existing objects are inserted into the graph with a link operation explicitly called by the user, + * which creates a named link from a group to the object. + * + * An object can be the target of more than one link. + * + * The names on the links must be unique within each group, but there may be many links with the + * same name in different groups. These are unambiguous, because some ancestor must have a + * different name, or else they are the same object. The graph is navigated with path names, + * analogous to Unix file systems. For more information, @see @ref subsubsec_group_descr_path. + * + * An object can be opened with a full path starting at the root group, or with a relative path and a + * starting point. That starting point is always a group, though it may be the current working group, + * another specified group, or the root group of the file. Note that all paths are relative to a single + * HDF5 file. In this sense, an HDF5 file is analogous to a single UNIX file system. + * + * It is important to note that, just like the UNIX file system, HDF5 objects do not have names, the + * names are associated with paths. An object has an object identifier that is unique within the file, + * but a single object may have many names because there may be many paths to the same object. + * An object can be renamed, or moved to another group, by adding and deleting links. In this case, + * the object itself never moves. For that matter, membership in a group has no implication for the + * physical location of the stored object. + * + * Deleting a link to an object does not necessarily delete the object. The object remains available + * as long as there is at least one link to it. After all links to an object are deleted, it can no longer + * be opened, and the storage may be reclaimed. + * + * It is also important to realize that the linking mechanism can be used to construct very complex + * graphs of objects. For example, it is possible for an object to be shared between several groups + * and even to have more than one name in the same group. It is also possible for a group to be a + * member of itself, or to create other cycles in the graph, such as in the case where a child group is + * linked to one of its ancestors. + * + * HDF5 also has soft links similar to UNIX soft links. A soft link is an object that has a name and + * a path name for the target object. The soft link can be followed to open the target of the link just + * like a regular or hard link. The differences are that the hard link cannot be created if the target + * object does not exist and it always points to the same object. A soft link can be created with any + * path name, whether or not the object exists; it may or may not, therefore, be possible to follow a + * soft link. Furthermore, a soft link’s target object may be changed. + * + * \subsubsection subsubsec_group_descr_path HDF5 Path Names + * The structure of the HDF5 file constitutes the name space for the objects in the file. A path name + * is a string of components separated by slashes (/). Each component is the name of a hard or soft + * link which points to an object in the file. The slash not only separates the components, but + * indicates their hierarchical relationship; the component indicated by the link name following a + * slash is a always a member of the component indicated by the link name preceding that slash. + * + * The first component in the path name may be any of the following: + * \li The special character dot (., a period), indicating the current group + * \li The special character slash (/), indicating the root group + * \li Any member of the current group + * + * Component link names may be any string of ASCII characters not containing a slash or a dot + * (/ and ., which are reserved as noted above). However, users are advised to avoid the use of + * punctuation and non-printing characters, as they may create problems for other software. The + * figure below provides a BNF grammar for HDF5 path names. + * + * A BNF grammar for HDF5 path names + * \code + * PathName ::= AbsolutePathName | RelativePathName + * Separator ::= "/" ["/"]* + * AbsolutePathName ::= Separator [ RelativePathName ] + * RelativePathName ::= Component [ Separator RelativePathName ]* + * Component ::= "." | Characters + * Characters ::= Character+ - { "." } + * Character ::= {c: c Î { { legal ASCII characters } - {'/'} } + * \endcode + * + * An object can always be addressed by either a full or an absolute path name, starting at the root + * group, or by a relative path name, starting in a known location such as the current working + * group. As noted elsewhere, a given object may have multiple full and relative path names. + * + * Consider, for example, the file illustrated in the figure below. Dataset1 can be identified by either + * of these absolute path names: + * /GroupA/Dataset1 + * + * /GroupA/GroupB/GroupC/Dataset1 + * + * Since an HDF5 file is a directed graph structure, and is therefore not limited to a strict tree + * structure, and since this illustrated file includes the sort of circular reference that a directed graph + * enables, Dataset1 can also be identified by this absolute path name: + * /GroupA/GroupB/GroupC/GroupA/Dataset1 + * + * Alternatively, if the current working location is GroupB, Dataset1 can be identified by either of + * these relative path names: + * GroupC/Dataset1 + * + * GroupC/GroupA/Dataset1 + * + * Note that relative path names in HDF5 do not employ the ../ notation, the UNIX notation + * indicating a parent directory, to indicate a parent group. + * + * + * + * + * + *
+ * \image html Groups_fig2.gif "A file with a circular reference" + *
+ * + * \subsubsection subsubsec_group_descr_impl Group Implementations in HDF5 + * The original HDF5 group implementation provided a single indexed structure for link storage. A + * new group implementation, as of HDF5 Release 1.8.0, enables more efficient compact storage + * for very small groups, improved link indexing for large groups, and other advanced features. + *
    + *
  • The original indexed format remains the default. Links are stored in a B-tree in the + * group’s local heap.
  • + *
  • Groups created in the new compact-or-indexed format, the implementation introduced + * with Release 1.8.0, can be tuned for performance, switching between the compact and + * indexed formats at thresholds set in the user application. + *
      + *
    • The compact format will conserve file space and processing overhead when + * working with small groups and is particularly valuable when a group contains + * no links. Links are stored as a list of messages in the group’s header.
    • + *
    • The indexed format will yield improved performance when working with large + * groups. A large group may contain thousands to millions of members. Links + * are stored in a fractal heap and indexed with an improved B-tree.
    • + *
  • + *
  • The new implementation also enables the use of link names consisting of non-ASCII + * character sets (see #H5Pset_char_encoding) and is required for all link types other than + * hard or soft links; the link types other than hard or soft links are external links and + * user-defined links @see @ref H5L APIs.
  • + *
+ * + * The original group structure and the newer structures are not directly interoperable. By default, a + * group will be created in the original indexed format. An existing group can be changed to a + * compact-or-indexed format if the need arises; there is no capability to change back. As stated + * above, once in the compact-or-indexed format, a group can switch between compact and indexed + * as needed. + * + * Groups will be initially created in the compact-or-indexed format only when one or more of the + * following conditions is met: + *
    + *
  • The low version bound value of the library version bounds property has been set to + * Release 1.8.0 or later in the file access property list (see #H5Pset_libver_bounds). + * Currently, that would require an #H5Pset_libver_bounds call with the low parameter + * set to #H5F_LIBVER_LATEST. + * + * When this property is set for an HDF5 file, all objects in the file will be created using + * the latest available format; no effort will be made to create a file that can be read by + * older libraries.
  • + *
  • The creation order tracking property, #H5P_CRT_ORDER_TRACKED, has been set + * in the group creation property list (see #H5Pset_link_creation_order).
  • + *
+ * + * An existing group, currently in the original indexed format, will be converted to the compact-or- + * indexed format upon the occurrence of any of the following events: + *
    + *
  • An external or user-defined link is inserted into the group. + *
  • A link named with a string composed of non-ASCII characters is inserted into the + * group. + *
+ * + * The compact-or-indexed format offers performance improvements that will be most notable at + * the extremes (for example, in groups with zero members and in groups with tens of thousands of + * members). But measurable differences may sometimes appear at a threshold as low as eight + * group members. Since these performance thresholds and criteria differ from application to + * application, tunable settings are provided to govern the switch between the compact and indexed + * formats (see #H5Pset_link_phase_change). Optimal thresholds will depend on the application and + * the operating environment. + * + * Future versions of HDF5 will retain the ability to create, read, write, and manipulate all groups + * stored in either the original indexed format or the compact-or-indexed format. + * + * \subsection subsec_group_h5dump Using h5dump + * You can use h5dump, the command-line utility distributed with HDF5, to examine a file for + * purposes either of determining where to create an object within an HDF5 file or to verify that + * you have created an object in the intended place. + * + * In the case of the new group created later in this chapter, the following h5dump command will + * display the contents of FileA.h5: + * \code + * h5dump FileA.h5 + * \endcode + * + * For more information, @see @ref subsubsec_group_program_create. + * + * Assuming that the discussed objects, GroupA and GroupB are the only objects that exist in + * FileA.h5, the output will look something like the following: + * \code + * HDF5 "FileA.h5" { + * GROUP "/" { + * GROUP GroupA { + * GROUP GroupB { + * } + * } + * } + * } + * \endcode + * + * h5dump is described on the “HDF5 Tools†page of the \ref RM. + * + * The HDF5 DDL grammar is described in the @ref DDLBNF110. + * + * \subsection subsec_group_function Group Function Summaries + * Functions that can be used with groups (\ref H5G functions) and property list functions that can used + * with groups (\ref H5P functions) are listed below. A number of group functions have been + * deprecated. Most of these have become link (\ref H5L) or object (\ref H5O) functions. These replacement + * functions are also listed below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Group functions
FunctionPurpose
#H5GcreateCreates a new empty group and gives it a name. The + * C function is a macro: \see \ref api-compat-macros.
#H5Gcreate_anonCreates a new empty group without linking it into the file structure.
#H5GopenOpens an existing group for modification and returns a group identifier for that group. + * The C function is a macro: \see \ref api-compat-macros.
#H5GcloseCloses the specified group.
#H5Gget_create_plistGets a group creation property list identifier.
#H5Gget_infoRetrieves information about a group. Use instead of H5Gget_num_objs.
#H5Gget_info_by_idxRetrieves information about a group according to the group’s position within an index.
#H5Gget_info_by_nameRetrieves information about a group.
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Link and object functions
FunctionPurpose
#H5Lcreate_hardCreates a hard link to an object. Replaces H5Glink and H5Glink2.
#H5Lcreate_softCreates a soft link to an object. Replaces H5Glink and H5Glink2.
#H5Lcreate_externalCreates a soft link to an object in a different file. Replaces H5Glink and H5Glink2.
#H5Lcreate_udCreates a link of a user-defined type.
#H5Lget_valReturns the value of a symbolic link. Replaces H5Gget_linkval.
#H5LiterateIterates through links in a group. Replaces H5Giterate. + * See also #H5Ovisit and #H5Lvisit.
#H5Literate_by_nameIterates through links in a group.
#H5LvisitRecursively visits all links starting from a specified group.
#H5OvisitRecursively visits all objects accessible from a specified object.
#H5Lget_infoReturns information about a link. Replaces H5Gget_objinfo.
#H5Oget_infoRetrieves the metadata for an object specified by an identifier. Replaces H5Gget_objinfo.
#H5Lget_name_by_idxRetrieves name of the nth link in a group, according to the order within a specified field + * or index. Replaces H5Gget_objname_by_idx.
#H5Oget_info_by_idxRetrieves the metadata for an object, identifying the object by an index position. Replaces + * H5Gget_objtype_by_idx.
#H5Oget_info_by_nameRetrieves the metadata for an object, identifying the object by location and relative name.
#H5Oset_commentSets the comment for specified object. Replaces H5Gset_comment.
#H5Oget_commentGets the comment for specified object. Replaces H5Gget_comment.
#H5LdeleteRemoves a link from a group. Replaces H5Gunlink.
#H5LmoveRenames a link within an HDF5 file. Replaces H5Gmove and H5Gmove2.
+ * + * \snippet{doc} tables/propertyLists.dox gcpl_table + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Other external link functions
FunctionPurpose
#H5Pset_elink_file_cache_sizeSets the size of the external link open file cache from the specified + * file access property list.
#H5Pget_elink_file_cache_sizeRetrieves the size of the external link open file cache from the specified + * file access property list.
#H5Fclear_elink_file_cacheClears the external link open file cache for a file.
+ * + * \subsection subsec_group_program Programming Model for Groups + * The programming model for working with groups is as follows: + *
  1. Create a new group or open an existing one.
  2. + *
  3. Perform the desired operations on the group. + *
    • Create new objects in the group.
    • + *
    • Insert existing objects as group members.
    • + *
    • Delete existing members.
    • + *
    • Open and close member objects.
    • + *
    • Access information regarding member objects.
    • + *
    • Iterate across group members.
    • + *
    • Manipulate links.
    + *
  4. Terminate access to the group (Close the group).
+ * + * \subsubsection subsubsec_group_program_create Creating a Group + * To create a group, use #H5Gcreate, specifying the location and the path of the new group. The + * location is the identifier of the file or the group in a file with respect to which the new group is to + * be identified. The path is a string that provides either an absolute path or a relative path to the + * new group. For more information, @see @ref subsubsec_group_descr_path. + * + * A path that begins with a slash (/) is + * an absolute path indicating that it locates the new group from the root group of the HDF5 file. A + * path that begins with any other character is a relative path. When the location is a file, a relative + * path is a path from that file’s root group; when the location is a group, a relative path is a path + * from that group. + * + * The sample code in the example below creates three groups. The group Data is created in the + * root directory; two groups are then created in /Data, one with absolute path, the other with a + * relative path. + * + * Creating three new groups + * \code + * hid_t file; + * file = H5Fopen(....); + * + * group = H5Gcreate(file, "/Data", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * group_new1 = H5Gcreate(file, "/Data/Data_new1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * group_new2 = H5Gcreate(group, "Data_new2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * \endcode + * The third #H5Gcreate parameter optionally specifies how much file space to reserve to store the + * names that will appear in this group. If a non-positive value is supplied, a default size is chosen. + * + * \subsubsection subsubsec_group_program_open Opening a Group and Accessing an Object in that Group + * Though it is not always necessary, it is often useful to explicitly open a group when working + * with objects in that group. Using the file created in the example above, the example below + * illustrates the use of a previously-acquired file identifier and a path relative to that file to open + * the group Data. + * + * Any object in a group can be also accessed by its absolute or relative path. To open an object + * using a relative path, an application must first open the group or file on which that relative path + * is based. To open an object using an absolute path, the application can use any location identifier + * in the same file as the target object; the file identifier is commonly used, but object identifier for + * any object in that file will work. Both of these approaches are illustrated in the example below. + * + * Using the file created in the examples above, the example below provides sample code + * illustrating the use of both relative and absolute paths to access an HDF5 data object. The first + * sequence (two function calls) uses a previously-acquired file identifier to open the group Data, + * and then uses the returned group identifier and a relative path to open the dataset CData. The + * second approach (one function call) uses the same previously-acquired file identifier and an + * absolute path to open the same dataset. + * + * Open a dataset with relative and absolute paths + * \code + * group = H5Gopen(file, "Data", H5P_DEFAULT); + * + * dataset1 = H5Dopen(group, "CData", H5P_DEFAULT); + * dataset2 = H5Dopen(file, "/Data/CData", H5P_DEFAULT); + * \endcode + * + * \subsubsection subsubsec_group_program_dataset Creating a Dataset in a Specific Group + * Any dataset must be created in a particular group. As with groups, a dataset may be created in a + * particular group by specifying its absolute path or a relative path. The example below illustrates + * both approaches to creating a dataset in the group /Data. + * + * Create a dataset with absolute and relative paths + * \code + * dataspace = H5Screate_simple(RANK, dims, NULL); + * dataset1 = H5Dcreate(file, "/Data/CData", H5T_NATIVE_INT, dataspace, + * H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * group = H5Gopen(file, "Data", H5P_DEFAULT); + * dataset2 = H5Dcreate(group, "Cdata2", H5T_NATIVE_INT, dataspace, + * H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * \endcode + * + * \subsubsection subsubsec_group_program_close Closing a Group + * To ensure the integrity of HDF5 objects and to release system resources, an application should + * always call the appropriate close function when it is through working with an HDF5 object. In + * the case of groups, H5Gclose ends access to the group and releases any resources the HDF5 + * library has maintained in support of that access, including the group identifier. + * + * As illustrated in the example below, all that is required for an H5Gclose call is the group + * identifier acquired when the group was opened; there are no relative versus absolute path + * considerations. + * + * Close a group + * \code + * herr_t status; + * + * status = H5Gclose(group); + * \endcode + * + * A non-negative return value indicates that the group was successfully closed and the resources + * released; a negative return value indicates that the attempt to close the group or release resources + * failed. + * + * \subsubsection subsubsec_group_program_links Creating Links + * As previously mentioned, every object is created in a specific group. Once created, an object can + * be made a member of additional groups by means of links created with one of the H5Lcreate_* + * functions. + * + * A link is, in effect, a path by which the target object can be accessed; it therefore has a name + * which functions as a single path component. A link can be removed with an #H5Ldelete call, + * effectively removing the target object from the group that contained the link (assuming, of + * course, that the removed link was the only link to the target object in the group). + * + *

Hard Links

+ * There are two kinds of links, hard links and symbolic links. Hard links are reference counted; + * symbolic links are not. When an object is created, a hard link is automatically created. An object + * can be deleted from the file by removing all the hard links to it. + * + * Working with the file from the previous examples, the code in the example below illustrates the + * creation of a hard link, named Data_link, in the root group, /, to the group Data. Once that link is + * created, the dataset Cdata can be accessed via either of two absolute paths, /Data/Cdata or + * /Data_Link/Cdata. + * + * Create a hard link + * \code + * status = H5Lcreate_hard(Data_loc_id, "Data", DataLink_loc_id, "Data_link", H5P_DEFAULT, H5P_DEFAULT); + * + * dataset1 = H5Dopen(file, "/Data_link/CData", H5P_DEFAULT); + * dataset2 = H5Dopen(file, "/Data/CData", H5P_DEFAULT); + * \endcode + * + * The example below shows example code to delete a link, deleting the hard link Data from the + * root group. The group /Data and its members are still in the file, but they can no longer be + * accessed via a path using the component /Data. + * + * Delete a link + * \code + * status = H5Ldelete(Data_loc_id, "Data", H5P_DEFAULT); + * + * dataset1 = H5Dopen(file, "/Data_link/CData", H5P_DEFAULT); + * // This call should succeed; all path components still exist + * dataset2 = H5Dopen(file, "/Data/CData", H5P_DEFAULT); + * // This call will fail; the path component '/Data' has been deleted. + * \endcode + * + * When the last hard link to an object is deleted, the object is no longer accessible. #H5Ldelete will + * not prevent you from deleting the last link to an object. To see if an object has only one link, use + * the #H5Oget_info function. If the value of the rc (reference count) field in the is greater than 1, + * then the link can be deleted without making the object inaccessible. + * + * The example below shows #H5Oget_info to the group originally called Data. + * + * Finding the number of links to an object + * \code + * status = H5Oget_info(Data_loc_id, object_info); + * \endcode + * + * It is possible to delete the last hard link to an object and not make the object inaccessible. + * Suppose your application opens a dataset, and then deletes the last hard link to the dataset. While + * the dataset is open, your application still has a connection to the dataset. If your application + * creates a hard link to the dataset before it closes the dataset, then the dataset will still be + * accessible. + * + *

Symbolic Links

+ * Symbolic links are objects that assign a name in a group to a path. Notably, the target object is + * determined only when the symbolic link is accessed, and may, in fact, not exist. Symbolic links + * are not reference counted, so there may be zero, one, or more symbolic links to an object. + * + * The major types of symbolic links are soft links and external links. Soft links are symbolic links + * within an HDF5 file and are created with the #H5Lcreate_soft function. Symbolic links to objects + * located in external files, in other words external links, can be created with the + * #H5Lcreate_external function. Symbolic links are removed with the #H5Ldelete function. + * + * The example below shows the creating two soft links to the group /Data. + * + * Create a soft link + * \code + * status = H5Lcreate_soft(path_to_target, link_loc_id, "Soft2", H5P_DEFAULT, H5P_DEFAULT); + * status = H5Lcreate_soft(path_to_target, link_loc_id, "Soft3", H5P_DEFAULT, H5P_DEFAULT); + * dataset = H5Dopen(file, "/Soft2/CData", H5P_DEFAULT); + * \endcode + * + * With the soft links defined in the example above, the dataset CData in the group /Data can now + * be opened with any of the names /Data/CData, /Soft2/CData, or /Soft3/CData. + * + * In release 1.8.7, a cache was added to hold the names of files accessed via external links. The + * size of this cache can be changed to help improve performance. For more information, see the + * entry in the \ref RM for the #H5Pset_elink_file_cache_size function call. + * + *

Note Regarding Hard Links and Soft Links

+ * Note that an object’s existence in a file is governed by the presence of at least one hard link to + * that object. If the last hard link to an object is removed, the object is removed from the file and + * any remaining soft link becomes a dangling link, a link whose target object does not exist. + * + *

Moving or Renaming Objects, and a Warning

+ * An object can be renamed by changing the name of a link to it with #H5Lmove. This has the same + * effect as creating a new link with the new name and deleting the link with the old name. + * + * Exercise caution in the use of #H5Lmove and #H5Ldelete as these functions each include a step + * that unlinks a pointer to an HDF5 object. If the link that is removed is on the only path leading to + * an HDF5 object, that object will become permanently inaccessible in the file. + * + *
Scenario 1: Removing the Last Link
+ * To avoid removing the last link to an object or otherwise making an object inaccessible, use the + * #H5Oget_info function. Make sure that the value of the reference count field (rc) is greater than 1. + * + *
Scenario 2: Moving a Link that Isolates an Object
+ * Consider the following example: assume that the group group2 can only be accessed via the + * following path, where top_group is a member of the file’s root group: + * /top_group/group1/group2/ + * + * Using #H5Lmove, top_group is renamed to be a member ofgroup2. At this point, since + * top_group was the only route from the root group to group1, there is no longer a path by which + * one can access group1, group2, or any member datasets. And since top_group is now a member + * of group2, top_group itself and any member datasets have thereby also become inaccessible. + * + *

Mounting a File

+ * An external link is a permanent connection between two files. A temporary connection can be set + * up with the #H5Fmount function. For more information, @see sec_file. + * For more information, see the #H5Fmount function in the \ref RM. + * + * \subsubsection subsubsec_group_program_info Discovering Information about Objects + * There is often a need to retrieve information about a particular object. The #H5Lget_info and + * #H5Oget_info functions fill this niche by returning a description of the object or link in an + * #H5L_info_t or #H5O_info_t structure. + * + * \subsubsection subsubsec_group_program_objs Discovering Objects in a Group + * To examine all the objects or links in a group, use the #H5Literate or #H5Ovisit functions to + * examine the objects, and use the #H5Lvisit function to examine the links. #H5Literate is useful + * both with a single group and in an iterative process that examines an entire file or section of a + * file (such as the contents of a group or the contents of all the groups that are members of that + * group) and acts on objects as they are encountered. #H5Ovisit recursively visits all objects + * accessible from a specified object. #H5Lvisit recursively visits all the links starting from a + * specified group. + * + * \subsubsection subsubsec_group_program_all Discovering All of the Objects in the File + * The structure of an HDF5 file is self-describing, meaning that an application can navigate an + * HDF5 file to discover and understand all the objects it contains. This is an iterative process + * wherein the structure is traversed as a graph, starting at one node and recursively visiting linked + * nodes. To explore the entire file, the traversal should start at the root group. + * + * \subsection subsec_group_examples Examples of File Structures + * This section presents several samples of HDF5 file structures. + * + * Figure 9 shows examples of the structure of a file with three groups and one dataset. The file in + * part a contains three groups: the root group and two member groups. In part b, the dataset + * dset1 has been created in /group1. In part c, a link named dset2 from /group2 to the dataset has + * been added. Note that there is only one copy of the dataset; there are two links to it and it can be + * accessed either as /group1/dset1 or as /group2/dset2. + * + * Part d illustrates that one of the two links to the dataset can be deleted. In this case, the link from + * /group1 + * has been removed. The dataset itself has not been deleted; it is still in the file but can only be + * accessed as + * /group2/dset2 + * + * + * + * + * + * + * + * + * + * + * + *
Figure 9 - Some file structures
+ * \image html Groups_fig9_a.gif "a) The file contains three groups: the root group, /group1, and /group2." + * + * \image html Groups_fig9_b.gif "b) The dataset dset1 (or /group1/dset1) is created in /group1." + *
+ * \image html Groups_fig9_aa.gif "c) A link named dset2 to the same dataset is created in /group2." + * + * \image html Groups_fig9_bb.gif "d) The link from /group1 to dset1 is removed. The dataset is + * still in the file, but can be accessed only as /group2/dset2." + *
+ * + * Figure 10 illustrates loops in an HDF5 file structure. The file in part a contains three groups + * and a dataset; group2 is a member of the root group and of the root group’s other member group, + * group1. group2 thus can be accessed by either of two paths: /group2 or /group1/GXX. Similarly, + * the dataset can be accessed either as /group2/dset1 or as /group1/GXX/dset1. + * + * Part b illustrates a different case: the dataset is a member of a single group but with two links, or + * names, in that group. In this case, the dataset again has two names, /group1/dset1 and + * /group1/dset2. + * + * In part c, the dataset dset1 is a member of two groups, one of which can be accessed by either of + * two names. The dataset thus has three path names: /group1/dset1, /group2/dset2, and + * /group1/GXX/dset2. + * + * And in part d, two of the groups are members of each other and the dataset is a member of both + * groups. In this case, there are an infinite number of paths to the dataset because GXX and + * GYY can be traversed any number of times on the way from the root group, /, to the dataset. This + * can yield a path name such as /group1/GXX/GYY/GXX/GYY/GXX/dset2. + * + * + * + * + * + * + * + * + * + * + * + *
Figure 10 - More sample file structures
+ * \image html Groups_fig10_a.gif "a) dset1 has two names: /group2/dset1 and /group1/GXX/dset1." + * + * \image html Groups_fig10_b.gif "b) dset1 again has two names: /group1/dset1 and /group1/dset2." + *
+ * \image html Groups_fig10_c.gif "c) dset1 has three names: /group1/dset1, /group2/dset2, and + * /group1/GXX/dset2." + * + * \image html Groups_fig10_d.gif "d) dset1 has an infinite number of available path names." + *
+ * + * Figure 11 takes us into the realm of soft links. The original file, in part a, contains only three + * hard links. In part b, a soft link named dset2 from group2 to /group1/dset1 has been created, + * making this dataset accessible as /group2/dset2. + * + * In part c, another soft link has been created in group2. But this time the soft link, dset3, points + * to a target object that does not yet exist. That target object, dset, has been added in part d and is + * now accessible as either /group2/dset or /group2/dset3. + * + * It could be said that HDF5 extends the organizing concepts of a file system to the internal + * structure of a single file. + * + * + * + * + * + * + * + * + * + * + * + *
Figure 11 - Hard and soft links
+ * \image html Groups_fig11_a.gif "a) The file contains only hard links." + * + * \image html Groups_fig11_b.gif "b) A soft link is added from group2 to /group1/dset1." + *
+ * \image html Groups_fig11_c.gif "c) A soft link named dset3 is added with a target that does not yet exist." + * + * \image html Groups_fig11_d.gif "d) The target of the soft link is created or linked." + *
+ * + * Previous Chapter \ref sec_file - Next Chapter \ref sec_dataset + * + */ + /** - * \defgroup H5G H5G + * \defgroup H5G Groups (H5G) + * + * Use the functions in this module to manage HDF5 groups. + * + * + * + * + * + * + * + * + * + * + * + *
CreateRead
+ * \snippet{lineno} H5G_examples.c create + * + * \snippet{lineno} H5G_examples.c read + *
UpdateDelete
+ * \snippet{lineno} H5G_examples.c update + * + * \snippet{lineno} H5G_examples.c delete + *
* * \details \Bold{Groups in HDF5:} A group associates names with objects and * provides a mechanism for mapping a name to an object. Since all @@ -74,7 +924,7 @@ * containing thousands to millions of members. Links are stored in * a fractal heap and indexed with an improved B-tree. * \li The new implementation also enables the use of link names consisting of - * non-ASCII character sets (see H5Pset_char_encoding()) and is + * non-ASCII character sets (see #H5Pset_char_encoding) and is * required for all link types other than hard or soft links, e.g., * external and user-defined links (see the \ref H5L APIs). * diff --git a/src/H5Gname.c b/src/H5Gname.c index cc8eaf4d339..6e9222a07ed 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -54,10 +53,10 @@ /* Struct used by change name callback function */ typedef struct H5G_names_t { H5G_names_op_t op; /* Operation performed on file */ - H5F_t * src_file; /* Top file in src location's mounted file hier. */ - H5RS_str_t * src_full_path_r; /* Source location's full path */ - H5F_t * dst_file; /* Destination location's file */ - H5RS_str_t * dst_full_path_r; /* Destination location's full path */ + H5F_t *src_file; /* Top file in src location's mounted file hier. */ + H5RS_str_t *src_full_path_r; /* Source location's full path */ + H5F_t *dst_file; /* Destination location's file */ + H5RS_str_t *dst_full_path_r; /* Destination location's full path */ } H5G_names_t; /* Info to pass to the iteration function when building name */ @@ -147,10 +146,10 @@ H5G__component(const char *name, size_t *size_p) char * H5G_normalize(const char *name) { - char * norm; /* Pointer to the normalized string */ + char *norm; /* Pointer to the normalized string */ size_t s, d; /* Positions within the strings */ unsigned last_slash; /* Flag to indicate last character was a slash */ - char * ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -274,7 +273,7 @@ H5G__common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) static H5RS_str_t * H5G__build_fullpath(const char *prefix, const char *name) { - char * full_path; /* Full user path built */ + char *full_path; /* Full user path built */ size_t orig_path_len; /* Original length of the path */ size_t path_len; /* Length of the path */ size_t name_len; /* Length of the name */ @@ -307,7 +306,7 @@ H5G__build_fullpath(const char *prefix, const char *name) /* Build full path */ HDstrncpy(full_path, prefix, orig_path_len + 1); if (need_sep) - HDstrncat(full_path, "/", (size_t)1); + HDstrcat(full_path, "/"); HDstrncat(full_path, name, name_len); /* Create reference counted string for path */ @@ -647,7 +646,7 @@ H5G__name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char size_t path_prefix2_len; /* Length of 2nd path prefix */ const char *common_prefix; /* Common prefix for src & dst paths */ size_t common_prefix_len; /* Length of common prefix */ - char * new_path; /* Pointer to new path */ + char *new_path; /* Pointer to new path */ size_t new_path_len; /* Length of new path */ /* Compute path prefix before full suffix*/ @@ -719,9 +718,9 @@ static int H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) { const H5G_names_t *names = (const H5G_names_t *)key; /* Get operation's information */ - H5O_loc_t * oloc; /* Object location for object that the ID refers to */ - H5G_name_t * obj_path; /* Pointer to group hier. path for obj */ - H5F_t * top_obj_file; /* Top file in object's mounted file hier. */ + H5O_loc_t *oloc; /* Object location for object that the ID refers to */ + H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ + H5F_t *top_obj_file; /* Top file in object's mounted file hier. */ hbool_t obj_in_child = FALSE; /* Flag to indicate that the object is in the child mount hier. */ herr_t ret_value = SUCCEED; /* Return value */ @@ -815,7 +814,7 @@ H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) const char *full_path; /* Full path of current object */ const char *src_path; /* Full path of source object */ size_t src_path_len; /* Length of source full path */ - char * new_full_path; /* New full path of object */ + char *new_full_path; /* New full path of object */ size_t new_full_len; /* Length of new full path */ /* Get pointers to paths of interest */ @@ -862,7 +861,7 @@ H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) const char *full_suffix; /* Full path after source path */ size_t full_suffix_len; /* Length of full path after source path */ const char *src_path; /* Full path of source object */ - char * new_full_path; /* New full path of object */ + char *new_full_path; /* New full path of object */ /* Get pointers to paths of interest */ full_path = H5RS_get_str(obj_path->full_path_r); @@ -925,7 +924,7 @@ H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) const char *full_path; /* Full path of current object */ const char *full_suffix; /* Suffix of full path, after src_path */ size_t full_suffix_len; /* Length of suffix of full path after src_path*/ - char * new_full_path; /* New full path of object */ + char *new_full_path; /* New full path of object */ size_t new_full_len; /* Length of new full path */ const char *src_path; /* Full path of source object */ const char *dst_path; /* Full path of destination object */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 9a7da0fffa0..f1c5d5d92b7 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -70,7 +69,7 @@ typedef struct H5G_node_key_t { /********************/ /* B-tree callbacks */ -static H5UC_t * H5G__node_get_shared(const H5F_t *f, const void *_udata); +static H5UC_t *H5G__node_get_shared(const H5F_t *f, const void *_udata); static herr_t H5G__node_create(H5F_t *f, H5B_ins_t op, void *_lt_key, void *_udata, void *_rt_key, haddr_t *addr_p /*out*/); static int H5G__node_cmp2(void *_lt_key, void *_udata, void *_rt_key); @@ -218,7 +217,7 @@ H5G__node_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key) static herr_t H5G__node_debug_key(FILE *stream, int indent, int fwidth, const void *_key, const void *_udata) { - const H5G_node_key_t * key = (const H5G_node_key_t *)_key; + const H5G_node_key_t *key = (const H5G_node_key_t *)_key; const H5G_bt_common_t *udata = (const H5G_bt_common_t *)_udata; FUNC_ENTER_STATIC_NOERR @@ -297,7 +296,7 @@ H5G__node_create(H5F_t *f, H5B_ins_t H5_ATTR_UNUSED op, void *_lt_key, void H5_A { H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; - H5G_node_t * sym = NULL; + H5G_node_t *sym = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -365,9 +364,9 @@ static herr_t H5G__node_cmp2(void *_lt_key, void *_udata, void *_rt_key) { H5G_bt_common_t *udata = (H5G_bt_common_t *)_udata; - H5G_node_key_t * lt_key = (H5G_node_key_t *)_lt_key; - H5G_node_key_t * rt_key = (H5G_node_key_t *)_rt_key; - const char * s1, *s2; + H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; + H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; + const char *s1, *s2; int ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -418,9 +417,9 @@ static herr_t H5G__node_cmp3(void *_lt_key, void *_udata, void *_rt_key) { H5G_bt_common_t *udata = (H5G_bt_common_t *)_udata; - H5G_node_key_t * lt_key = (H5G_node_key_t *)_lt_key; - H5G_node_key_t * rt_key = (H5G_node_key_t *)_rt_key; - const char * s; + H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; + H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; + const char *s; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -476,10 +475,10 @@ static htri_t H5G__node_found(H5F_t *f, haddr_t addr, const void H5_ATTR_UNUSED *_lt_key, void *_udata) { H5G_bt_lkp_t *udata = (H5G_bt_lkp_t *)_udata; - H5G_node_t * sn = NULL; + H5G_node_t *sn = NULL; unsigned lt = 0, idx = 0, rt; int cmp = 1; - const char * s; + const char *s; htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -565,13 +564,13 @@ H5G__node_insert(H5F_t *f, haddr_t addr, void H5_ATTR_UNUSED *_lt_key, hbool_t H { H5G_node_key_t *md_key = (H5G_node_key_t *)_md_key; H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; - H5G_bt_ins_t * udata = (H5G_bt_ins_t *)_udata; - H5G_node_t * sn = NULL, *snrt = NULL; + H5G_bt_ins_t *udata = (H5G_bt_ins_t *)_udata; + H5G_node_t *sn = NULL, *snrt = NULL; unsigned sn_flags = H5AC__NO_FLAGS_SET, snrt_flags = H5AC__NO_FLAGS_SET; - const char * s; + const char *s; unsigned lt = 0, rt; /* Binary search cntrs */ int cmp = 1, idx = -1; - H5G_node_t * insert_into = NULL; /*node that gets new entry*/ + H5G_node_t *insert_into = NULL; /*node that gets new entry*/ H5G_entry_t ent; /* Entry to insert in node */ H5B_ins_t ret_value = H5B_INS_ERROR; @@ -726,8 +725,8 @@ H5G__node_remove(H5F_t *f, haddr_t addr, void H5_ATTR_NDEBUG_UNUSED *_lt_key /*i void *_rt_key /*in,out*/, hbool_t *rt_key_changed /*out*/) { H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key; - H5G_bt_rm_t * udata = (H5G_bt_rm_t *)_udata; - H5G_node_t * sn = NULL; + H5G_bt_rm_t *udata = (H5G_bt_rm_t *)_udata; + H5G_node_t *sn = NULL; unsigned sn_flags = H5AC__NO_FLAGS_SET; unsigned lt = 0, rt, idx = 0; int cmp = 1; @@ -922,8 +921,8 @@ H5G__node_iterate(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata) { H5G_bt_it_it_t *udata = (H5G_bt_it_it_t *)_udata; - H5G_node_t * sn = NULL; - H5G_entry_t * ents; /* Pointer to entries in this node */ + H5G_node_t *sn = NULL; + H5G_entry_t *ents; /* Pointer to entries in this node */ unsigned u; /* Local index variable */ int ret_value = H5_ITER_CONT; @@ -1000,7 +999,7 @@ int H5G__node_sumup(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata) { - hsize_t * num_objs = (hsize_t *)_udata; + hsize_t *num_objs = (hsize_t *)_udata; H5G_node_t *sn = NULL; int ret_value = H5_ITER_CONT; @@ -1045,7 +1044,7 @@ H5G__node_by_idx(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata) { H5G_bt_it_idx_common_t *udata = (H5G_bt_it_idx_common_t *)_udata; - H5G_node_t * sn = NULL; + H5G_node_t *sn = NULL; int ret_value = H5_ITER_CONT; FUNC_ENTER_PACKAGE @@ -1179,9 +1178,9 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const { H5G_bt_it_cpy_t *udata = (H5G_bt_it_cpy_t *)_udata; const H5O_loc_t *src_oloc = udata->src_oloc; - H5O_copy_t * cpy_info = udata->cpy_info; - H5HL_t * heap = NULL; - H5G_node_t * sn = NULL; + H5O_copy_t *cpy_info = udata->cpy_info; + H5HL_t *heap = NULL; + H5G_node_t *sn = NULL; unsigned int i; /* Local index variable */ int ret_value = H5_ITER_CONT; @@ -1205,8 +1204,8 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const H5G_entry_t *src_ent = &(sn->entry[i]); /* Convenience variable to refer to current source group entry */ H5O_link_t lnk; /* Link to insert */ - const char * name; /* Name of source object */ - H5G_entry_t tmp_src_ent; /* Temperary copy. Change will not affect the cache */ + const char *name; /* Name of source object */ + H5G_entry_t tmp_src_ent; /* Temporary copy. Change will not affect the cache */ H5O_type_t obj_type = H5O_TYPE_UNKNOWN; /* Target object type */ H5G_copy_file_ud_t *cpy_udata; /* Copy file udata */ H5G_obj_create_t gcrt_info; /* Group creation info */ @@ -1216,7 +1215,7 @@ H5G__node_copy(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr, const haddr_t obj_addr; /* Address of object pointed to by soft link */ H5G_loc_t grp_loc; /* Group location holding soft link */ H5G_name_t grp_path; /* Path for group holding soft link */ - char * link_name; /* Pointer to value of soft link */ + char *link_name; /* Pointer to value of soft link */ /* Make a temporary copy, so that it will not change the info in the cache */ H5MM_memcpy(&tmp_src_ent, src_ent, sizeof(H5G_entry_t)); @@ -1335,7 +1334,7 @@ H5G__node_build_table(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr const void H5_ATTR_UNUSED *_rt_key, void *_udata) { H5G_bt_it_bt_t *udata = (H5G_bt_it_bt_t *)_udata; - H5G_node_t * sn = NULL; /* Symbol table node */ + H5G_node_t *sn = NULL; /* Symbol table node */ unsigned u; /* Local index variable */ int ret_value = H5_ITER_CONT; @@ -1358,7 +1357,7 @@ H5G__node_build_table(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, haddr_t addr /* Check if the link table needs to be extended */ if ((udata->ltable->nlinks + sn->nsyms) >= udata->alloc_nlinks) { size_t na = MAX((udata->ltable->nlinks + sn->nsyms), - (udata->alloc_nlinks * 2)); /* Double # of links allocated */ + (udata->alloc_nlinks * 2)); /* Double # of links allocated */ H5O_link_t *x; /* Pointer to larger array of links */ /* Re-allocate the link table */ @@ -1440,7 +1439,7 @@ herr_t H5G_node_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t heap_addr) { H5G_node_t *sn = NULL; - H5HL_t * heap = NULL; + H5HL_t *heap = NULL; unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 7ebd65a8021..271f14fb63a 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -52,7 +51,7 @@ * link storage */ typedef struct { - H5F_t * f; /* Pointer to file for insertion */ + H5F_t *f; /* Pointer to file for insertion */ haddr_t oh_addr; /* Address of the object header */ H5O_linfo_t *linfo; /* Pointer to link info */ } H5G_obj_oh_it_ud1_t; @@ -354,7 +353,7 @@ H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo) static herr_t H5G__obj_compact_to_dense_cb(const void *_mesg, unsigned H5_ATTR_UNUSED idx, void *_udata) { - const H5O_link_t * lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ + const H5O_link_t *lnk = (const H5O_link_t *)_mesg; /* Pointer to link */ H5G_obj_oh_it_ud1_t *udata = (H5G_obj_oh_it_ud1_t *)_udata; /* 'User data' passed in */ herr_t ret_value = H5_ITER_CONT; /* Return value */ @@ -692,7 +691,7 @@ H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, H5_iter_order_t herr_t H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info) { - H5G_t * grp = NULL; /* Group to query */ + H5G_t *grp = NULL; /* Group to query */ H5G_loc_t grp_loc; /* Entry of group to be queried */ H5G_name_t grp_path; /* Group hier. path */ H5O_loc_t grp_oloc; /* Group object location */ @@ -867,7 +866,7 @@ H5G__obj_remove_update_linfo(const H5O_loc_t *oloc, H5O_linfo_t *linfo) /* Check if we should switch from dense storage back to link messages */ if (linfo->nlinks < ginfo.min_dense) { - struct H5O_t * oh = NULL; /* Pointer to group's object header */ + struct H5O_t *oh = NULL; /* Pointer to group's object header */ H5G_link_table_t ltable; /* Table of links */ hbool_t can_convert = TRUE; /* Whether converting to link messages is possible */ size_t u; /* Local index */ @@ -972,7 +971,7 @@ H5G_obj_remove(const H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *n else /* Remove object from the link messages */ if (H5G__compact_remove(oloc, grp_full_path_r, name) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end if */ else { /* Using the old format for groups */ @@ -1111,7 +1110,7 @@ H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) else /* Get the object's info from the symbol table */ if ((ret_value = H5G__stab_lookup(grp_oloc, name, lnk)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") done: FUNC_LEAVE_NOAPI_TAG(ret_value) diff --git a/src/H5Goh.c b/src/H5Goh.c index f6ac79179e9..82732ba20c6 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -40,11 +39,11 @@ /* Local Prototypes */ /********************/ -static void * H5O__group_get_copy_file_udata(void); +static void *H5O__group_get_copy_file_udata(void); static void H5O__group_free_copy_file_udata(void *udata); static htri_t H5O__group_isa(const H5O_t *loc); -static void * H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); -static void * H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); +static void *H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); +static void *H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__group_get_oloc(hid_t obj_id); static herr_t H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); @@ -198,7 +197,7 @@ static void * H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { H5G_t *grp = NULL; /* Group opened */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -237,8 +236,8 @@ static void * H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) { H5G_obj_create_t *crt_info = (H5G_obj_create_t *)_crt_info; /* Group creation parameters */ - H5G_t * grp = NULL; /* New group created */ - void * ret_value = NULL; /* Return value */ + H5G_t *grp = NULL; /* New group created */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -284,7 +283,7 @@ H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc) static H5O_loc_t * H5O__group_get_oloc(hid_t obj_id) { - H5G_t * grp; /* Group opened */ + H5G_t *grp; /* Group opened */ H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index b0adf30f510..904dd41ca76 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -157,7 +156,7 @@ typedef struct { typedef struct H5G_bt_common_t { /* downward */ const char *name; /*points to temporary memory */ - H5HL_t * heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ } H5G_bt_common_t; /* @@ -169,7 +168,7 @@ typedef struct H5G_bt_ins_t { H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ const H5O_link_t *lnk; /* Link to insert into table */ H5O_type_t obj_type; /* Type of object being inserted */ - const void * crt_info; /* Creation info for object being inserted */ + const void *crt_info; /* Creation info for object being inserted */ } H5G_bt_ins_t; /* @@ -179,7 +178,7 @@ typedef struct H5G_bt_ins_t { typedef struct H5G_bt_rm_t { /* downward */ H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ - H5RS_str_t * grp_full_path_r; /* Full path of group where link is removed */ + H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ } H5G_bt_rm_t; /* Typedef for B-tree 'find' operation */ @@ -193,7 +192,7 @@ typedef struct H5G_bt_lkp_t { /* downward */ H5G_bt_common_t common; /* Common info for B-tree user data (must be first) */ H5G_bt_find_op_t op; /* Operator to call when correct entry is found */ - void * op_data; /* Data to pass to operator */ + void *op_data; /* Data to pass to operator */ /* upward */ } H5G_bt_lkp_t; @@ -204,10 +203,10 @@ typedef struct H5G_bt_lkp_t { */ typedef struct H5G_bt_it_it_t { /* downward */ - H5HL_t * heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ hsize_t skip; /*initial entries to skip */ H5G_lib_iterate_t op; /*iteration operator */ - void * op_data; /*user-defined operator data */ + void *op_data; /*user-defined operator data */ /* upward */ hsize_t *final_ent; /*final entry looked at */ @@ -215,11 +214,11 @@ typedef struct H5G_bt_it_it_t { /* Data passed through B-tree iteration for copying copy symbol table content */ typedef struct H5G_bt_it_cpy_t { - const H5O_loc_t * src_oloc; /* Source object location */ + const H5O_loc_t *src_oloc; /* Source object location */ haddr_t src_heap_addr; /* Heap address of the source symbol table */ - H5F_t * dst_file; /* File of destination group */ + H5F_t *dst_file; /* File of destination group */ const H5O_stab_t *dst_stab; /* Symbol table message for destination group */ - H5O_copy_t * cpy_info; /* Information for copy operation */ + H5O_copy_t *cpy_info; /* Information for copy operation */ } H5G_bt_it_cpy_t; /* Common information for "by index" lookups in symbol tables */ @@ -264,13 +263,13 @@ typedef struct H5G_dense_bt2_corder_rec_t { */ typedef struct H5G_bt2_ud_common_t { /* downward */ - H5F_t * f; /* Pointer to file that fractal heap is in */ - H5HF_t * fheap; /* Fractal heap handle */ - const char * name; /* Name of link to compare */ + H5F_t *f; /* Pointer to file that fractal heap is in */ + H5HF_t *fheap; /* Fractal heap handle */ + const char *name; /* Name of link to compare */ uint32_t name_hash; /* Hash of name of link to compare */ int64_t corder; /* Creation order value of link to compare */ H5B2_found_t found_op; /* Callback when correct link is found */ - void * found_op_data; /* Callback data when correct link is found */ + void *found_op_data; /* Callback data when correct link is found */ } H5G_bt2_ud_common_t; /* @@ -374,7 +373,7 @@ H5_DLL herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab); /* * Functions that understand symbol table entries. */ -H5_DLL void H5G__ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth); +H5_DLL void H5G__ent_copy(H5G_entry_t *dst, H5G_entry_t *src, H5_copy_depth_t depth); H5_DLL void H5G__ent_reset(H5G_entry_t *ent); H5_DLL herr_t H5G__ent_decode_vec(const H5F_t *f, const uint8_t **pp, const uint8_t *p_end, H5G_entry_t *ent, unsigned n); @@ -463,7 +462,7 @@ H5_DLL herr_t H5G__name_init(H5G_name_t *name, const char *path); /* * These functions operate on group "locations" */ -H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, +H5_DLL herr_t H5G__loc_insert(H5G_loc_t *grp_loc, char *name, H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info); H5_DLL herr_t H5G__loc_addr(const H5G_loc_t *loc, const char *name, haddr_t *addr /*out*/); diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 409d79003de..734f34639ea 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -146,7 +145,7 @@ struct H5O_link_t; */ typedef struct { struct H5O_loc_t *oloc; /* Object header location */ - H5G_name_t * path; /* Group hierarchy path */ + H5G_name_t *path; /* Group hierarchy path */ } H5G_loc_t; /* Typedef for path traversal operations */ @@ -191,14 +190,14 @@ typedef struct H5G_entry_t H5G_entry_t; */ H5_DLL herr_t H5G_init(void); H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp); -H5_DLL H5G_name_t *H5G_nameof(const H5G_t *grp); -H5_DLL H5F_t *H5G_fileof(H5G_t *grp); -H5_DLL H5G_t * H5G_open(const H5G_loc_t *loc); -H5_DLL herr_t H5G_close(H5G_t *grp); -H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); -H5_DLL herr_t H5G_mount(H5G_t *grp); -H5_DLL hbool_t H5G_mounted(H5G_t *grp); -H5_DLL herr_t H5G_unmount(H5G_t *grp); +H5_DLL H5G_name_t *H5G_nameof(H5G_t *grp); +H5_DLL H5F_t *H5G_fileof(H5G_t *grp); +H5_DLL H5G_t *H5G_open(const H5G_loc_t *loc); +H5_DLL herr_t H5G_close(H5G_t *grp); +H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); +H5_DLL herr_t H5G_mount(H5G_t *grp); +H5_DLL hbool_t H5G_mounted(H5G_t *grp); +H5_DLL herr_t H5G_unmount(H5G_t *grp); #ifndef H5_NO_DEPRECATED_SYMBOLS H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -253,14 +252,14 @@ H5_DLL herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *en /* * These functions operate on group hierarchy names. */ -H5_DLL herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name); -H5_DLL herr_t H5G_name_replace(const struct H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, - H5RS_str_t *src_full_path_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r); -H5_DLL herr_t H5G_name_reset(H5G_name_t *name); -H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth); -H5_DLL herr_t H5G_name_free(H5G_name_t *name); -H5_DLL ssize_t H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cached); -H5_DLL ssize_t H5G_get_name_by_addr(H5F_t *f, const struct H5O_loc_t *loc, char *name, size_t size); +H5_DLL herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name); +H5_DLL herr_t H5G_name_replace(const struct H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, + H5RS_str_t *src_full_path_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r); +H5_DLL herr_t H5G_name_reset(H5G_name_t *name); +H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth); +H5_DLL herr_t H5G_name_free(H5G_name_t *name); +H5_DLL ssize_t H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, hbool_t *cached); +H5_DLL ssize_t H5G_get_name_by_addr(H5F_t *f, const struct H5O_loc_t *loc, char *name, size_t size); H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char *name); /* diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 7f1faf8e6aa..5ffa72a029b 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -120,7 +119,7 @@ extern "C" { * * \since 1.8.0 * - * \see H5Gopen2(), H5Gclose() + * \see H5Gopen2() * */ H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); @@ -167,7 +166,7 @@ H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcp * H5Gclose() when the group is no longer needed so that resource * leaks will not develop. * - * \see H5Olink(), H5Dcreate(), Using Identifiers + * \see H5Olink(), H5Gcreate() * * \since 1.8.0 * @@ -199,7 +198,7 @@ H5_DLL hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); * * \since 1.8.0 * - * \see H5Gcreate2(), H5Gclose() + * \see H5Gcreate2() * */ H5_DLL hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id); @@ -218,12 +217,10 @@ H5_DLL hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id); * property list associated with the group specified by \p group_id. * * The creation property list identifier should be released with - * H5Gclose() to prevent resource leaks. + * H5Pclose() to prevent resource leaks. * * \since 1.8.0 * - * \see H5Gcreate2(), H5Gclose() - * */ H5_DLL hid_t H5Gget_create_plist(hid_t group_id); @@ -250,8 +247,6 @@ H5_DLL hid_t H5Gget_create_plist(hid_t group_id); * * \since 1.8.0 * - * \see H5Gcreate2(), H5Gclose() - * */ H5_DLL herr_t H5Gget_info(hid_t loc_id, H5G_info_t *ginfo); @@ -284,8 +279,6 @@ H5_DLL herr_t H5Gget_info(hid_t loc_id, H5G_info_t *ginfo); * * \since 1.8.0 * - * \see H5Gcreate2(), H5Gclose() - * */ H5_DLL herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *ginfo, hid_t lapl_id); @@ -331,8 +324,6 @@ H5_DLL herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *gi * * \since 1.8.0 * - * \see H5Gcreate2(), H5Gclose() - * */ H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *ginfo, hid_t lapl_id); @@ -360,8 +351,6 @@ H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_ * * \since 1.8.0 * - * \see H5Gcreate2(), H5Gclose() - * */ H5_DLL herr_t H5Gflush(hid_t group_id); @@ -385,8 +374,6 @@ H5_DLL herr_t H5Gflush(hid_t group_id); * * \since 1.8.0 * - * \see H5Gcreate2(), H5Gclose() - * */ H5_DLL herr_t H5Grefresh(hid_t group_id); @@ -660,7 +647,7 @@ H5_DLL herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, * * \attention Exercise care in moving groups as it is possible to render data in * a file inaccessible with H5Gmove(). See The Group Interface in the - * HDF5 User's Guide. + * \ref UG. * * \version 1.8.0 Function deprecated in this release. * @@ -691,7 +678,7 @@ H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_na * * \attention Exercise care in moving groups as it is possible to render data in * a file inaccessible with H5Gmove2(). See The Group Interface in the - * HDF5 User's Guide. + * \ref UG. * * \version 1.8.0 Function deprecated in this release. * @@ -725,14 +712,14 @@ H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, * any object identifier is open for the object, the space will not be * released until after the object identifier is closed. * - * Note that space identified as freespace is available for re-use only + * Note that space identified as freespace is available for reuse only * as long as the file remains open; once a file has been closed, the * HDF5 library loses track of freespace. See “Freespace Management†in - * the HDF5 User's Guide for further details. + * the \ref UG for further details. * * \attention Exercise care in moving groups as it is possible to render data in * a file inaccessible with H5Gunlink(). See The Group Interface in the - * HDF5 User's Guide. + * \ref UG. * * \version 1.8.0 Function deprecated in this release. * @@ -1038,7 +1025,7 @@ H5_DLL herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link * actual object name length, the object name is truncated to * \Code{max_size - 1} characters. * - * Note that if the size of the object's name is unkown, a preliminary + * Note that if the size of the object's name is unknown, a preliminary * call to H5Gget_objname_by_idx() with \p name set to \c NULL will * return the length of the object's name. A second call to * H5Gget_objname_by_idx() can then be used to retrieve the actual diff --git a/src/H5Groot.c b/src/H5Groot.c index 997d187cc81..3629f72d1ce 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 54b28b53200..f9ed032ec2a 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -44,7 +43,7 @@ typedef struct { /* downward */ const char *name; /* Name to search for */ - H5HL_t * heap; /* Local heap for group */ + H5HL_t *heap; /* Local heap for group */ /* upward */ H5O_link_t *lnk; /* Caller's link location */ @@ -54,7 +53,7 @@ typedef struct { typedef struct H5G_bt_it_gnbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ - H5HL_t * heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ /* upward */ char *name; /*member name to be returned */ @@ -65,7 +64,7 @@ typedef struct H5G_bt_it_gnbi_t { typedef struct H5G_bt_it_gtbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ - H5F_t * f; /* Pointer to file that symbol table is in */ + H5F_t *f; /* Pointer to file that symbol table is in */ /* upward */ H5G_obj_t type; /*member type to be returned */ @@ -76,7 +75,7 @@ typedef struct H5G_bt_it_gtbi_t { typedef struct H5G_bt_it_lbi_t { /* downward */ H5G_bt_it_idx_common_t common; /* Common information for "by index" lookup */ - H5HL_t * heap; /*symbol table heap */ + H5HL_t *heap; /*symbol table heap */ /* upward */ H5O_link_t *lnk; /*link to be returned */ @@ -245,7 +244,7 @@ herr_t H5G__stab_insert_real(H5F_t *f, const H5O_stab_t *stab, const char *name, H5O_link_t *obj_lnk, H5O_type_t obj_type, const void *crt_info) { - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5G_bt_ins_t udata; /* Data to pass through B-tree */ herr_t ret_value = SUCCEED; /* Return value */ @@ -334,7 +333,7 @@ H5G__stab_insert(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *obj_ln herr_t H5G__stab_remove(const H5O_loc_t *loc, H5RS_str_t *grp_full_path_r, const char *name) { - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5O_stab_t stab; /*symbol table message */ H5G_bt_rm_t udata; /*data to pass through B-tree */ herr_t ret_value = SUCCEED; /* Return value */ @@ -385,7 +384,7 @@ herr_t H5G__stab_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, H5_iter_order_t order, hsize_t n) { - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5O_stab_t stab; /* Symbol table message */ H5G_bt_rm_t udata; /* Data to pass through B-tree */ H5O_link_t obj_lnk; /* Object's link within group */ @@ -445,7 +444,7 @@ H5G__stab_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, herr_t H5G__stab_delete(H5F_t *f, const H5O_stab_t *stab) { - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5G_bt_rm_t udata; /*data to pass through B-tree */ herr_t ret_value = SUCCEED; /* Return value */ @@ -501,7 +500,7 @@ herr_t H5G__stab_iterate(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data) { - H5HL_t * heap = NULL; /* Local heap for group */ + H5HL_t *heap = NULL; /* Local heap for group */ H5O_stab_t stab; /* Info about symbol table */ H5G_link_table_t ltable = {0, NULL}; /* Link table */ herr_t ret_value = FAIL; /* Return value */ @@ -678,7 +677,7 @@ H5G__stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) { H5G_bt_it_gnbi_t *udata = (H5G_bt_it_gnbi_t *)_udata; size_t name_off; /* Offset of name in heap */ - const char * name; /* Pointer to name string in heap */ + const char *name; /* Pointer to name string in heap */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -716,7 +715,7 @@ H5G__stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) ssize_t H5G__stab_get_name_by_idx(const H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char *name, size_t size) { - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5O_stab_t stab; /* Info about local heap & B-tree */ H5G_bt_it_gnbi_t udata; /* Iteration information */ hbool_t udata_valid = FALSE; /* Whether iteration information is valid */ @@ -835,7 +834,7 @@ H5G__stab_lookup_cb(const H5G_entry_t *ent, void *_udata) htri_t H5G__stab_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk) { - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5G_bt_lkp_t bt_udata; /* Data to pass through B-tree */ H5G_stab_fnd_ud_t udata; /* 'User data' to give to callback */ H5O_stab_t stab; /* Symbol table message */ @@ -897,7 +896,7 @@ static herr_t H5G__stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata) { H5G_bt_it_lbi_t *udata = (H5G_bt_it_lbi_t *)_udata; - const char * name; /* Pointer to name string in heap */ + const char *name; /* Pointer to name string in heap */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -934,7 +933,7 @@ H5G__stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata) herr_t H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk) { - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ H5G_bt_it_lbi_t udata; /* Iteration information */ H5O_stab_t stab; /* Symbol table message */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1016,7 +1015,7 @@ herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab) { H5O_stab_t stab; /* Current symbol table */ - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ hbool_t changed = FALSE; /* Whether stab has been modified */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Gtest.c b/src/H5Gtest.c index d2f3f90e849..f2ba074b2c0 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -86,7 +85,7 @@ htri_t H5G__is_empty_test(hid_t gid) { - H5G_t * grp = NULL; /* Pointer to group */ + H5G_t *grp = NULL; /* Pointer to group */ htri_t msg_exists = FALSE; /* Indicate that a header message is present */ htri_t linfo_exists = FALSE; /* Indicate that the 'link info' message is present */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ @@ -206,7 +205,7 @@ H5G__is_empty_test(hid_t gid) htri_t H5G__has_links_test(hid_t gid, unsigned *nmsgs) { - H5G_t * grp = NULL; /* Pointer to group */ + H5G_t *grp = NULL; /* Pointer to group */ htri_t msg_exists = 0; /* Indicate that a header message is present */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ htri_t ret_value = TRUE; /* Return value */ @@ -272,7 +271,7 @@ H5G__has_links_test(hid_t gid, unsigned *nmsgs) htri_t H5G__has_stab_test(hid_t gid) { - H5G_t * grp = NULL; /* Pointer to group */ + H5G_t *grp = NULL; /* Pointer to group */ htri_t msg_exists = 0; /* Indicate that a header message is present */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ htri_t ret_value = TRUE; /* Return value */ @@ -330,7 +329,7 @@ H5G__has_stab_test(hid_t gid) htri_t H5G__is_new_dense_test(hid_t gid) { - H5G_t * grp = NULL; /* Pointer to group */ + H5G_t *grp = NULL; /* Pointer to group */ htri_t msg_exists = 0; /* Indicate that a header message is present */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ htri_t ret_value = TRUE; /* Return value */ @@ -406,10 +405,10 @@ H5G__is_new_dense_test(hid_t gid) herr_t H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) { - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ H5O_linfo_t linfo; /* Link info message */ - H5G_t * grp = NULL; /* Pointer to group */ + H5G_t *grp = NULL; /* Pointer to group */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ @@ -497,7 +496,7 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) herr_t H5G__lheap_size_test(hid_t gid, size_t *lheap_size) { - H5G_t * grp = NULL; /* Pointer to group */ + H5G_t *grp = NULL; /* Pointer to group */ H5O_stab_t stab; /* Symbol table message */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ @@ -553,7 +552,7 @@ H5G__lheap_size_test(hid_t gid, size_t *lheap_size) herr_t H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *obj_hidden) { - void * obj_ptr; /* Pointer to object for ID */ + void *obj_ptr; /* Pointer to object for ID */ H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ @@ -658,7 +657,7 @@ herr_t H5G__verify_cached_stab_test(H5O_loc_t *grp_oloc, H5G_entry_t *ent) { H5O_stab_t stab; /* Symbol table */ - H5HL_t * heap = NULL; /* Pointer to local heap */ + H5HL_t *heap = NULL; /* Pointer to local heap */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(grp_oloc->addr) @@ -714,7 +713,7 @@ H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, h { H5G_node_t *sn = NULL; H5O_loc_t targ_oloc; - H5O_t * targ_oh = NULL; + H5O_t *targ_oh = NULL; htri_t stab_exists; H5O_stab_t stab; unsigned i; @@ -805,7 +804,7 @@ H5G__verify_cached_stabs_test_cb(H5F_t *f, const void H5_ATTR_UNUSED *_lt_key, h herr_t H5G__verify_cached_stabs_test(hid_t gid) { - H5G_t * grp = NULL; /* Group */ + H5G_t *grp = NULL; /* Group */ htri_t stab_exists; H5O_stab_t stab; /* Symbol table message */ H5G_bt_common_t udata = {NULL, NULL}; /* Dummy udata so H5B_iterate doesn't freak out */ diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 6b2ae7d61ba..1083cfd9668 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -159,7 +158,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc /*in,out*/, const H5O_link_t *lnk, H5G H5G_name_t grp_path_copy; H5O_loc_t grp_oloc_copy; H5G_loc_t new_loc; /* Group location for newly opened external object */ - H5G_t * grp; + H5G_t *grp; hid_t cur_grp = (-1); herr_t ret_value = SUCCEED; /* Return value */ @@ -191,7 +190,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc /*in,out*/, const H5O_link_t *lnk, H5G /* User-defined callback function */ #ifndef H5_NO_DEPRECATED_SYMBOLS - /* (Backwardly compatible with v0 H5L_class_t traverssal callback) */ + /* (Backward-compatible with v0 H5L_class_t traversal callback) */ if (link_class->version == H5L_LINK_CLASS_T_VERS_0) cb_return = (((const H5L_class_0_t *)link_class)->trav_func)(lnk->name, cur_grp, lnk->u.ud.udata, lnk->u.ud.size, H5CX_get_lapl()); @@ -470,8 +469,8 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5G H5G_own_loc_t own_loc = H5G_OWN_NONE; /* Enum to indicate whether callback took ownership of locations*/ hbool_t group_copy = FALSE; /* Flag to indicate that the group entry is copied */ char comp_buf[1024]; /* Temporary buffer for path components */ - char * comp; /* Pointer to buffer for path components */ - H5WB_t * wb = NULL; /* Wrapped buffer for temporary buffer */ + char *comp; /* Pointer to buffer for path components */ + H5WB_t *wb = NULL; /* Wrapped buffer for temporary buffer */ hbool_t last_comp = FALSE; /* Flag to indicate that a component is the last component in the name */ herr_t ret_value = SUCCEED; /* Return value */ @@ -592,7 +591,7 @@ H5G__traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, H5G /* Check for last component in name provided */ if (last_comp) { H5O_link_t *cb_lnk; /* Pointer to link info for callback */ - H5G_loc_t * cb_loc; /* Pointer to object location for callback */ + H5G_loc_t *cb_loc; /* Pointer to object location for callback */ /* Set callback parameters appropriately, based on link being found */ if (lookup_status) { diff --git a/src/H5HF.c b/src/H5HF.c index 73281a4e31b..93fa2abc177 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -139,10 +138,10 @@ H5HF__op_write(const void *obj, size_t obj_len, void *op_data) H5HF_t * H5HF_create(H5F_t *f, const H5HF_create_t *cparam) { - H5HF_t * fh = NULL; /* Pointer to new fractal heap */ + H5HF_t *fh = NULL; /* Pointer to new fractal heap */ H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ haddr_t fh_addr; /* Heap header address */ - H5HF_t * ret_value = NULL; /* Return value */ + H5HF_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -205,9 +204,9 @@ H5HF_create(H5F_t *f, const H5HF_create_t *cparam) H5HF_t * H5HF_open(H5F_t *f, haddr_t fh_addr) { - H5HF_t * fh = NULL; /* Pointer to new fractal heap */ + H5HF_t *fh = NULL; /* Pointer to new fractal heap */ H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - H5HF_t * ret_value = NULL; /* Return value */ + H5HF_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index 353d7d7c1bf..19e1364eb6b 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -61,7 +60,7 @@ typedef struct H5HF_huge_bt2_ctx_t { /* v2 B-tree driver callbacks */ /* Common callbacks */ -static void * H5HF__huge_bt2_crt_context(void *udata); +static void *H5HF__huge_bt2_crt_context(void *udata); static herr_t H5HF__huge_bt2_dst_context(void *ctx); /* Callbacks for indirect objects */ @@ -188,9 +187,9 @@ H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t); static void * H5HF__huge_bt2_crt_context(void *_f) { - H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -365,7 +364,7 @@ H5HF__huge_bt2_indir_compare(const void *_rec1, const void *_rec2, int *result) static herr_t H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -397,7 +396,7 @@ H5HF__huge_bt2_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) static herr_t H5HF__huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_indir_rec_t *nrecord = (H5HF_huge_bt2_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -563,7 +562,7 @@ H5HF__huge_bt2_filt_indir_compare(const void *_rec1, const void *_rec2, int *res static herr_t H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -597,7 +596,7 @@ H5HF__huge_bt2_filt_indir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) static herr_t H5HF__huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_filt_indir_rec_t *nrecord = (H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -752,7 +751,7 @@ H5HF__huge_bt2_dir_compare(const void *_rec1, const void *_rec2, int *result) static herr_t H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -783,7 +782,7 @@ H5HF__huge_bt2_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) static herr_t H5HF__huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_dir_rec_t *nrecord = (H5HF_huge_bt2_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -959,7 +958,7 @@ H5HF__huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2, int *resul static herr_t H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR @@ -992,7 +991,7 @@ H5HF__huge_bt2_filt_dir_encode(uint8_t *raw, const void *_nrecord, void *_ctx) static herr_t H5HF__huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { - H5HF_huge_bt2_ctx_t * ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5HF_huge_bt2_ctx_t *ctx = (H5HF_huge_bt2_ctx_t *)_ctx; /* Callback context structure */ H5HF_huge_bt2_filt_dir_rec_t *nrecord = (H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5HFcache.c b/src/H5HFcache.c index fde5a4f27ba..9dbf52790ae 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -71,7 +70,7 @@ static herr_t H5HF__cache_hdr_get_initial_load_size(void *udata, size_t *image_l static herr_t H5HF__cache_hdr_get_final_load_size(const void *image_ptr, size_t image_len, void *udata, size_t *actual_len); static htri_t H5HF__cache_hdr_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5HF__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5HF__cache_hdr_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HF__cache_hdr_image_len(const void *thing, size_t *image_len); static herr_t H5HF__cache_hdr_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); @@ -80,7 +79,7 @@ static herr_t H5HF__cache_hdr_free_icr(void *thing); static herr_t H5HF__cache_iblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5HF__cache_iblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5HF__cache_iblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5HF__cache_iblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HF__cache_iblock_image_len(const void *thing, size_t *image_len); static herr_t H5HF__cache_iblock_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); @@ -90,7 +89,7 @@ static herr_t H5HF__cache_iblock_free_icr(void *thing); static herr_t H5HF__cache_dblock_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5HF__cache_dblock_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5HF__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5HF__cache_dblock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HF__cache_dblock_image_len(const void *thing, size_t *image_len); static herr_t H5HF__cache_dblock_pre_serialize(H5F_t *f, void *thing, haddr_t addr, size_t len, haddr_t *new_addr, size_t *new_len, unsigned *flags); @@ -385,7 +384,7 @@ H5HF__cache_hdr_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UN size_t *actual_len) { H5HF_hdr_t hdr; /* Temporary fractal heap header */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into into supplied image */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into into supplied image */ H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -466,12 +465,12 @@ H5HF__cache_hdr_verify_chksum(const void *_image, size_t len, void H5_ATTR_UNUSE static void * H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5HF_hdr_t * hdr = NULL; /* Fractal heap info */ + H5HF_hdr_t *hdr = NULL; /* Fractal heap info */ H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into into supplied image */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into into supplied image */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint8_t heap_flags; /* Status flags for heap */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -726,7 +725,7 @@ static herr_t H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5HF_hdr_t *hdr = (H5HF_hdr_t *)_thing; /* Fractal heap info */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint8_t heap_flags; /* Status flags for heap */ uint32_t metadata_chksum; /* Computed metadata checksum value */ herr_t ret_value = SUCCEED; /* Return value */ @@ -796,7 +795,7 @@ H5HF__cache_hdr_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UN /* Encode I/O filter information */ if (H5O_msg_encode(hdr->f, H5O_PLINE_ID, FALSE, image, &(hdr->pline)) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, FAIL, "can't encode I/O pipeline fiters") + HGOTO_ERROR(H5E_HEAP, H5E_CANTENCODE, FAIL, "can't encode I/O pipeline filters") image += hdr->filter_len; } /* end if */ @@ -895,7 +894,7 @@ H5HF__cache_iblock_get_initial_load_size(void *_udata, size_t *image_len) * Function: H5HF__cache_iblock_verify_chksum * * Purpose: Verify the computed checksum of the data structure is the - * same as the stored chksum. + * same as the stored checksum. * * Return: Success: TRUE/FALSE * Failure: Negative @@ -950,14 +949,14 @@ static void * H5HF__cache_iblock_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_hdr_t *hdr; /* Shared fractal heap information */ H5HF_iblock_cache_ud_t *udata = (H5HF_iblock_cache_ud_t *)_udata; /* User data for callback */ - H5HF_indirect_t * iblock = NULL; /* Indirect block info */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + H5HF_indirect_t *iblock = NULL; /* Indirect block info */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ haddr_t heap_addr; /* Address of heap header in the file */ uint32_t stored_chksum; /* Stored metadata checksum value */ unsigned u; /* Local index variable */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1177,7 +1176,7 @@ static herr_t H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5_ATTR_UNUSED len, haddr_t *new_addr, size_t H5_ATTR_UNUSED *new_len, unsigned *flags) { - H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_hdr_t *hdr; /* Shared fractal heap information */ H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1298,9 +1297,9 @@ H5HF__cache_iblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t H5 static herr_t H5HF__cache_iblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_hdr_t *hdr; /* Shared fractal heap information */ H5HF_indirect_t *iblock = (H5HF_indirect_t *)_thing; /* Indirect block info */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ #ifndef NDEBUG unsigned nchildren = 0; /* Track # of children */ size_t max_child = 0; /* Track max. child entry used */ @@ -1554,8 +1553,8 @@ static herr_t H5HF__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) { const H5HF_dblock_cache_ud_t *udata = (const H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ - const H5HF_parent_t * par_info; /* Pointer to parent information */ - const H5HF_hdr_t * hdr; /* Shared fractal heap information */ + const H5HF_parent_t *par_info; /* Pointer to parent information */ + const H5HF_hdr_t *hdr; /* Shared fractal heap information */ FUNC_ENTER_STATIC_NOERR @@ -1601,15 +1600,15 @@ H5HF__cache_dblock_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ H5HF_dblock_cache_ud_t *udata = (H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ - void * read_buf = NULL; /* Pointer to buffer to read in */ - H5HF_hdr_t * hdr; /* Shared fractal heap information */ - H5HF_parent_t * par_info; /* Pointer to parent information */ + void *read_buf = NULL; /* Pointer to buffer to read in */ + H5HF_hdr_t *hdr; /* Shared fractal heap information */ + H5HF_parent_t *par_info; /* Pointer to parent information */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ size_t chk_size; /* The size for validating checksum */ - uint8_t * chk_p; /* Pointer to the area for validating checksum */ + uint8_t *chk_p; /* Pointer to the area for validating checksum */ htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_STATIC @@ -1727,14 +1726,14 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata) static void * H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5HF_hdr_t * hdr; /* Shared fractal heap information */ + H5HF_hdr_t *hdr; /* Shared fractal heap information */ H5HF_dblock_cache_ud_t *udata = (H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */ - H5HF_parent_t * par_info; /* Pointer to parent information */ - H5HF_direct_t * dblock = NULL; /* Direct block info */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - void * read_buf = NULL; /* Pointer to buffer to decompress */ + H5HF_parent_t *par_info; /* Pointer to parent information */ + H5HF_direct_t *dblock = NULL; /* Direct block info */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + void *read_buf = NULL; /* Pointer to buffer to decompress */ haddr_t heap_addr; /* Address of heap header in the file */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1909,7 +1908,7 @@ static herr_t H5HF__cache_dblock_image_len(const void *_thing, size_t *image_len) { const H5HF_direct_t *dblock = (const H5HF_direct_t *)_thing; /* Direct block info */ - const H5HF_hdr_t * hdr; /* Shared fractal heap information */ + const H5HF_hdr_t *hdr; /* Shared fractal heap information */ size_t size; FUNC_ENTER_STATIC_NOERR @@ -2044,13 +2043,13 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, void *_thing, haddr_t addr, size_t le hbool_t at_tmp_addr; /* Flag to indicate direct block is */ /* at temporary address */ haddr_t dblock_addr; - H5HF_hdr_t * hdr; /* Shared fractal heap information */ - H5HF_direct_t * dblock = (H5HF_direct_t *)_thing; /* Direct block info */ + H5HF_hdr_t *hdr; /* Shared fractal heap information */ + H5HF_direct_t *dblock = (H5HF_direct_t *)_thing; /* Direct block info */ H5HF_indirect_t *par_iblock; /* Parent indirect block */ unsigned par_entry = 0; /* Entry in parent indirect block */ - void * write_buf; /* Pointer to buffer to write out */ + void *write_buf; /* Pointer to buffer to write out */ size_t write_size; /* Size of buffer to write out */ - uint8_t * image; /* Pointer into raw data buffer */ + uint8_t *image; /* Pointer into raw data buffer */ unsigned dblock_flags = 0; herr_t ret_value = SUCCEED; /* Return value */ @@ -2622,7 +2621,7 @@ H5HF__cache_dblock_fsf_size(const void *_thing, hsize_t *fsf_size) * Further, metadata cache entries are now allowed to have * multiple flush dependency parents. * - * This means that the fractal heap is no longer ncessarily + * This means that the fractal heap is no longer necessarily * flushed from the bottom up. * * For example, it is now possible for a dirty fractal heap @@ -2987,7 +2986,7 @@ H5HF__cache_verify_hdr_descendants_clean(H5F_t *f, H5HF_hdr_t *hdr, hbool_t *fd_ * Further, metadata cache entries are now allowed to have * multiple flush dependency parents. * - * This means that the fractal heap is no longer ncessarily + * This means that the fractal heap is no longer necessarily * flushed from the bottom up. * * For example, it is now possible for a dirty fractal heap @@ -3104,7 +3103,7 @@ H5HF__cache_verify_iblock_descendants_clean(H5F_t *f, haddr_t fd_parent_addr, H5 * Further, metadata cache entries are now allowed to have * multiple flush dependency parents. * - * This means that the fractal heap is no longer ncessarily + * This means that the fractal heap is no longer necessarily * flushed from the bottom up. * * For example, it is now possible for a dirty fractal heap @@ -3267,7 +3266,7 @@ H5HF__cache_verify_iblocks_dblocks_clean(H5F_t *f, haddr_t fd_parent_addr, H5HF_ * Further, metadata cache entries are now allowed to have * multiple flush dependency parents. * - * This means that the fractal heap is no longer ncessarily + * This means that the fractal heap is no longer necessarily * flushed from the bottom up. * * For example, it is now possible for a dirty fractal heap diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index a2440357d0e..7259d2176f2 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -49,8 +48,8 @@ /* User data for direct block debugging iterator callback */ typedef struct { - FILE * stream; /* Stream for output */ - int indent; /* Indention amount */ + FILE *stream; /* Stream for output */ + int indent; /* Indentation amount */ int fwidth; /* Field width mount */ haddr_t dblock_addr; /* Direct block's address */ hsize_t dblock_size; /* Direct block's size */ @@ -62,8 +61,8 @@ typedef struct { /* User data for free space section iterator callback */ typedef struct { H5FS_t *fspace; /* Free space manager */ - FILE * stream; /* Stream for output */ - int indent; /* Indention amount */ + FILE *stream; /* Stream for output */ + int indent; /* Indentation amount */ int fwidth; /* Field width mount */ } H5HF_debug_iter_ud2_t; @@ -373,7 +372,7 @@ H5HF_hdr_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) static herr_t H5HF_dblock_debug_cb(H5FS_section_info_t *_sect, void *_udata) { - H5HF_free_section_t * sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ + H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ H5HF_debug_iter_ud1_t *udata = (H5HF_debug_iter_ud1_t *)_udata; /* User data for callbacks */ haddr_t sect_start, sect_end; /* Section's beginning and ending offsets */ haddr_t dblock_start, dblock_end; /* Direct block's beginning and ending offsets */ @@ -456,11 +455,11 @@ herr_t H5HF_dblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t hdr_addr, size_t block_size) { - H5HF_hdr_t * hdr = NULL; /* Fractal heap header info */ + H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ H5HF_direct_t *dblock = NULL; /* Fractal heap direct block info */ size_t blk_prefix_size; /* Size of prefix for block */ size_t amount_free; /* Amount of free space in block */ - uint8_t * marker = NULL; /* Track free space for block */ + uint8_t *marker = NULL; /* Track free space for block */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -690,7 +689,7 @@ herr_t H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, haddr_t hdr_addr, unsigned nrows) { - H5HF_hdr_t * hdr = NULL; /* Fractal heap header info */ + H5HF_hdr_t *hdr = NULL; /* Fractal heap header info */ H5HF_indirect_t *iblock = NULL; /* Fractal heap direct block info */ hbool_t did_protect = FALSE; /* Whether we protected the indirect block or not */ herr_t ret_value = SUCCEED; /* Return value */ @@ -746,7 +745,7 @@ H5HF_iblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, static herr_t H5HF_sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) { - H5HF_free_section_t * sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ + H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ H5HF_debug_iter_ud2_t *udata = (H5HF_debug_iter_ud2_t *)_udata; /* User data for callbacks */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index 628dcc426b7..e8b2cb40723 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -86,7 +85,7 @@ H5HF__man_dblock_create(H5HF_hdr_t *hdr, H5HF_indirect_t *par_iblock, unsigned p H5HF_free_section_t **ret_sec_node) { H5HF_free_section_t *sec_node; /* Pointer to free space section for block */ - H5HF_direct_t * dblock = NULL; /* Pointer to direct block */ + H5HF_direct_t *dblock = NULL; /* Pointer to direct block */ haddr_t dblock_addr; /* Direct block's address */ size_t free_space; /* Free space in new block */ herr_t ret_value = SUCCEED; /* Return value */ @@ -431,9 +430,9 @@ H5HF_direct_t * H5HF__man_dblock_protect(H5HF_hdr_t *hdr, haddr_t dblock_addr, size_t dblock_size, H5HF_indirect_t *par_iblock, unsigned par_entry, unsigned flags) { - H5HF_direct_t * dblock; /* Direct block from cache */ - H5HF_dblock_cache_ud_t udata; /* parent and other infor for deserializing direct block */ - H5HF_direct_t * ret_value = NULL; /* Return value */ + H5HF_direct_t *dblock; /* Direct block from cache */ + H5HF_dblock_cache_ud_t udata; /* parent and other info for deserializing direct block */ + H5HF_direct_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5HFdtable.c b/src/H5HFdtable.c index 5a1f9503a5b..9b971beb445 100644 --- a/src/H5HFdtable.c +++ b/src/H5HFdtable.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index cd5ba2304e9..1d243aaae02 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -515,8 +514,8 @@ H5HF_hdr_t * H5HF__hdr_protect(H5F_t *f, haddr_t addr, unsigned flags) { H5HF_hdr_cache_ud_t cache_udata; /* User-data for callback */ - H5HF_hdr_t * hdr; /* Fractal heap header */ - H5HF_hdr_t * ret_value = NULL; /* Return value */ + H5HF_hdr_t *hdr; /* Fractal heap header */ + H5HF_hdr_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index b1043a6c1a3..ca6387ff164 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -291,7 +290,7 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) { uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ haddr_t obj_addr; /* Address of object in the file */ - void * write_buf; /* Pointer to buffer to write */ + void *write_buf; /* Pointer to buffer to write */ size_t write_size; /* Size of [possibly filtered] object written to file */ unsigned filter_mask = 0; /* Filter mask for object (only used for filtered objects) */ herr_t ret_value = SUCCEED; /* Return value */ @@ -411,7 +410,7 @@ H5HF__huge_insert(H5HF_hdr_t *hdr, size_t obj_size, void *obj, void *_id) else { H5HF_huge_bt2_filt_indir_rec_t filt_indir_rec; /* Record for tracking filtered object */ H5HF_huge_bt2_indir_rec_t indir_rec; /* Record for tracking non-filtered object */ - void * ins_rec; /* Pointer to record to insert */ + void *ins_rec; /* Pointer to record to insert */ hsize_t new_id; /* New ID for object */ /* Get new ID for object */ @@ -650,7 +649,7 @@ H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) static herr_t H5HF__huge_op_real(H5HF_hdr_t *hdr, const uint8_t *id, hbool_t is_read, H5HF_operator_t op, void *op_data) { - void * read_buf = NULL; /* Pointer to buffer for reading */ + void *read_buf = NULL; /* Pointer to buffer for reading */ haddr_t obj_addr; /* Object's address in the file */ size_t obj_size = 0; /* Object's size in the file */ unsigned filter_mask = 0; /* Filter mask for object (only used for filtered objects) */ diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 9b69ec116f1..b4a48112d60 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -803,7 +802,7 @@ H5HF__man_iblock_root_halve(H5HF_indirect_t *iblock) static herr_t H5HF__man_iblock_root_revert(H5HF_indirect_t *root_iblock) { - H5HF_hdr_t * hdr; /* Pointer to heap's header */ + H5HF_hdr_t *hdr; /* Pointer to heap's header */ H5HF_direct_t *dblock = NULL; /* Pointer to new root indirect block */ haddr_t dblock_addr; /* Direct block's address in the file */ size_t dblock_size; /* Direct block's size */ @@ -893,7 +892,7 @@ H5HF__man_iblock_root_revert(H5HF_indirect_t *root_iblock) herr_t H5HF__man_iblock_alloc_row(H5HF_hdr_t *hdr, H5HF_free_section_t **sec_node) { - H5HF_indirect_t * iblock = NULL; /* Pointer to indirect block */ + H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ H5HF_free_section_t *old_sec_node = *sec_node; /* Pointer to old indirect section node */ unsigned dblock_entry; /* Entry for direct block */ hbool_t iblock_held = FALSE; /* Flag to indicate that indirect block is held */ @@ -1349,7 +1348,7 @@ H5HF__man_iblock_attach(H5HF_indirect_t *iblock, unsigned entry, haddr_t child_a herr_t H5HF__man_iblock_detach(H5HF_indirect_t *iblock, unsigned entry) { - H5HF_hdr_t * hdr; /* Fractal heap header */ + H5HF_hdr_t *hdr; /* Fractal heap header */ H5HF_indirect_t *del_iblock = NULL; /* Pointer to protected indirect block, when deleting */ unsigned row; /* Row for entry */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5HFiter.c b/src/H5HFiter.c index 673c54398c4..6d4097989ce 100644 --- a/src/H5HFiter.c +++ b/src/H5HFiter.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5HFman.c b/src/H5HFman.c index 427be0026a7..d2782ec48a8 100644 --- a/src/H5HFman.c +++ b/src/H5HFman.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -97,10 +96,10 @@ herr_t H5HF__man_insert(H5HF_hdr_t *hdr, size_t obj_size, const void *obj, void *_id) { H5HF_free_section_t *sec_node = NULL; /* Pointer to free space section */ - H5HF_direct_t * dblock = NULL; /* Pointer to direct block to modify */ + H5HF_direct_t *dblock = NULL; /* Pointer to direct block to modify */ haddr_t dblock_addr = HADDR_UNDEF; /* Direct block address */ size_t dblock_size; /* Direct block size */ - uint8_t * id = (uint8_t *)_id; /* Pointer to ID buffer */ + uint8_t *id = (uint8_t *)_id; /* Pointer to ID buffer */ size_t blk_off; /* Offset of object within block */ htri_t node_found; /* Whether an existing free list node was found */ herr_t ret_value = SUCCEED; /* Return value */ @@ -546,7 +545,7 @@ herr_t H5HF__man_remove(H5HF_hdr_t *hdr, const uint8_t *id) { H5HF_free_section_t *sec_node = NULL; /* Pointer to free space section for block */ - H5HF_indirect_t * iblock = NULL; /* Pointer to indirect block */ + H5HF_indirect_t *iblock = NULL; /* Pointer to indirect block */ hbool_t did_protect = FALSE; /* Whether we protected the indirect block or not */ hsize_t obj_off; /* Object's offset in heap */ size_t obj_len; /* Object's length in heap */ diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 893a65d4f15..d961d7a8f6d 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -231,7 +230,7 @@ typedef struct H5HF_block_loc_t { unsigned entry; /* Entry of block in doubling table */ /* Infrastructure */ - H5HF_indirect_t * context; /* Pointer to the indirect block containing the block */ + H5HF_indirect_t *context; /* Pointer to the indirect block containing the block */ struct H5HF_block_loc_t *up; /* Pointer to next level up in the stack of levels */ } H5HF_block_loc_t; @@ -340,16 +339,16 @@ struct H5HF_hdr_t { haddr_t heap_addr; /* Address of heap header in the file */ size_t heap_size; /* Size of heap header in the file */ unsigned mode; /* Access mode for heap */ - H5F_t * f; /* Pointer to file for heap */ + H5F_t *f; /* Pointer to file for heap */ size_t file_rc; /* Reference count of files using heap header */ hbool_t pending_delete; /* Heap is pending deletion */ uint8_t sizeof_size; /* Size of file sizes */ uint8_t sizeof_addr; /* Size of file addresses */ struct H5HF_indirect_t *root_iblock; /* Pointer to root indirect block */ unsigned root_iblock_flags; /* Flags to indicate whether root indirect block is pinned/protected */ - H5FS_t * fspace; /* Free space list for objects in heap */ + H5FS_t *fspace; /* Free space list for objects in heap */ H5HF_block_iter_t next_block; /* Block iterator for searching for next block with space */ - H5B2_t * huge_bt2; /* v2 B-tree handle for huge objects */ + H5B2_t *huge_bt2; /* v2 B-tree handle for huge objects */ hsize_t huge_max_id; /* Max. 'huge' heap ID before rolling 'huge' heap IDs over */ uint8_t huge_id_size; /* Size of 'huge' heap IDs (in bytes) */ hbool_t huge_ids_direct; /* Flag to indicate that 'huge' object's offset & length are stored directly in @@ -382,9 +381,9 @@ struct H5HF_indirect_t { /* Internal heap information (not stored) */ size_t rc; /* Reference count of objects using this block */ - H5HF_hdr_t * hdr; /* Shared heap header info */ + H5HF_hdr_t *hdr; /* Shared heap header info */ struct H5HF_indirect_t *parent; /* Shared parent indirect block info */ - void * fd_parent; /* Saved copy of the parent pointer -- this */ + void *fd_parent; /* Saved copy of the parent pointer -- this */ /* necessary as the parent field is sometimes */ /* nulled out before the eviction notify call */ /* is made from the metadata cache. Since */ @@ -405,7 +404,7 @@ struct H5HF_indirect_t { /* Stored values */ hsize_t block_off; /* Offset of the block within the heap's address space */ - H5HF_indirect_ent_t * ents; /* Pointer to block entry table */ + H5HF_indirect_ent_t *ents; /* Pointer to block entry table */ H5HF_indirect_filt_ent_t *filt_ents; /* Pointer to filtered information for direct blocks */ }; @@ -415,9 +414,9 @@ typedef struct H5HF_direct_t { H5AC_info_t cache_info; /* Internal heap information */ - H5HF_hdr_t * hdr; /* Shared heap header info */ + H5HF_hdr_t *hdr; /* Shared heap header info */ H5HF_indirect_t *parent; /* Shared parent indirect block info */ - void * fd_parent; /* Saved copy of the parent pointer -- this */ + void *fd_parent; /* Saved copy of the parent pointer -- this */ /* necessary as the parent field is sometimes */ /* nulled out before the eviction notify call */ /* is made from the metadata cache. Since */ @@ -460,12 +459,12 @@ typedef struct H5HF_direct_t { /* Fractal heap */ struct H5HF_t { H5HF_hdr_t *hdr; /* Pointer to internal fractal heap header info */ - H5F_t * f; /* Pointer to file for heap */ + H5F_t *f; /* Pointer to file for heap */ }; /* Fractal heap "parent info" (for loading a block) */ typedef struct H5HF_parent_t { - H5HF_hdr_t * hdr; /* Pointer to heap header info */ + H5HF_hdr_t *hdr; /* Pointer to heap header info */ H5HF_indirect_t *iblock; /* Pointer to parent indirect block */ unsigned entry; /* Location of block in parent's entry table */ } H5HF_parent_t; @@ -518,15 +517,15 @@ typedef struct H5HF_hdr_cache_ud_t { /* User data for fractal heap indirect block cache client callbacks */ typedef struct H5HF_iblock_cache_ud_t { - H5HF_parent_t * par_info; /* Parent info */ - H5F_t * f; /* File pointer */ + H5HF_parent_t *par_info; /* Parent info */ + H5F_t *f; /* File pointer */ const unsigned *nrows; /* Number of rows */ } H5HF_iblock_cache_ud_t; /* User data for fractal heap direct block cache client callbacks */ typedef struct H5HF_dblock_cache_ud_t { H5HF_parent_t par_info; /* Parent info */ - H5F_t * f; /* File pointer */ + H5F_t *f; /* File pointer */ size_t odi_size; /* On disk image size of the direct block. * Note that there is no necessary relation * between this value, and the actual @@ -752,7 +751,7 @@ H5_DLL herr_t H5HF__sect_single_dblock_info(H5HF_hdr_t *hdr, const haddr_t *dblock_addr, size_t *dblock_size); H5_DLL herr_t H5HF__sect_single_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, size_t amt); H5_DLL herr_t H5HF__sect_row_revive(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); -H5_DLL herr_t H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned *entry_p); +H5_DLL herr_t H5HF__sect_row_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned *entry_p); H5_DLL H5HF_indirect_t *H5HF__sect_row_get_iblock(H5HF_free_section_t *sect); H5_DLL herr_t H5HF__sect_indirect_add(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, unsigned start_entry, unsigned nentries); diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h index 3263b4efa70..cba1c58853a 100644 --- a/src/H5HFprivate.h +++ b/src/H5HFprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5HFsection.c b/src/H5HFsection.c index eec41a48ad0..6fed159312a 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -131,7 +130,7 @@ static herr_t H5HF__sect_indirect_reduce_row(H5HF_hdr_t *hdr, H5HF static herr_t H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned child_entry); static herr_t H5HF__sect_indirect_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect); static hbool_t H5HF__sect_indirect_is_first(H5HF_free_section_t *sect); -static H5HF_indirect_t * H5HF__sect_indirect_get_iblock(H5HF_free_section_t *sect); +static H5HF_indirect_t *H5HF__sect_indirect_get_iblock(H5HF_free_section_t *sect); static hsize_t H5HF__sect_indirect_iblock_off(const H5HF_free_section_t *sect); static H5HF_free_section_t *H5HF__sect_indirect_top(H5HF_free_section_t *sect); static herr_t H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *sect1, @@ -783,8 +782,8 @@ H5HF__sect_single_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata */ if (!(*flags & H5FS_ADD_DESERIALIZING)) { H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ - H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ /* Sanity check */ HDassert(sect); @@ -910,9 +909,9 @@ static herr_t H5HF__sect_single_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { H5HF_free_section_t **sect1 = (H5HF_free_section_t **)_sect1; /* Fractal heap free section */ - H5HF_free_section_t * sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ - H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ + H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -967,8 +966,8 @@ static htri_t H5HF__sect_single_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Fractal heap free section */ - H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1021,9 +1020,9 @@ static herr_t H5HF__sect_single_shrink(H5FS_section_info_t **_sect, void *_udata) { H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ - H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ - H5HF_direct_t * dblock; /* Pointer to direct block for section */ + H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ + H5HF_direct_t *dblock; /* Pointer to direct block for section */ haddr_t dblock_addr; /* Section's direct block's address */ size_t dblock_size; /* Section's direct block's size */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1086,7 +1085,7 @@ herr_t H5HF__sect_single_free(H5FS_section_info_t *_sect) { H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Pointer to section to free */ - H5HF_indirect_t * parent = NULL; /* Parent indirect block for section */ + H5HF_indirect_t *parent = NULL; /* Parent indirect block for section */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -1135,7 +1134,7 @@ H5HF__sect_single_valid(const H5FS_section_class_t H5_ATTR_UNUSED *cls, const H5 /* Check if this section is not in a direct block that is the root direct block */ /* (not enough information to check on a single section in a root direct block) */ if (sect->u.single.parent != NULL) { - H5HF_indirect_t * iblock; /* Indirect block that section's direct block resides in */ + H5HF_indirect_t *iblock; /* Indirect block that section's direct block resides in */ haddr_t dblock_addr; /* Direct block address */ size_t dblock_size; /* Direct block size */ unsigned dblock_status = 0; /* Direct block's status in the metadata cache */ @@ -1441,7 +1440,7 @@ H5HF__sect_row_first(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) else /* Change row section to be the "first row" */ if (H5HF__space_sect_change_class(hdr, sect, H5HF_FSPACE_SECT_FIRST_ROW) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set row section to be first row") + HGOTO_ERROR(H5E_HEAP, H5E_CANTSET, FAIL, "can't set row section to be first row") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1625,7 +1624,7 @@ H5HF__sect_row_term_cls(H5FS_section_class_t *cls) static herr_t H5HF__sect_row_serialize(const H5FS_section_class_t *cls, const H5FS_section_info_t *_sect, uint8_t *buf) { - H5HF_hdr_t * hdr; /* Fractal heap header */ + H5HF_hdr_t *hdr; /* Fractal heap header */ const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; herr_t ret_value = SUCCEED; /* Return value */ @@ -1669,7 +1668,7 @@ static H5FS_section_info_t * H5HF__sect_row_deserialize(const H5FS_section_class_t *cls, const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags) { - H5HF_hdr_t * hdr; /* Fractal heap header */ + H5HF_hdr_t *hdr; /* Fractal heap header */ H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1712,7 +1711,7 @@ H5HF__sect_row_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section_i { const H5HF_free_section_t *sect1 = (const H5HF_free_section_t *)_sect1; /* Fractal heap free section */ const H5HF_free_section_t *sect2 = (const H5HF_free_section_t *)_sect2; /* Fractal heap free section */ - H5HF_free_section_t * top_indir_sect1, *top_indir_sect2; /* Top indirect section for each row */ + H5HF_free_section_t *top_indir_sect1, *top_indir_sect2; /* Top indirect section for each row */ htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1766,9 +1765,9 @@ static herr_t H5HF__sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { H5HF_free_section_t **sect1 = (H5HF_free_section_t **)_sect1; /* Fractal heap free section */ - H5HF_free_section_t * sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ - H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2; /* Fractal heap free section */ + H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1793,7 +1792,7 @@ H5HF__sect_row_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, else /* Merge rows' underlying indirect sections together */ if (H5HF__sect_indirect_merge_row(hdr, (*sect1), sect2) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTMERGE, FAIL, "can't merge underlying indirect sections") + HGOTO_ERROR(H5E_HEAP, H5E_CANTMERGE, FAIL, "can't merge underlying indirect sections") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1821,8 +1820,8 @@ static htri_t H5HF__sect_row_can_shrink(const H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udata) { const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Fractal heap free section */ - H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1857,9 +1856,9 @@ static herr_t H5HF__sect_row_shrink(H5FS_section_info_t **_sect, void *_udata) { H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect; /* Fractal heap free section */ - H5HF_free_section_t * top_indir_sect; /* Top indirect section for row */ - H5HF_sect_add_ud_t * udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ - H5HF_hdr_t * hdr = udata->hdr; /* Fractal heap header */ + H5HF_free_section_t *top_indir_sect; /* Top indirect section for row */ + H5HF_sect_add_ud_t *udata = (H5HF_sect_add_ud_t *)_udata; /* User callback data */ + H5HF_hdr_t *hdr = udata->hdr; /* Fractal heap header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1967,8 +1966,8 @@ H5HF__sect_row_free(H5FS_section_info_t *_sect) static herr_t H5HF__sect_row_valid(const H5FS_section_class_t *cls, const H5FS_section_info_t *_sect) { - H5HF_sect_private_t * cls_prvt; /* Pointer to class private info */ - const H5HF_hdr_t * hdr; /* Fractal heap header */ + H5HF_sect_private_t *cls_prvt; /* Pointer to class private info */ + const H5HF_hdr_t *hdr; /* Fractal heap header */ const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect; /* Pointer to section to check */ const H5HF_free_section_t *indir_sect; /* Pointer to underlying indirect section */ unsigned H5_ATTR_NDEBUG_UNUSED indir_idx; /* Index of row in underlying indirect section's row array */ @@ -2292,7 +2291,7 @@ H5HF__sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, H5HF_free_ (sect->u.indirect.dir_rows = (H5HF_free_section_t **)H5MM_malloc(sizeof(H5HF_free_section_t *)))) HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "allocation failed for row section pointer array") - /* Atatch the new row section to indirect section */ + /* Attach the new row section to indirect section */ sect->u.indirect.dir_rows[0] = row_sect; sect->u.indirect.rc = 1; @@ -2447,7 +2446,7 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, hbool_ else /* Add new row section to free space manager for the heap */ if (H5HF__space_add(hdr, row_sect, space_flags) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add row section to free space") + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add row section to free space") /* Increment reference count for underlying indirect section */ sect->u.indirect.rc++; @@ -2463,7 +2462,7 @@ H5HF__sect_indirect_init_rows(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, hbool_ first_row_sect = NULL; } /* end if */ else { - H5HF_indirect_t * child_iblock; /* Child indirect block */ + H5HF_indirect_t *child_iblock; /* Child indirect block */ H5HF_free_section_t *child_sect; /* Child 'indirect' section to add */ unsigned child_nrows; /* Number of child rows in indirect blocks for this row */ unsigned child_nentries; /* Number of child entries in indirect blocks for this row */ @@ -3206,7 +3205,7 @@ H5HF__sect_indirect_reduce(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, unsigned /* (Will use this to compute the section address for the peer section */ sect->u.indirect.num_entries = new_nentries; sect->u.indirect.span_size = H5HF__dtable_span_size(&hdr->man_dtable, sect->u.indirect.row, - sect->u.indirect.col, new_nentries); + sect->u.indirect.col, new_nentries); HDassert(sect->u.indirect.span_size > 0); /* Compute address of peer indirect section */ @@ -3672,7 +3671,7 @@ H5HF__sect_indirect_merge_row(H5HF_hdr_t *hdr, H5HF_free_section_t *row_sect1, H static herr_t H5HF__sect_indirect_build_parent(H5HF_hdr_t *hdr, H5HF_free_section_t *sect) { - H5HF_indirect_t * par_iblock; /* Indirect block for parent section */ + H5HF_indirect_t *par_iblock; /* Indirect block for parent section */ H5HF_free_section_t *par_sect = NULL; /* Parent indirect section */ hsize_t par_block_off; /* Offset of parent's block */ unsigned par_row, par_col; /* Row & column in parent indirect section */ @@ -4059,7 +4058,7 @@ H5HF__sect_indirect_valid(const H5HF_hdr_t *hdr, const H5HF_free_section_t *sect HDassert(tmp_child_sect->u.indirect.parent == sect); if (u > 0) { const H5HF_free_section_t H5_ATTR_NDEBUG_UNUSED - * tmp_child_sect2; /* Pointer to child indirect section */ + *tmp_child_sect2; /* Pointer to child indirect section */ tmp_child_sect2 = sect->u.indirect.indir_ents[u - 1]; HDassert(H5F_addr_lt(tmp_child_sect2->sect_info.addr, tmp_child_sect->sect_info.addr)); diff --git a/src/H5HFspace.c b/src/H5HFspace.c index d62267cd0e4..24cbb6441fd 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -320,7 +319,7 @@ static herr_t H5HF__space_create_root_cb(H5FS_section_info_t *_sect, void *_udata) { H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect; /* Section to dump info */ - H5HF_indirect_t * root_iblock = (H5HF_indirect_t *)_udata; /* User data for callback */ + H5HF_indirect_t *root_iblock = (H5HF_indirect_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -383,7 +382,7 @@ H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock) /* Only need to scan the sections if the free space has been initialized */ if (hdr->fspace) - /* Iterate over all sections, seting the parent pointers in 'single' sections to the new indirect + /* Iterate over all sections, setting the parent pointers in 'single' sections to the new indirect * block */ if (H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF__space_create_root_cb, root_iblock) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to set parent pointers") diff --git a/src/H5HFstat.c b/src/H5HFstat.c index 5e5d06ad630..79ce15f09cf 100644 --- a/src/H5HFstat.c +++ b/src/H5HFstat.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -116,7 +115,7 @@ herr_t H5HF_size(const H5HF_t *fh, hsize_t *heap_size) { H5HF_hdr_t *hdr; /* Fractal heap header */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ hsize_t meta_size = 0; /* free space storage size */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5HFtest.c b/src/H5HFtest.c index 84734d2a430..14199eeebd2 100644 --- a/src/H5HFtest.c +++ b/src/H5HFtest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c index eca177c1752..544526cd052 100644 --- a/src/H5HFtiny.c +++ b/src/H5HFtiny.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5HG.c b/src/H5HG.c index cae23a77240..b1b20ed5c00 100644 --- a/src/H5HG.c +++ b/src/H5HG.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -127,7 +126,7 @@ static haddr_t H5HG__create(H5F_t *f, size_t size) { H5HG_heap_t *heap = NULL; - uint8_t * p = NULL; + uint8_t *p = NULL; haddr_t addr = HADDR_UNDEF; size_t n; haddr_t ret_value = HADDR_UNDEF; /* Return value */ @@ -410,8 +409,8 @@ H5HG_extend(H5F_t *f, haddr_t addr, size_t need) H5HG_heap_t *heap = NULL; /* Pointer to heap to extend */ unsigned heap_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting heap */ size_t old_size; /* Previous size of the heap's chunk */ - uint8_t * new_chunk; /* Pointer to new chunk information */ - uint8_t * p; /* Pointer to raw heap info */ + uint8_t *new_chunk; /* Pointer to new chunk information */ + uint8_t *p; /* Pointer to raw heap info */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -584,9 +583,9 @@ H5HG_read(H5F_t *f, H5HG_t *hobj, void *object /*out*/, size_t *buf_size) { H5HG_heap_t *heap = NULL; /* Pointer to global heap object */ size_t size; /* Size of the heap object */ - uint8_t * p; /* Pointer to object in heap buffer */ - void * orig_object = object; /* Keep a copy of the original object pointer */ - void * ret_value = NULL; /* Return value */ + uint8_t *p; /* Pointer to object in heap buffer */ + void *orig_object = object; /* Keep a copy of the original object pointer */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, NULL) @@ -751,7 +750,7 @@ herr_t H5HG_remove(H5F_t *f, H5HG_t *hobj) { H5HG_heap_t *heap = NULL; - uint8_t * p = NULL, *obj_start = NULL; + uint8_t *p = NULL, *obj_start = NULL; size_t need; unsigned u; unsigned flags = H5AC__NO_FLAGS_SET; /* Whether the heap gets deleted */ diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 379e6f66c16..7c02d01cfc8 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -58,7 +57,7 @@ static herr_t H5HG__cache_heap_get_initial_load_size(void *udata, size_t *image_len); static herr_t H5HG__cache_heap_get_final_load_size(const void *_image, size_t image_len, void *udata, size_t *actual_len); -static void * H5HG__cache_heap_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5HG__cache_heap_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HG__cache_heap_image_len(const void *thing, size_t *image_len); static herr_t H5HG__cache_heap_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HG__cache_heap_free_icr(void *thing); @@ -231,12 +230,12 @@ H5HG__cache_heap_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UN static void * H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5F_t * f = (H5F_t *)_udata; /* File pointer -- obtained from user data */ + H5F_t *f = (H5F_t *)_udata; /* File pointer -- obtained from user data */ H5HG_heap_t *heap = NULL; /* New global heap */ - uint8_t * image; /* Pointer to image to decode */ + uint8_t *image; /* Pointer to image to decode */ size_t max_idx = 0; /* Maximum heap object index seen */ size_t nalloc; /* Number of objects allocated */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c index 51a74ec4b04..6da4855d07e 100644 --- a/src/H5HGdbg.c +++ b/src/H5HGdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -78,7 +77,7 @@ H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) unsigned u, nused, maxobj; unsigned j, k; H5HG_heap_t *h = NULL; - uint8_t * p = NULL; + uint8_t *p = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h index 5c0fbe8686b..5623e8bc0f4 100644 --- a/src/H5HGpkg.h +++ b/src/H5HGpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -127,13 +126,13 @@ struct H5HG_heap_t { /* have been used at some time and the */ /* correct new index should be searched for */ struct H5F_shared_t *shared; /* shared file */ - H5HG_obj_t * obj; /*array of object descriptions */ + H5HG_obj_t *obj; /*array of object descriptions */ }; /******************************/ /* Package Private Prototypes */ /******************************/ -H5_DLL herr_t H5HG__free(H5HG_heap_t *heap); +H5_DLL herr_t H5HG__free(H5HG_heap_t *heap); H5_DLL H5HG_heap_t *H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags); #endif /* H5HGpkg_H */ diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h index d8e6b4665eb..fae3713fafb 100644 --- a/src/H5HGprivate.h +++ b/src/H5HGprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -50,11 +49,11 @@ 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*/); -H5_DLL void * H5HG_read(H5F_t *f, H5HG_t *hobj, void *object, size_t *buf_size /*out*/); +H5_DLL void *H5HG_read(H5F_t *f, H5HG_t *hobj, void *object, size_t *buf_size /*out*/); H5_DLL int H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust); H5_DLL herr_t H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size); H5_DLL herr_t H5HG_remove(H5F_t *f, H5HG_t *hobj); diff --git a/src/H5HGquery.c b/src/H5HGquery.c index c24a414c43a..9e4c789a68a 100644 --- a/src/H5HGquery.c +++ b/src/H5HGquery.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5HL.c b/src/H5HL.c index ca8344526e4..8a59d0474ec 100644 --- a/src/H5HL.c +++ b/src/H5HL.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -98,11 +97,15 @@ H5FL_BLK_DEFINE(lheap_chunk); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p /*out*/)) - - H5HL_t * heap = NULL; /* Heap created */ +herr_t +H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p /*out*/) +{ + H5HL_t *heap = NULL; /* Heap created */ H5HL_prfx_t *prfx = NULL; /* Heap prefix */ hsize_t total_size = 0; /* Total heap size on disk */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); @@ -115,12 +118,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_h /* Allocate new heap structure */ if (NULL == (heap = H5HL__new(H5F_SIZEOF_SIZE(f), H5F_SIZEOF_ADDR(f), H5HL_SIZEOF_HDR(f)))) - H5E_THROW(H5E_CANTALLOC, "can't allocate new heap struct"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't allocate new heap struct"); /* Allocate file space */ total_size = heap->prfx_size + size_hint; if (HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, total_size))) - H5E_THROW(H5E_CANTALLOC, "unable to allocate file memory"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file memory"); /* Initialize info */ heap->single_cache_obj = TRUE; @@ -128,52 +131,52 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_create(H5F_t *f, size_t size_h heap->dblk_size = size_hint; if (size_hint) if (NULL == (heap->dblk_image = H5FL_BLK_CALLOC(lheap_chunk, size_hint))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* free list */ if (size_hint) { if (NULL == (heap->freelist = H5FL_MALLOC(H5HL_free_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); heap->freelist->offset = 0; heap->freelist->size = size_hint; heap->freelist->prev = heap->freelist->next = NULL; heap->free_block = 0; - } /* end if */ + } else { heap->freelist = NULL; heap->free_block = H5HL_FREE_NULL; - } /* end else */ + } /* Allocate the heap prefix */ if (NULL == (prfx = H5HL__prfx_new(heap))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Add to cache */ if (FAIL == H5AC_insert_entry(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTINIT, "unable to cache local heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap prefix"); /* Set address to return */ *addr_p = heap->prfx_addr; - CATCH +done: if (ret_value < 0) { *addr_p = HADDR_UNDEF; if (prfx) { if (FAIL == H5HL__prfx_dest(prfx)) - H5E_THROW(H5E_CANTFREE, "unable to destroy local heap prefix"); - } /* end if */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap prefix"); + } else { if (heap) { if (H5F_addr_defined(heap->prfx_addr)) if (FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, heap->prfx_addr, total_size)) - H5E_THROW(H5E_CANTFREE, "can't release heap data?"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't release heap data?"); if (FAIL == H5HL__dest(heap)) - H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); - } /* end if */ - } /* end else */ - } /* end if */ - -END_FUNC(PRIV) /* end H5HL_create() */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap"); + } + } + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_create() */ /*------------------------------------------------------------------------- * Function: H5HL__minimize_heap_space @@ -188,16 +191,19 @@ END_FUNC(PRIV) /* end H5HL_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap)) - +static herr_t +H5HL__minimize_heap_space(H5F_t *f, H5HL_t *heap) +{ size_t new_heap_size = heap->dblk_size; /* New size of heap */ + herr_t ret_value = SUCCEED; - /* check args */ + FUNC_ENTER_STATIC + + /* Check args */ HDassert(f); HDassert(heap); - /* - * Check to see if we can reduce the size of the heap in memory by + /* Check to see if we can reduce the size of the heap in memory by * eliminating free blocks at the tail of the buffer before flushing the * buffer out. */ @@ -211,29 +217,25 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * if (tmp_fl->offset + tmp_fl->size == heap->dblk_size) { last_fl = tmp_fl; break; - } /* end if */ + } - /* - * Found free block at the end of the buffer, decide what to do + /* Found free block at the end of the buffer, decide what to do * about it */ if (last_fl) { - /* - * If the last free block's size is more than half the memory + /* If the last free block's size is more than half the memory * buffer size (and the memory buffer is larger than the * minimum size), reduce or eliminate it. */ if (last_fl->size >= (heap->dblk_size / 2) && heap->dblk_size > H5HL_MIN_HEAP) { - /* - * Reduce size of buffer until it's too small or would + /* Reduce size of buffer until it's too small or would * eliminate the free block */ while (new_heap_size > H5HL_MIN_HEAP && new_heap_size >= (last_fl->offset + H5HL_SIZEOF_FREE(f))) new_heap_size /= 2; - /* - * Check if reducing the memory buffer size would + /* Check if reducing the memory buffer size would * eliminate the free block */ if (new_heap_size < (last_fl->offset + H5HL_SIZEOF_FREE(f))) { @@ -246,31 +248,29 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); new_heap_size = last_fl->offset + last_fl->size; HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); - } /* end if */ + } else { - /* - * Set the size of the memory buffer to the start + /* Set the size of the memory buffer to the start * of the free list */ new_heap_size = last_fl->offset; /* Eliminate the free block from the list */ last_fl = H5HL__remove_free(heap, last_fl); - } /* end else */ - } /* end if */ + } + } else { /* Truncate the free block */ last_fl->size = H5HL_ALIGN(new_heap_size - last_fl->offset); new_heap_size = last_fl->offset + last_fl->size; HDassert(last_fl->size >= H5HL_SIZEOF_FREE(f)); HDassert(last_fl->size == H5HL_ALIGN(last_fl->size)); - } /* end else */ - } /* end if */ - } /* end if */ - } /* end if */ + } + } + } + } - /* - * If the heap grew smaller than disk storage then move the + /* If the heap grew smaller than disk storage then move the * data segment of the heap to another contiguous block of disk * storage. */ @@ -279,17 +279,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__minimize_heap_space(H5F_t * /* Resize the memory buffer */ if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, new_heap_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Reallocate data block in file */ if (FAIL == H5HL__dblk_realloc(f, heap, new_heap_size)) - H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); - } /* end if */ - - CATCH - /* No special processing on errors */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "reallocating data block failed"); + } -END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HL__minimize_heap_space() */ /*------------------------------------------------------------------------- * Function: H5HL_protect @@ -304,20 +303,24 @@ END_FUNC(STATIC) /* H5HL__minimize_heap_space() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags)) - +H5HL_t * +H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags) +{ H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ - H5HL_dblk_t * dblk = NULL; /* Local heap data block */ - H5HL_t * heap = NULL; /* Heap data structure */ + H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ + H5HL_dblk_t *dblk = NULL; /* Local heap data block */ + H5HL_t *heap = NULL; /* Heap data structure */ unsigned prfx_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting prefix entry */ unsigned dblk_cache_flags = H5AC__NO_FLAGS_SET; /* Cache flags for unprotecting data block entry */ + H5HL_t *ret_value = NULL; - /* check arguments */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); - /* only the H5AC__READ_ONLY_FLAG may appear in flags */ + /* Only the H5AC__READ_ONLY_FLAG may appear in flags */ HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); /* Construct the user data for protect callback */ @@ -328,7 +331,7 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -344,12 +347,12 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Protect the local heap data block */ if (NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, flags))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap data block"); /* Set the flag for pinning the data block when unprotecting it */ dblk_cache_flags |= H5AC__PIN_ENTRY_FLAG; - } /* end if */ - } /* end if */ + } + } /* Increment # of times heap is protected */ heap->prots++; @@ -357,16 +360,17 @@ BEGIN_FUNC(PRIV, ERR, H5HL_t *, NULL, NULL, H5HL_protect(H5F_t *f, haddr_t addr, /* Set return value */ ret_value = heap; - CATCH +done: /* Release the prefix from the cache, now pinned */ if (prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, prfx_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap prefix"); /* Release the data block from the cache, now pinned */ if (dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, dblk_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release local heap data block"); -END_FUNC(PRIV) /* end H5HL_protect() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_protect() */ /*------------------------------------------------------------------------- * Function: H5HL_offset_into @@ -374,26 +378,31 @@ END_FUNC(PRIV) /* end H5HL_protect() */ * Purpose: Called directly after the call to H5HL_protect so that * a pointer to the object in the heap can be obtained. * - * Return: Success: Valid pointer. - * Failure: Can't fail + * Return: Success: Valid pointer + * Failure: NULL * * Programmer: Bill Wendling * Sept. 17, 2003 * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, void *, NULL, NULL, H5HL_offset_into(const H5HL_t *heap, size_t offset)) +void * +H5HL_offset_into(const H5HL_t *heap, size_t offset) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) /* Sanity check */ HDassert(heap); if (offset >= heap->dblk_size) - H5E_THROW(H5E_CANTGET, "unable to offset into local heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, NULL, "unable to offset into local heap data block"); ret_value = heap->dblk_image + offset; - CATCH -/* No special processing on errors */ -END_FUNC(PRIV) /* end H5HL_offset_into() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_offset_into() */ /*------------------------------------------------------------------------- * Function: H5HL_unprotect @@ -407,9 +416,14 @@ END_FUNC(PRIV) /* end H5HL_offset_into() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) +herr_t +H5HL_unprotect(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(heap); /* Decrement # of times heap is protected */ @@ -421,8 +435,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) if (heap->single_cache_obj) { /* Mark local heap prefix as evictable again */ if (FAIL == H5AC_unpin_entry(heap->prfx)) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block"); + } else { /* Sanity check */ HDassert(heap->dblk); @@ -430,14 +444,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_unprotect(H5HL_t *heap)) /* Mark local heap data block as evictable again */ /* (data block still pins prefix) */ if (FAIL == H5AC_unpin_entry(heap->dblk)) - H5E_THROW(H5E_CANTUNPIN, "unable to unpin local heap data block"); - } /* end else */ - } /* end if */ - - CATCH - /* No special processing on errors */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap data block"); + } + } -END_FUNC(PRIV) /* end H5HL_unprotect() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_unprotect() */ /*------------------------------------------------------------------------- * Function: H5HL__remove_free @@ -452,7 +465,12 @@ END_FUNC(PRIV) /* end H5HL_unprotect() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, NOERR, H5HL_free_t *, NULL, -, H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl)) +static H5HL_free_t * +H5HL__remove_free(H5HL_t *heap, H5HL_free_t *fl) +{ + H5HL_free_t *ret_value = NULL; + + FUNC_ENTER_STATIC_NOERR if (fl->prev) fl->prev->next = fl->next; @@ -465,7 +483,8 @@ BEGIN_FUNC(STATIC, NOERR, H5HL_free_t *, NULL, -, H5HL__remove_free(H5HL_t *heap /* H5FL_FREE always returns NULL so we can't check for errors */ ret_value = (H5HL_free_t *)H5FL_FREE(H5HL_free_t, fl); -END_FUNC(STATIC) /* end H5HL__remove_free() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__remove_free() */ /*------------------------------------------------------------------------- * Function: H5HL__dirty @@ -479,9 +498,14 @@ END_FUNC(STATIC) /* end H5HL__remove_free() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__dirty(H5HL_t *heap)) +static herr_t +H5HL__dirty(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_STATIC + + /* Check arguments */ HDassert(heap); HDassert(heap->prfx); @@ -491,17 +515,16 @@ BEGIN_FUNC(STATIC, ERR, herr_t, SUCCEED, FAIL, H5HL__dirty(H5HL_t *heap)) HDassert(heap->dblk); if (FAIL == H5AC_mark_entry_dirty(heap->dblk)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap data block as dirty"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap data block as dirty"); + } /* Mark heap prefix as dirty */ if (FAIL == H5AC_mark_entry_dirty(heap->prfx)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap prefix as dirty"); - - CATCH - /* No special processing on errors */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap prefix as dirty"); -END_FUNC(STATIC) /* end H5HL__dirty() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dirty() */ /*------------------------------------------------------------------------- * Function: H5HL_insert @@ -519,13 +542,16 @@ END_FUNC(STATIC) /* end H5HL__dirty() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, - H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf, size_t *offset_out)) - +herr_t +H5HL_insert(H5F_t *f, H5HL_t *heap, size_t buf_size, const void *buf, size_t *offset_out) +{ H5HL_free_t *fl = NULL, *last_fl = NULL; size_t need_size; size_t offset = 0; hbool_t found; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ HDassert(f); @@ -541,7 +567,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, * if an error occurs -QAK) */ if (FAIL == H5HL__dirty(heap)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty"); /* In order to keep the free list descriptors aligned on word boundaries, * whatever that might mean, we round the size up to the next multiple of @@ -574,7 +600,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, /* Track free space that's closest to end of heap */ last_fl = fl; } - } /* end for */ + } /* If no free chunk was large enough, then allocate more space and * add it to the free list. If the heap ends with a free chunk, we @@ -612,7 +638,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, was_extended = H5MF_try_extend(f, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more); if (FAIL == was_extended) - H5E_THROW(H5E_CANTEXTEND, "error trying to extend heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, FAIL, "error trying to extend heap"); /* Check if we extended the heap data block in file */ if (was_extended == TRUE) { @@ -620,22 +646,22 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, if (heap->single_cache_obj) { /* Resize prefix+data block */ if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_dblk_size))) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap prefix in cache"); + } else { /* Resize 'standalone' data block */ if (FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_dblk_size)) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache"); - } /* end else */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap data block in cache"); + } /* Note new size */ heap->dblk_size = new_dblk_size; - } /* end if */ + } else { /* ...if we can't, allocate a new chunk & release the old */ /* Reallocate data block in file */ if (FAIL == H5HL__dblk_realloc(f, heap, new_dblk_size)) - H5E_THROW(H5E_CANTRESIZE, "reallocating data block failed"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "reallocating data block failed"); + } /* If the last free list in the heap is at the end of the heap, extend it */ if (last_fl && last_fl->offset + last_fl->size == old_dblk_size) { @@ -657,7 +683,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, #endif last_fl = H5HL__remove_free(heap, last_fl); } - } /* end if */ + } else { /* Create a new free list element large enough that we can * take some space out of it right away. @@ -665,7 +691,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, offset = old_dblk_size; if (need_more - need_size >= H5HL_SIZEOF_FREE(f)) { if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); fl->offset = old_dblk_size + need_size; fl->size = need_more - need_size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); @@ -682,7 +708,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, (unsigned long)(need_more - need_size), __LINE__); #endif } - } /* end else */ + } #ifdef H5HL_DEBUG if (H5DEBUG(HL)) { @@ -691,22 +717,21 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, } #endif if (NULL == (heap->dblk_image = H5FL_BLK_REALLOC(lheap_chunk, heap->dblk_image, heap->dblk_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); /* Clear new section so junk doesn't appear in the file */ /* (Avoid clearing section which will be overwritten with newly inserted data) */ HDmemset(heap->dblk_image + offset + buf_size, 0, (new_dblk_size - (offset + buf_size))); - } /* end if */ + } /* Copy the data into the heap */ H5MM_memcpy(heap->dblk_image + offset, buf, buf_size); *offset_out = offset; - CATCH - /* No special processing on exit */ - -END_FUNC(PRIV) /* H5HL_insert() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HL_insert() */ /*------------------------------------------------------------------------- * Function: H5HL_remove @@ -731,11 +756,15 @@ END_FUNC(PRIV) /* H5HL_insert() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size)) +herr_t +H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size) +{ + H5HL_free_t *fl = NULL; + herr_t ret_value = SUCCEED; - H5HL_free_t *fl = NULL; + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(heap); HDassert(size > 0); @@ -746,17 +775,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, HDassert(offset < heap->dblk_size); HDassert(offset + size <= heap->dblk_size); - /* Mark heap as dirty in cache */ - /* (A bit early in the process, but it's difficult to determine in the + /* Mark heap as dirty in cache + * + * (A bit early in the process, but it's difficult to determine in the * code below where to mark the heap as dirty, especially in error cases, * so we just accept that an extra flush of the heap info could occur * if an error occurs -QAK) */ if (FAIL == H5HL__dirty(heap)) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark heap as dirty"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTMARKDIRTY, FAIL, "unable to mark heap as dirty"); - /* - * Check if this chunk can be prepended or appended to an already + /* Check if this chunk can be prepended or appended to an already * free chunk. It might also fall between two chunks in such a way * that all three chunks can be combined into one. */ @@ -779,17 +808,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, fl2 = H5HL__remove_free(heap, fl2); if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - H5_LEAVE(SUCCEED); + HGOTO_DONE(SUCCEED) } fl2 = fl2->next; } if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); } - H5_LEAVE(SUCCEED); + HGOTO_DONE(SUCCEED) } else if (fl->offset + fl->size == offset) { fl->size += size; @@ -802,20 +831,20 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, fl2 = H5HL__remove_free(heap, fl2); if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - } /* end if */ - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); + } + HGOTO_DONE(SUCCEED) + } fl2 = fl2->next; - } /* end while */ + } if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) { if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - } /* end if */ - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); + } + HGOTO_DONE(SUCCEED) + } fl = fl->next; - } /* end while */ + } /* * The amount which is being removed must be large enough to @@ -828,14 +857,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, HDfprintf(H5DEBUG(HL), "H5HL: lost %lu bytes\n", (unsigned long)size); } #endif - H5_LEAVE(SUCCEED); - } /* end if */ + HGOTO_DONE(SUCCEED) + } - /* - * Add an entry to the free list. - */ + /* Add an entry to the free list */ if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); fl->offset = offset; fl->size = size; HDassert(fl->offset == H5HL_ALIGN(fl->offset)); @@ -848,12 +875,11 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_remove(H5F_t *f, H5HL_t *heap, if (((fl->offset + fl->size) == heap->dblk_size) && ((2 * fl->size) > heap->dblk_size)) if (FAIL == H5HL__minimize_heap_space(f, heap)) - H5E_THROW(H5E_CANTFREE, "heap size minimization failed"); - - CATCH - /* No special processing on exit */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed"); -END_FUNC(PRIV) /* end H5HL_remove() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_remove() */ /*------------------------------------------------------------------------- * Function: H5HL_delete @@ -867,15 +893,19 @@ END_FUNC(PRIV) /* end H5HL_remove() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr)) - - H5HL_t * heap = NULL; /* Local heap to delete */ +herr_t +H5HL_delete(H5F_t *f, haddr_t addr) +{ + H5HL_t *heap = NULL; /* Local heap to delete */ H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ - H5HL_dblk_t * dblk = NULL; /* Local heap data block */ + H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ + H5HL_dblk_t *dblk = NULL; /* Local heap data block */ unsigned cache_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting heap */ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); @@ -888,7 +918,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr) /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -898,21 +928,22 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_delete(H5F_t *f, haddr_t addr) /* Protect the local heap data block */ if (NULL == (dblk = (H5HL_dblk_t *)H5AC_protect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, heap, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap data block"); /* Set the flags for releasing the prefix and data block */ cache_flags |= H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - CATCH +done: /* Release the data block from the cache, now deleted */ if (dblk && heap && H5AC_unprotect(f, H5AC_LHEAP_DBLK, heap->dblk_addr, dblk, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap data block"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap data block"); /* Release the prefix from the cache, now deleted */ if (prfx && heap && H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_delete() */ /*------------------------------------------------------------------------- * Function: H5HL_get_size @@ -926,13 +957,17 @@ END_FUNC(PRIV) /* end H5HL_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size)) +herr_t +H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size) +{ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ + H5HL_t *heap = NULL; /* Heap data structure */ + herr_t ret_value = SUCCEED; - H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ - H5HL_t * heap = NULL; /* Heap data structure */ + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(size); @@ -946,7 +981,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t add /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -954,11 +989,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_get_size(H5F_t *f, haddr_t add /* Set the size to return */ *size = heap->dblk_size; - CATCH +done: if (prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_get_size() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_get_size() */ /*------------------------------------------------------------------------- * Function: H5HL_heapsize @@ -973,13 +1009,17 @@ END_FUNC(PRIV) /* end H5HL_get_size() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size)) +herr_t +H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size) +{ + H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ + H5HL_prfx_t *prfx = NULL; /* Local heap prefix */ + H5HL_t *heap = NULL; /* Heap data structure */ + herr_t ret_value = SUCCEED; - H5HL_cache_prfx_ud_t prfx_udata; /* User data for protecting local heap prefix */ - H5HL_prfx_t * prfx = NULL; /* Local heap prefix */ - H5HL_t * heap = NULL; /* Heap data structure */ + FUNC_ENTER_NOAPI(FAIL) - /* check arguments */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); HDassert(heap_size); @@ -993,7 +1033,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t add /* Protect the local heap prefix */ if (NULL == (prfx = (H5HL_prfx_t *)H5AC_protect(f, H5AC_LHEAP_PRFX, addr, &prfx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load heap prefix"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix"); /* Get the pointer to the heap */ heap = prfx->heap; @@ -1001,8 +1041,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5HL_heapsize(H5F_t *f, haddr_t add /* Accumulate the size of the local heap */ *heap_size += (hsize_t)(heap->prfx_size + heap->dblk_size); - CATCH +done: if (prfx && FAIL == H5AC_unprotect(f, H5AC_LHEAP_PRFX, heap->prfx_addr, prfx, H5AC__NO_FLAGS_SET)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release local heap prefix"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap prefix"); -END_FUNC(PRIV) /* end H5HL_heapsize() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_heapsize() */ diff --git a/src/H5HLcache.c b/src/H5HLcache.c index b46280ef79b..dcf1249ddaa 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -68,21 +67,22 @@ static herr_t H5HL__cache_prefix_get_initial_load_size(void *udata, size_t *image_len); static herr_t H5HL__cache_prefix_get_final_load_size(const void *_image, size_t image_len, void *udata, size_t *actual_len); -static void * H5HL__cache_prefix_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5HL__cache_prefix_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HL__cache_prefix_image_len(const void *thing, size_t *image_len); static herr_t H5HL__cache_prefix_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HL__cache_prefix_free_icr(void *thing); /* Local heap data block */ static herr_t H5HL__cache_datablock_get_initial_load_size(void *udata, size_t *image_len); -static void * H5HL__cache_datablock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5HL__cache_datablock_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5HL__cache_datablock_image_len(const void *thing, size_t *image_len); static herr_t H5HL__cache_datablock_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing); static herr_t H5HL__cache_datablock_free_icr(void *thing); /* Header deserialization */ -static herr_t H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, H5HL_cache_prfx_ud_t *udata); +static herr_t H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, size_t len, + H5HL_cache_prfx_ud_t *udata); /* Free list de/serialization */ static herr_t H5HL__fl_deserialize(H5HL_t *heap); @@ -149,9 +149,10 @@ const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, H5HL_cache_prfx_ud_t *udata) +H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, size_t len, H5HL_cache_prfx_ud_t *udata) { - herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *p_end = image + len - 1; /* End of image buffer */ + herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -160,16 +161,22 @@ H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, H5HL_cache_prfx_ud_t * HDassert(image); HDassert(udata); - /* Check magic number */ + /* Magic number */ + if (H5_IS_BUFFER_OVERFLOW(image, H5_SIZEOF_MAGIC, p_end)) + HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); if (HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC) != 0) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad local heap signature") + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad local heap signature"); image += H5_SIZEOF_MAGIC; /* Version */ + if (H5_IS_BUFFER_OVERFLOW(image, 1, p_end)) + HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); if (H5HL_VERSION != *image++) - HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in local heap") + HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in local heap"); /* Reserved */ + if (H5_IS_BUFFER_OVERFLOW(image, 3, p_end)) + HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); image += 3; /* Store the prefix's address & length */ @@ -177,16 +184,28 @@ H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image, H5HL_cache_prfx_ud_t * heap->prfx_size = udata->sizeof_prfx; /* Heap data size */ + if (H5_IS_BUFFER_OVERFLOW(image, udata->sizeof_size, p_end)) + HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); H5F_DECODE_LENGTH_LEN(image, heap->dblk_size, udata->sizeof_size); /* Free list head */ + if (H5_IS_BUFFER_OVERFLOW(image, udata->sizeof_size, p_end)) + HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); H5F_DECODE_LENGTH_LEN(image, heap->free_block, udata->sizeof_size); if (heap->free_block != H5HL_FREE_NULL && heap->free_block >= heap->dblk_size) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad heap free list") + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad heap free list"); /* Heap data address */ + if (H5_IS_BUFFER_OVERFLOW(image, udata->sizeof_addr, p_end)) + HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); H5F_addr_decode_len(udata->sizeof_addr, &image, &(heap->dblk_addr)); + /* Check that the datablock address is valid (might not be true + * in a corrupt file) + */ + if (!H5F_addr_defined(heap->dblk_addr)) + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad datablock address"); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__hdr_deserialize() */ @@ -223,11 +242,11 @@ H5HL__fl_deserialize(H5HL_t *heap) /* Sanity check */ if (free_block >= heap->dblk_size) - HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list") + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list"); /* Allocate & initialize free list node */ if (NULL == (fl = H5FL_MALLOC(H5HL_free_t))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed"); fl->offset = (size_t)free_block; fl->prev = tail; fl->next = NULL; @@ -236,12 +255,12 @@ H5HL__fl_deserialize(H5HL_t *heap) image = heap->dblk_image + free_block; H5F_DECODE_LENGTH_LEN(image, free_block, heap->sizeof_size); if (0 == free_block) - HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "free block size is zero?") + HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "free block size is zero?"); /* Decode length of this free block */ H5F_DECODE_LENGTH_LEN(image, fl->size, heap->sizeof_size); if ((fl->offset + fl->size) > heap->dblk_size) - HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list") + HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "bad heap free list"); /* Append node onto list */ if (tail) @@ -250,7 +269,7 @@ H5HL__fl_deserialize(H5HL_t *heap) heap->freelist = fl; tail = fl; fl = NULL; - } /* end while */ + } done: if (ret_value < 0) @@ -296,7 +315,7 @@ H5HL__fl_serialize(const H5HL_t *heap) H5F_ENCODE_LENGTH_LEN(image, H5HL_FREE_NULL, heap->sizeof_size) H5F_ENCODE_LENGTH_LEN(image, fl->size, heap->sizeof_size) - } /* end for */ + } FUNC_LEAVE_NOAPI_VOID @@ -345,10 +364,9 @@ H5HL__cache_prefix_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *im *------------------------------------------------------------------------- */ static herr_t -H5HL__cache_prefix_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image_len, - void *_udata, size_t *actual_len) +H5HL__cache_prefix_get_final_load_size(const void *_image, size_t image_len, void *_udata, size_t *actual_len) { - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ H5HL_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ H5HL_t heap; /* Local heap */ herr_t ret_value = SUCCEED; /* Return value */ @@ -362,8 +380,8 @@ H5HL__cache_prefix_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG HDassert(*actual_len == image_len); /* Deserialize the heap's header */ - if (H5HL__hdr_deserialize(&heap, (const uint8_t *)image, udata) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode local heap header") + if (H5HL__hdr_deserialize(&heap, (const uint8_t *)image, image_len, udata) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode local heap header"); /* Set the final size for the cache image */ *actual_len = heap.prfx_size; @@ -395,14 +413,14 @@ H5HL__cache_prefix_get_final_load_size(const void *_image, size_t H5_ATTR_NDEBUG *------------------------------------------------------------------------- */ static void * -H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, - hbool_t H5_ATTR_UNUSED *dirty) +H5HL__cache_prefix_deserialize(const void *_image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5HL_t * heap = NULL; /* Local heap */ - H5HL_prfx_t * prfx = NULL; /* Heap prefix deserialized */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into decoding buffer */ + H5HL_t *heap = NULL; /* Local heap */ + H5HL_prfx_t *prfx = NULL; /* Heap prefix deserialized */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into decoding buffer */ + const uint8_t *p_end = image + len - 1; /* End of image buffer */ H5HL_cache_prfx_ud_t *udata = (H5HL_cache_prfx_ud_t *)_udata; /* User data for callback */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -421,8 +439,8 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap structure"); /* Deserialize the heap's header */ - if (H5HL__hdr_deserialize(heap, (const uint8_t *)image, udata) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode local heap header") + if (H5HL__hdr_deserialize(heap, (const uint8_t *)image, len, udata) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode local heap header"); /* Allocate the heap prefix */ if (NULL == (prfx = H5HL__prfx_new(heap))) @@ -437,7 +455,7 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED /* Allocate space for the heap data image */ if (NULL == (heap->dblk_image = H5FL_BLK_MALLOC(lheap_chunk, heap->dblk_size))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed"); /* Set image to the start of the data block. This is necessary * because there may be a gap between the used portion of the @@ -445,18 +463,20 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED image = ((const uint8_t *)_image) + heap->prfx_size; /* Copy the heap data from the speculative read buffer */ + if (H5_IS_BUFFER_OVERFLOW(image, heap->dblk_size, p_end)) + HGOTO_ERROR(H5E_HEAP, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding"); H5MM_memcpy(heap->dblk_image, image, heap->dblk_size); /* Build free list */ if (H5HL__fl_deserialize(heap) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list") - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list"); + } else /* Note that the heap should _NOT_ be a single * object in the cache */ heap->single_cache_obj = FALSE; - } /* end if */ + } /* Set return value */ ret_value = prfx; @@ -467,12 +487,12 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED if (prfx) { if (FAIL == H5HL__prfx_dest(prfx)) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap prefix"); - } /* end if */ + } else { if (heap && FAIL == H5HL__dest(heap)) HDONE_ERROR(H5E_HEAP, H5E_CANTRELEASE, NULL, "unable to destroy local heap"); - } /* end else */ - } /* end if */ + } + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL__cache_prefix_deserialize() */ @@ -537,9 +557,8 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5HL_prfx_t *prfx = (H5HL_prfx_t *)_thing; /* Pointer to local heap prefix to query */ - H5HL_t * heap; /* Pointer to the local heap */ - uint8_t * image = (uint8_t *)_image; /* Pointer into image buffer */ - size_t buf_size; /* expected size of the image buffer */ + H5HL_t *heap; /* Pointer to the local heap */ + uint8_t *image = (uint8_t *)_image; /* Pointer into image buffer */ FUNC_ENTER_STATIC_NOERR @@ -556,11 +575,13 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, heap = prfx->heap; HDassert(heap); +#ifndef NDEBUG /* Compute the buffer size */ - buf_size = heap->prfx_size; + size_t buf_size = heap->prfx_size; /* expected size of the image buffer */ if (heap->single_cache_obj) buf_size += heap->dblk_size; HDassert(len == buf_size); +#endif /* Update the free block value from the free list */ heap->free_block = heap->freelist ? heap->freelist->offset : H5HL_FREE_NULL; @@ -588,7 +609,7 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, gap = heap->prfx_size - (size_t)(image - (uint8_t *)_image); HDmemset(image, 0, gap); image += gap; - } /* end if */ + } /* Serialize the free list into the heap data's image */ H5HL__fl_serialize(heap); @@ -598,14 +619,14 @@ H5HL__cache_prefix_serialize(const H5_ATTR_NDEBUG_UNUSED H5F_t *f, void *_image, /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) + heap->dblk_size == len); - } /* end if */ + } else { /* Sanity check */ HDassert((size_t)(image - (uint8_t *)_image) <= len); /* Clear rest of local heap */ HDmemset(image, 0, len - (size_t)(image - (uint8_t *)_image)); - } /* end else */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HL__cache_prefix_serialize() */ @@ -648,7 +669,7 @@ H5HL__cache_prefix_free_icr(void *_thing) /* Destroy local heap prefix */ if (H5HL__prfx_dest(prfx) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't destroy local heap prefix") + HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't destroy local heap prefix"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -706,8 +727,8 @@ static void * H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { H5HL_dblk_t *dblk = NULL; /* Local heap data block deserialized */ - H5HL_t * heap = (H5HL_t *)_udata; /* User data for callback */ - void * ret_value = NULL; /* Return value */ + H5HL_t *heap = (H5HL_t *)_udata; /* User data for callback */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -736,7 +757,7 @@ H5HL__cache_datablock_deserialize(const void *image, size_t len, void *_udata, h /* Build free list */ if (FAIL == H5HL__fl_deserialize(heap)) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't initialize free list"); - } /* end if */ + } /* Set return value */ ret_value = dblk; @@ -801,7 +822,7 @@ static herr_t H5HL__cache_datablock_serialize(const H5F_t H5_ATTR_NDEBUG_UNUSED *f, void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5HL_t * heap; /* Pointer to the local heap */ + H5HL_t *heap; /* Pointer to the local heap */ H5HL_dblk_t *dblk = (H5HL_dblk_t *)_thing; /* Pointer to the local heap data block */ FUNC_ENTER_STATIC_NOERR @@ -866,7 +887,7 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) /* Pin the heap's prefix */ if (FAIL == H5AC_pin_protected_entry(dblk->heap->prfx)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin local heap prefix") + HGOTO_ERROR(H5E_HEAP, H5E_CANTPIN, FAIL, "unable to pin local heap prefix"); break; case H5AC_NOTIFY_ACTION_AFTER_FLUSH: @@ -886,13 +907,13 @@ H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing) /* Unpin the local heap prefix */ if (FAIL == H5AC_unpin_entry(dblk->heap->prfx)) - HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap prefix") + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPIN, FAIL, "unable to unpin local heap prefix"); break; default: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown action from metadata cache") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown action from metadata cache"); break; - } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -930,7 +951,7 @@ H5HL__cache_datablock_free_icr(void *_thing) /* Destroy the data block */ if (H5HL__dblk_dest(dblk) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block") + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap data block"); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index 76e4ec09cbb..6e5ad39fd01 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -44,14 +43,17 @@ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, - H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)) - - H5HL_t * h = NULL; +herr_t +H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) +{ + H5HL_t *h = NULL; int free_block; H5HL_free_t *freelist; - uint8_t * marker = NULL; + uint8_t *marker = NULL; size_t amount_free = 0; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) /* check arguments */ HDassert(f); @@ -61,7 +63,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, HDassert(fwidth >= 0); if (NULL == (h = (H5HL_t *)H5HL_protect(f, addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load/protect local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load/protect local heap") HDfprintf(stream, "%*sLocal Heap...\n", indent, ""); HDfprintf(stream, "%*s%-*s %zu\n", indent, "", fwidth, "Header size (in bytes):", h->prfx_size); @@ -73,7 +75,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, * the heap. */ if (NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") HDfprintf(stream, "%*sFree Blocks (offset, size):\n", indent, ""); for (free_block = 0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) { @@ -92,13 +94,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, if (marker[freelist->offset + i]) overlap++; marker[freelist->offset + i] = 1; - } /* end for */ + } if (overlap) HDfprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n"); else amount_free += freelist->size; - } /* end else */ - } /* end for */ + } + } if (h->dblk_size) HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", @@ -107,11 +109,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, /* Print the data in a VMS-style octal dump */ H5_buffer_dump(stream, indent, h->dblk_image, marker, (size_t)0, h->dblk_size); - CATCH +done: if (h && FAIL == H5HL_unprotect(h)) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release/unprotect local heap"); + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release/unprotect local heap") if (marker && NULL != (marker = (uint8_t *)H5MM_xfree(marker))) - H5E_THROW(H5E_CANTFREE, "can't free marker buffer"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't free marker buffer") -END_FUNC(PRIV) /* end H5HL_debug() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_debug() */ diff --git a/src/H5HLdblk.c b/src/H5HLdblk.c index f771de522c5..6b80897b21b 100644 --- a/src/H5HLdblk.c +++ b/src/H5HLdblk.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -81,20 +80,24 @@ H5FL_DEFINE_STATIC(H5HL_dblk_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_dblk_t *, NULL, NULL, H5HL__dblk_new(H5HL_t *heap)) +H5HL_dblk_t * +H5HL__dblk_new(H5HL_t *heap) +{ + H5HL_dblk_t *dblk = NULL; /* New local heap data block */ + H5HL_dblk_t *ret_value = NULL; - H5HL_dblk_t *dblk = NULL; /* New local heap data block */ + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); /* Allocate new local heap data block */ if (NULL == (dblk = H5FL_CALLOC(H5HL_dblk_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap data block") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for local heap data block") /* Increment ref. count on heap data structure */ if (FAIL == H5HL__inc_rc(heap)) - H5E_THROW(H5E_CANTINC, "can't increment heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count") /* Link the heap & the data block */ dblk->heap = heap; @@ -103,13 +106,14 @@ BEGIN_FUNC(PKG, ERR, H5HL_dblk_t *, NULL, NULL, H5HL__dblk_new(H5HL_t *heap)) /* Set the return value */ ret_value = dblk; - CATCH +done: /* Ensure that the data block memory is deallocated on errors */ if (!ret_value && dblk != NULL) /* H5FL_FREE always returns NULL so we can't check for errors */ dblk = H5FL_FREE(H5HL_dblk_t, dblk); -END_FUNC(PKG) /* end H5HL__dblk_new() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5HL__dblk_new() */ /*------------------------------------------------------------------------- * Function: H5HL__dblk_dest @@ -123,7 +127,12 @@ END_FUNC(PKG) /* end H5HL__dblk_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_dest(H5HL_dblk_t *dblk)) +herr_t +H5HL__dblk_dest(H5HL_dblk_t *dblk) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(dblk); @@ -135,18 +144,19 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_dest(H5HL_dblk_t *dblk)) /* Decrement ref. count on heap data structure */ if (FAIL == H5HL__dec_rc(dblk->heap)) - H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count") /* Unlink heap from data block */ dblk->heap = NULL; - } /* end if */ + } - CATCH +done: /* Free local heap data block */ /* H5FL_FREE always returns NULL so we can't check for errors */ dblk = H5FL_FREE(H5HL_dblk_t, dblk); -END_FUNC(PKG) /* end H5HL__dblk_dest() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dblk_dest() */ /*------------------------------------------------------------------------- * Function: H5HL__dblk_realloc @@ -160,14 +170,18 @@ END_FUNC(PKG) /* end H5HL__dblk_dest() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size)) - +herr_t +H5HL__dblk_realloc(H5F_t *f, H5HL_t *heap, size_t new_heap_size) +{ H5HL_dblk_t *dblk; /* Local heap data block */ haddr_t old_addr; /* Old location of heap data block */ haddr_t new_addr; /* New location of heap data block */ size_t old_heap_size; /* Old size of heap data block */ + herr_t ret_value = SUCCEED; - /* check arguments */ + FUNC_ENTER_PACKAGE + + /* Check arguments */ HDassert(heap); HDassert(new_heap_size > 0); @@ -176,12 +190,12 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t old_heap_size = heap->dblk_size; H5_CHECK_OVERFLOW(old_heap_size, size_t, hsize_t); if (FAIL == H5MF_xfree(f, H5FD_MEM_LHEAP, old_addr, (hsize_t)old_heap_size)) - H5E_THROW(H5E_CANTFREE, "can't free old local heap data"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't free old local heap data"); /* Allocate new space on disk */ H5_CHECK_OVERFLOW(new_heap_size, size_t, hsize_t); if (HADDR_UNDEF == (new_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, (hsize_t)new_heap_size))) - H5E_THROW(H5E_CANTALLOC, "unable to allocate file space for local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file space for local heap"); /* Update heap info*/ heap->dblk_addr = new_addr; @@ -197,8 +211,8 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t /* Resize the heap prefix in the cache */ if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)(heap->prfx_size + new_heap_size))) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap in cache"); - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap in cache"); + } else { /* Sanity check */ HDassert(H5F_addr_ne(heap->prfx_addr + heap->prfx_size, old_addr)); @@ -206,50 +220,49 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dblk_realloc(H5F_t *f, H5HL_t /* Resize the heap data block in the cache */ if (H5AC_resize_entry(heap->dblk, (size_t)new_heap_size) < 0) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap (data block) in cache"); - } /* end else */ - } /* end if */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap (data block) in cache"); + } + } else { /* Check if heap data block was contiguous w/prefix previously */ if (heap->single_cache_obj) { /* Create new heap data block */ if (NULL == (dblk = H5HL__dblk_new(heap))) - H5E_THROW(H5E_CANTALLOC, "unable to allocate local heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate local heap data block"); /* Resize current heap prefix */ heap->prfx_size = H5HL_SIZEOF_HDR(f); if (FAIL == H5AC_resize_entry(heap->prfx, (size_t)heap->prfx_size)) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap prefix in cache"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap prefix in cache"); /* Insert data block into cache (pinned) */ if (FAIL == H5AC_insert_entry(f, H5AC_LHEAP_DBLK, new_addr, dblk, H5AC__PIN_ENTRY_FLAG)) - H5E_THROW(H5E_CANTINIT, "unable to cache local heap data block"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to cache local heap data block"); dblk = NULL; /* Reset 'single cache object' flag */ heap->single_cache_obj = FALSE; - } /* end if */ + } else { /* Resize the heap data block in the cache */ /* (ignore [unlikely] case where heap data block ends up * contiguous w/heap prefix again. */ if (FAIL == H5AC_resize_entry(heap->dblk, (size_t)new_heap_size)) - H5E_THROW(H5E_CANTRESIZE, "unable to resize heap data block in cache"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTRESIZE, FAIL, "unable to resize heap data block in cache"); /* Relocate the heap data block in the cache */ if (FAIL == H5AC_move_entry(f, H5AC_LHEAP_DBLK, old_addr, new_addr)) - H5E_THROW(H5E_CANTMOVE, "unable to move heap data block in cache"); - - } /* end else */ - } /* end else */ + HGOTO_ERROR(H5E_HEAP, H5E_CANTMOVE, FAIL, "unable to move heap data block in cache"); + } + } - CATCH +done: /* Restore old heap address & size on errors */ if (FAIL == ret_value) { heap->dblk_addr = old_addr; heap->dblk_size = old_heap_size; - } /* end if */ - -END_FUNC(PKG) /* end H5HL__dblk_realloc() */ + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dblk_realloc() */ diff --git a/src/H5HLint.c b/src/H5HLint.c index 069bad80761..fa879faa0f6 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -80,10 +79,13 @@ H5FL_DEFINE_STATIC(H5HL_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, - H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size)) +H5HL_t * +H5HL__new(size_t sizeof_size, size_t sizeof_addr, size_t prfx_size) +{ + H5HL_t *heap = NULL; /* New local heap */ + H5HL_t *ret_value = NULL; - H5HL_t *heap = NULL; /* New local heap */ + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(sizeof_size > 0); @@ -92,7 +94,7 @@ BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, /* Allocate new local heap structure */ if (NULL == (heap = H5FL_CALLOC(H5HL_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed") /* Initialize non-zero fields */ heap->sizeof_size = sizeof_size; @@ -102,12 +104,13 @@ BEGIN_FUNC(PKG, ERR, H5HL_t *, NULL, NULL, /* Set the return value */ ret_value = heap; - CATCH +done: if (!ret_value && heap != NULL) if (NULL == (heap = H5FL_FREE(H5HL_t, heap))) - H5E_THROW(H5E_CANTFREE, "can't free heap memory"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, NULL, "can't free heap memory") -END_FUNC(PKG) /* end H5HL__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__new() */ /*------------------------------------------------------------------------- * Function: H5HL__inc_rc @@ -121,7 +124,10 @@ END_FUNC(PKG) /* end H5HL__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5HL__inc_rc(H5HL_t *heap)) +herr_t +H5HL__inc_rc(H5HL_t *heap) +{ + FUNC_ENTER_PACKAGE_NOERR /* check arguments */ HDassert(heap); @@ -129,7 +135,8 @@ BEGIN_FUNC(PKG, NOERR, herr_t, SUCCEED, -, H5HL__inc_rc(H5HL_t *heap)) /* Increment heap's ref. count */ heap->rc++; -END_FUNC(PKG) /* end H5HL__inc_rc() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5HL__inc_rc() */ /*------------------------------------------------------------------------- * Function: H5HL__dec_rc @@ -143,7 +150,12 @@ END_FUNC(PKG) /* end H5HL__inc_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dec_rc(H5HL_t *heap)) +herr_t +H5HL__dec_rc(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); @@ -151,12 +163,13 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dec_rc(H5HL_t *heap)) /* Decrement heap's ref. count */ heap->rc--; - CATCH /* Check if we should destroy the heap */ if (heap->rc == 0 && FAIL == H5HL__dest(heap)) - H5E_THROW(H5E_CANTFREE, "unable to destroy local heap"); + HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to destroy local heap"); -END_FUNC(PKG) /* end H5HL__dec_rc() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dec_rc() */ /*------------------------------------------------------------------------- * Function: H5HL__dest @@ -170,7 +183,12 @@ END_FUNC(PKG) /* end H5HL__dec_rc() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dest(H5HL_t *heap)) +herr_t +H5HL__dest(H5HL_t *heap) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); @@ -181,20 +199,21 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__dest(H5HL_t *heap)) HDassert(heap->prfx == NULL); HDassert(heap->dblk == NULL); - CATCH + /* Use DONE errors here to try to free as much as possible */ if (heap->dblk_image) if (NULL != (heap->dblk_image = H5FL_BLK_FREE(lheap_chunk, heap->dblk_image))) - H5E_THROW(H5E_CANTFREE, "unable to free local heap data block image"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap data block image"); while (heap->freelist) { H5HL_free_t *fl; fl = heap->freelist; heap->freelist = fl->next; if (NULL != (fl = H5FL_FREE(H5HL_free_t, fl))) - H5E_THROW(H5E_CANTFREE, "unable to free local heap free list"); - } /* end while */ + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap free list"); + } if (NULL != (heap = H5FL_FREE(H5HL_t, heap))) - H5E_THROW(H5E_CANTFREE, "unable to free local heap"); + HDONE_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free local heap"); -END_FUNC(PKG) /* end H5HL__dest() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__dest() */ diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h index dbac1b9f3fd..bb5ce82b12c 100644 --- a/src/H5HLpkg.h +++ b/src/H5HLpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -54,7 +53,7 @@ H5FL_BLK_EXTERN(lheap_chunk); #define H5_MY_PKG H5HL #define H5_MY_PKG_ERR H5E_HEAP #define H5_MY_PKG_INIT NO -#endif /* H5HL_PACKAGE */ +#endif #define H5HL_SIZEOF_HDR(F) \ H5HL_ALIGN(H5_SIZEOF_MAGIC + /* heap signature */ \ @@ -101,7 +100,7 @@ struct H5HL_t { H5HL_dblk_t *dblk; /* The data block object for the heap */ haddr_t dblk_addr; /* address of data block */ size_t dblk_size; /* size of heap data block on disk and in mem */ - uint8_t * dblk_image; /* The data block image */ + uint8_t *dblk_image; /* The data block image */ }; /* Struct for heap data block */ diff --git a/src/H5HLprfx.c b/src/H5HLprfx.c index 90f6c741c0a..f81381cae43 100644 --- a/src/H5HLprfx.c +++ b/src/H5HLprfx.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -80,20 +79,24 @@ H5FL_DEFINE_STATIC(H5HL_prfx_t); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, H5HL_prfx_t *, NULL, NULL, H5HL__prfx_new(H5HL_t *heap)) +H5HL_prfx_t * +H5HL__prfx_new(H5HL_t *heap) +{ + H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + H5HL_prfx_t *ret_value = NULL; - H5HL_prfx_t *prfx = NULL; /* New local heap prefix */ + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(heap); /* Allocate new local heap prefix */ if (NULL == (prfx = H5FL_CALLOC(H5HL_prfx_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for local heap prefix") + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for local heap prefix") /* Increment ref. count on heap data structure */ if (FAIL == H5HL__inc_rc(heap)) - H5E_THROW(H5E_CANTINC, "can't increment heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment heap ref. count") /* Link the heap & the prefix */ prfx->heap = heap; @@ -102,13 +105,14 @@ BEGIN_FUNC(PKG, ERR, H5HL_prfx_t *, NULL, NULL, H5HL__prfx_new(H5HL_t *heap)) /* Set the return value */ ret_value = prfx; - CATCH +done: /* Ensure that the prefix memory is deallocated on errors */ if (!ret_value && prfx != NULL) /* H5FL_FREE always returns NULL so we can't check for errors */ prfx = H5FL_FREE(H5HL_prfx_t, prfx); -END_FUNC(PKG) /* end H5HL__prfx_new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__prfx_new() */ /*------------------------------------------------------------------------- * Function: H5HL__prfx_dest @@ -122,7 +126,12 @@ END_FUNC(PKG) /* end H5HL__prfx_new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__prfx_dest(H5HL_prfx_t *prfx)) +herr_t +H5HL__prfx_dest(H5HL_prfx_t *prfx) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_PACKAGE /* check arguments */ HDassert(prfx); @@ -134,15 +143,16 @@ BEGIN_FUNC(PKG, ERR, herr_t, SUCCEED, FAIL, H5HL__prfx_dest(H5HL_prfx_t *prfx)) /* Decrement ref. count on heap data structure */ if (FAIL == H5HL__dec_rc(prfx->heap)) - H5E_THROW(H5E_CANTDEC, "can't decrement heap ref. count") + HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement heap ref. count") /* Unlink heap from prefix */ prfx->heap = NULL; - } /* end if */ + } - CATCH +done: /* Free prefix memory */ /* H5FL_FREE always returns NULL so we can't check for errors */ prfx = H5FL_FREE(H5HL_prfx_t, prfx); -END_FUNC(PKG) /* end H5HL__prfx_dest() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL__prfx_dest() */ diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index 5c9884629db..51e7e992b0c 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -53,12 +52,12 @@ typedef struct H5HL_t H5HL_t; /* * Library prototypes */ -H5_DLL herr_t H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr /*out*/); -H5_DLL herr_t H5HL_delete(H5F_t *f, haddr_t addr); -H5_DLL herr_t H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size); -H5_DLL herr_t H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size); -H5_DLL herr_t H5HL_insert(H5F_t *f, H5HL_t *heap, size_t size, const void *buf, size_t *offset); -H5_DLL void * H5HL_offset_into(const H5HL_t *heap, size_t offset); +H5_DLL herr_t H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr /*out*/); +H5_DLL herr_t H5HL_delete(H5F_t *f, haddr_t addr); +H5_DLL herr_t H5HL_get_size(H5F_t *f, haddr_t addr, size_t *size); +H5_DLL herr_t H5HL_heapsize(H5F_t *f, haddr_t addr, hsize_t *heap_size); +H5_DLL herr_t H5HL_insert(H5F_t *f, H5HL_t *heap, size_t size, const void *buf, size_t *offset); +H5_DLL void *H5HL_offset_into(const H5HL_t *heap, size_t offset); H5_DLL H5HL_t *H5HL_protect(H5F_t *f, haddr_t addr, unsigned flags); H5_DLL herr_t H5HL_remove(H5F_t *f, H5HL_t *heap, size_t offset, size_t size); H5_DLL herr_t H5HL_unprotect(H5HL_t *heap); @@ -66,4 +65,4 @@ H5_DLL herr_t H5HL_unprotect(H5HL_t *heap); /* Debugging routines for dumping file structures */ H5_DLL herr_t H5HL_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); -#endif +#endif /* H5HLprivate_H */ diff --git a/src/H5HP.c b/src/H5HP.c deleted file mode 100644 index d1642237eda..00000000000 --- a/src/H5HP.c +++ /dev/null @@ -1,904 +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: Provides a heap abstract data type. - * - * (See chapter 11 - "Priority Queues" of _Algorithms_, by - * Sedgewick for additional information) - * - */ - -/* Private headers needed */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HPprivate.h" /* Heap routines */ -#include "H5FLprivate.h" /* Memory management functions */ - -/* Local Macros */ -#define H5HP_START_SIZE 16 /* Initial number of entries for heaps */ - -/* Private typedefs & structs */ - -/* Data structure for entries in the internal heap array */ -typedef struct { - int val; /* Value to be used for heap condition */ - H5HP_info_t *obj; /* Pointer to object stored in heap */ -} H5HP_ent_t; - -/* Main heap data structure */ -struct H5HP_t { - H5HP_type_t type; /* Type of heap (minimum or maximum value at "top") */ - size_t nobjs; /* Number of active objects in heap array */ - size_t nalloc; /* Number of allocated locations in heap array */ - H5HP_ent_t *heap; /* Pointer to array containing heap entries */ -}; - -/* Static functions */ -static herr_t H5HP__swim_max(H5HP_t *heap, size_t loc); -static herr_t H5HP__swim_min(H5HP_t *heap, size_t loc); -static herr_t H5HP__sink_max(H5HP_t *heap, size_t loc); -static herr_t H5HP__sink_min(H5HP_t *heap, size_t loc); - -/* Declare a free list to manage the H5HP_t struct */ -H5FL_DEFINE_STATIC(H5HP_t); - -/* Declare a free list to manage sequences of H5HP_ent_t */ -H5FL_SEQ_DEFINE_STATIC(H5HP_ent_t); - -/*-------------------------------------------------------------------------- - NAME - H5HP__swim_max - PURPOSE - Restore heap condition by moving an object upward - USAGE - herr_t H5HP__swim_max(heap, loc) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - size_t loc; IN: Location to start from - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Restore the heap condition for the heap's array by "swimming" the object - at a location upward. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine is for "maximum" value heaps. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5HP__swim_max(H5HP_t *heap, size_t loc) -{ - int val; /* Temporary copy value of object to move in heap */ - H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Get copies of the information about the object to move in the heap */ - val = heap->heap[loc].val; - obj = heap->heap[loc].obj; - - /* Move object up in heap until it's reached the maximum location possible */ - while (heap->heap[loc / 2].val < val) { - /* Move object "above" current location in heap down */ - heap->heap[loc].val = heap->heap[loc / 2].val; - heap->heap[loc].obj = heap->heap[loc / 2].obj; - - /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc = loc; - - /* Move to location "above" current location */ - loc = loc / 2; - } /* end while */ - - /* Put object into heap at correct location */ - heap->heap[loc].val = val; - heap->heap[loc].obj = obj; - - /* Update heap location for object */ - heap->heap[loc].obj->heap_loc = loc; - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP__swim_max() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP__swim_min - PURPOSE - Restore heap condition by moving an object upward - USAGE - herr_t H5HP__swim_min(heap, loc) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - size_t loc; IN: Location to start from - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Restore the heap condition for the heap's array by "swimming" the object - at a location upward. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine is for "minimum" value heaps. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5HP__swim_min(H5HP_t *heap, size_t loc) -{ - int val; /* Temporary copy value of object to move in heap */ - H5HP_info_t *obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Get copies of the information about the object to move in the heap */ - val = heap->heap[loc].val; - obj = heap->heap[loc].obj; - - /* Move object up in heap until it's reached the minimum location possible */ - while (heap->heap[loc / 2].val > val) { - /* Move object "above" current location in heap down */ - heap->heap[loc].val = heap->heap[loc / 2].val; - heap->heap[loc].obj = heap->heap[loc / 2].obj; - - /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc = loc; - - /* Move to location "above" current location */ - loc = loc / 2; - } /* end while */ - - /* Put object into heap at correct location */ - heap->heap[loc].val = val; - heap->heap[loc].obj = obj; - - /* Update heap location for object */ - heap->heap[loc].obj->heap_loc = loc; - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP__swim_min() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP__sink_max - PURPOSE - Restore heap condition by moving an object downward - USAGE - herr_t H5HP__sink_max(heap, loc) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - size_t loc; IN: Location to start from - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Restore the heap condition for the heap's array by "sinking" the object - at a location downward. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine is for "maximum" value heaps. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5HP__sink_max(H5HP_t *heap, size_t loc) -{ - int val; /* Temporary copy value of object to move in heap */ - void * obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Get copies of the information about the object to move in the heap */ - val = heap->heap[loc].val; - obj = heap->heap[loc].obj; - - /* Move object up in heap until it's reached the maximum location possible */ - while ((2 * loc) <= heap->nobjs) { - size_t new_loc = loc * 2; /* New object's potential location area */ - - /* Get the greater of the two objects below the location in heap */ - if (new_loc < heap->nobjs && (heap->heap[new_loc].val < heap->heap[new_loc + 1].val)) - new_loc++; - - /* Check if the object is smaller than the larger of the objects below it */ - /* If so, its in the correct location now, and we can get out */ - if (val >= heap->heap[new_loc].val) - break; - - /* Move the greater of the two objects below the current location up */ - heap->heap[loc].val = heap->heap[new_loc].val; - heap->heap[loc].obj = heap->heap[new_loc].obj; - - /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc = loc; - - /* Move to location "below" current location */ - loc = new_loc; - } /* end while */ - - /* Put object into heap at correct location */ - heap->heap[loc].val = val; - heap->heap[loc].obj = (H5HP_info_t *)obj; - - /* Update heap location for object */ - heap->heap[loc].obj->heap_loc = loc; - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP__sink_max() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP__sink_min - PURPOSE - Restore heap condition by moving an object downward - USAGE - herr_t H5HP__sink_min(heap, loc) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - size_t loc; IN: Location to start from - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Restore the heap condition for the heap's array by "sinking" the object - at a location downward. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This routine is for "minimum" value heaps. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5HP__sink_min(H5HP_t *heap, size_t loc) -{ - int val; /* Temporary copy value of object to move in heap */ - void * obj; /* Temporary pointer to object to move in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* Get copies of the information about the object to move in the heap */ - val = heap->heap[loc].val; - obj = heap->heap[loc].obj; - - /* Move object up in heap until it's reached the maximum location possible */ - while ((2 * loc) <= heap->nobjs) { - size_t new_loc = loc * 2; /* New object's potential location area */ - - /* Get the lesser of the two objects below the location in heap */ - if (new_loc < heap->nobjs && (heap->heap[new_loc].val > heap->heap[new_loc + 1].val)) - new_loc++; - - /* Check if the object is greater than the larger of the objects below it */ - /* If so, its in the correct location now, and we can get out */ - if (val <= heap->heap[new_loc].val) - break; - - /* Move the greater of the two objects below the current location up */ - heap->heap[loc].val = heap->heap[new_loc].val; - heap->heap[loc].obj = heap->heap[new_loc].obj; - - /* Update heap location for object which moved */ - heap->heap[loc].obj->heap_loc = loc; - - /* Move to location "below" current location */ - loc = new_loc; - } /* end while */ - - /* Put object into heap at correct location */ - heap->heap[loc].val = val; - heap->heap[loc].obj = (H5HP_info_t *)obj; - - /* Update heap location for object */ - heap->heap[loc].obj->heap_loc = loc; - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP__sink_min() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_create - PURPOSE - Create a heap - USAGE - H5HP_t *H5HP_create(heap_type) - H5HP_type_t heap_type; IN: Type of heap to create - - RETURNS - Returns a pointer to a heap on success, NULL on failure. - DESCRIPTION - Create a priority queue. The SIZE is used to set the initial number of - entries allocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5HP_t * -H5HP_create(H5HP_type_t heap_type) -{ - H5HP_t *new_heap = NULL; /* Pointer to new heap object created */ - H5HP_t *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Check args */ - HDassert(heap_type == H5HP_MIN_HEAP || heap_type == H5HP_MAX_HEAP); - - /* Allocate ref-counted string structure */ - if ((new_heap = H5FL_MALLOC(H5HP_t)) == NULL) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Allocate the array to store the heap entries */ - if ((new_heap->heap = H5FL_SEQ_MALLOC(H5HP_ent_t, (size_t)(H5HP_START_SIZE + 1))) == NULL) - HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed"); - - /* Set the internal fields */ - new_heap->type = heap_type; - new_heap->nobjs = 0; - new_heap->nalloc = H5HP_START_SIZE + 1; - - /* Set the information in the 0'th location based on the type of heap */ - if (heap_type == H5HP_MIN_HEAP) { - /* Set the value in the '0' location to be the minimum value, to - * simplify the algorithms - */ - new_heap->heap[0].val = INT_MIN; - new_heap->heap[0].obj = NULL; - } /* end if */ - else { - /* Set the value in the '0' location to be the maximum value, to - * simplify the algorithms - */ - new_heap->heap[0].val = INT_MAX; - new_heap->heap[0].obj = NULL; - } /* end else */ - - /* Set the return value */ - ret_value = new_heap; - -done: - /* Error cleanup */ - if (NULL == ret_value) { - if (NULL != new_heap) { - if (NULL != new_heap->heap) - new_heap->heap = H5FL_SEQ_FREE(H5HP_ent_t, new_heap->heap); - new_heap = H5FL_FREE(H5HP_t, new_heap); - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_create() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_count - PURPOSE - Check the number of elements in a heap - USAGE - ssize_t H5HP_count(heap) - const H5HP_t *heap; IN: Pointer to heap to query - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Checks the number of elements in heap - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -ssize_t -H5HP_count(const H5HP_t *heap) -{ - ssize_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check args */ - HDassert(heap); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Return the number of objects in the heap */ - H5_CHECK_OVERFLOW(heap->nobjs, size_t, ssize_t); - ret_value = (ssize_t)heap->nobjs; - - /* No post-condition check necessary, since heap is constant */ - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_count() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_insert - PURPOSE - Insert an object into a heap, with an initial value - USAGE - herr_t H5HP_insert(heap, val, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - int val; IN: Initial value for object in heap - void *obj; IN: Pointer to object to insert into heap - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Inserts a OBJ into a HEAP, with an initial VALue. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_insert(H5HP_t *heap, int val, void *obj) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Increment number of objects in heap */ - heap->nobjs++; - - /* Check if we need to allocate more room for heap array */ - if (heap->nobjs >= heap->nalloc) { - size_t n = MAX(H5HP_START_SIZE, 2 * (heap->nalloc - 1)) + 1; - H5HP_ent_t *new_heap = H5FL_SEQ_REALLOC(H5HP_ent_t, heap->heap, n); - - if (!new_heap) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend heap array"); - heap->heap = new_heap; - heap->nalloc = n; - } /* end if */ - - /* Insert new object at end of heap */ - heap->heap[heap->nobjs].val = val; - heap->heap[heap->nobjs].obj = (H5HP_info_t *)obj; - heap->heap[heap->nobjs].obj->heap_loc = heap->nobjs; - - /* Restore heap condition */ - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__swim_max(heap, heap->nobjs) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__swim_min(heap, heap->nobjs) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to restore heap condition"); - } /* end else */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_insert() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_top - PURPOSE - Check the value of the top object in the heap - USAGE - herr_t H5HP_top(heap, val) - const H5HP_t *heap; IN: Pointer to heap to modify - int val; IN/OUT: Initial value for object in heap - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Checks the value of the top object in a heap - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_top(const H5HP_t *heap, int *val) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check args */ - HDassert(heap); - HDassert(val); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Get value of the top object in the heap */ - *val = heap->heap[1].val; - - /* No post-condition check necessary, since heap is constant */ - FUNC_LEAVE_NOAPI(SUCCEED); -} /* end H5HP_top() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_remove - PURPOSE - Remove an object into a heap - USAGE - herr_t H5HP_remove(heap, val, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - int *val; OUT: Pointer to value of object removed from heap - void **obj; OUT: Pointer to object removed from heap - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Removes the top object on a heap, returning its value and object pointer - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_remove(H5HP_t *heap, int *val, void **obj) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(val); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Check if there are any objects on the heap to remove */ - if (heap->nobjs == 0) - HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "heap is empty"); - - /* Get the information for the top object on the heap */ - HDassert(heap->heap[1].obj->heap_loc == 1); - *val = heap->heap[1].val; - *obj = heap->heap[1].obj; - - /* Move the last element in the heap to the top */ - heap->heap[1].val = heap->heap[heap->nobjs].val; - heap->heap[1].obj = heap->heap[heap->nobjs].obj; - heap->heap[1].obj->heap_loc = 1; - - /* Decrement number of objects in heap */ - heap->nobjs--; - - /* Restore heap condition, if there are objects on the heap */ - if (heap->nobjs > 0) { - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__sink_max(heap, (size_t)1) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__sink_min(heap, (size_t)1) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to restore heap condition"); - } /* end else */ - } /* end if */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_remove() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_change - PURPOSE - Change the priority of an object on a heap - USAGE - herr_t H5HP_change(heap, val, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - int val; IN: New priority value for object - void *obj; IN: Pointer to object to modify - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Changes the priority of an object on a heap. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_change(H5HP_t *heap, int val, void *_obj) -{ - H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - int old_val; /* Object's old priority value */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Get the location of the object in the heap */ - obj_loc = obj->heap_loc; - HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); - - /* Change the heap object's priority */ - old_val = heap->heap[obj_loc].val; - heap->heap[obj_loc].val = val; - - /* Restore heap condition */ - if (val < old_val) { - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__sink_max(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__swim_min(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end else */ - } /* end if */ - else { - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__swim_max(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__sink_min(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end else */ - } /* end else */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_change() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_incr - PURPOSE - Increment the priority of an object on a heap - USAGE - herr_t H5HP_incr(heap, amt, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - unsigned amt; IN: Amount to increase priority by - void *obj; IN: Pointer to object to modify - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Increments the priority of an object on a heap by one. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_incr(H5HP_t *heap, unsigned amt, void *_obj) -{ - H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Get the location of the object in the heap */ - obj_loc = obj->heap_loc; - HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); - - /* Change the heap object's priority */ - heap->heap[obj_loc].val += (int)amt; - - /* Restore heap condition */ - if (H5HP_MAX_HEAP == heap->type) { - if (H5HP__swim_max(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") - } /* end if */ - else { - if (H5HP__sink_min(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition") - } /* end else */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_incr() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_decr - PURPOSE - Decrement the priority of an object on a heap - USAGE - herr_t H5HP_dec(heap, amt, obj) - H5HP_t *heap; IN/OUT: Pointer to heap to modify - unsigned amt; IN: Amount to decrease priority by - void *obj; IN: Pointer to object to modify - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Decrements the priority of an object on a heap by one. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_decr(H5HP_t *heap, unsigned amt, void *_obj) -{ - H5HP_info_t *obj = (H5HP_info_t *)_obj; /* Alias for object */ - size_t obj_loc; /* Location of object in heap */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(heap); - HDassert(obj); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - /* Get the location of the object in the heap */ - obj_loc = obj->heap_loc; - HDassert(obj_loc > 0 && obj_loc <= heap->nobjs); - - /* Change the heap object's priority */ - H5_CHECK_OVERFLOW(amt, unsigned, int); - heap->heap[obj_loc].val -= (int)amt; - - /* Restore heap condition */ - if (heap->type == H5HP_MAX_HEAP) { - if (H5HP__sink_max(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end if */ - else { - if (H5HP__swim_min(heap, obj_loc) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTRESTORE, FAIL, "unable to restore heap condition"); - } /* end else */ - -done: - - /* Check internal consistency */ - /* (Post-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(heap->heap[0].obj == NULL); - - FUNC_LEAVE_NOAPI(ret_value); -} /* end H5HP_decr() */ - -/*-------------------------------------------------------------------------- - NAME - H5HP_close - PURPOSE - Close a heap, deallocating it. - USAGE - herr_t H5HP_close(heap) - H5HP_t *heap; IN/OUT: Pointer to heap to close - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Close a heap, freeing all internal information. Any objects left in - the heap are not deallocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5HP_close(H5HP_t *heap) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check args */ - HDassert(heap); - - /* Check internal consistency */ - /* (Pre-condition) */ - HDassert(heap->nobjs < heap->nalloc); - HDassert(heap->heap); - HDassert((heap->type == H5HP_MAX_HEAP && heap->heap[0].val == INT_MAX) || - (heap->type == H5HP_MIN_HEAP && heap->heap[0].val == INT_MIN)); - HDassert(NULL == heap->heap[0].obj); - - /* Free internal structures for heap */ - heap->heap = H5FL_SEQ_FREE(H5HP_ent_t, heap->heap); - - /* Free actual heap object */ - heap = H5FL_FREE(H5HP_t, heap); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5HP_close() */ diff --git a/src/H5HPprivate.h b/src/H5HPprivate.h deleted file mode 100644 index 50020bc0d6d..00000000000 --- a/src/H5HPprivate.h +++ /dev/null @@ -1,68 +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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * This file contains private information about the H5HP module - */ -#ifndef H5HPprivate_H -#define H5HPprivate_H - -/**************************************/ -/* Public headers needed by this file */ -/**************************************/ -#ifdef LATER -#include "H5HPpublic.h" -#endif /* LATER */ - -/***************************************/ -/* Private headers needed by this file */ -/***************************************/ -#include "H5private.h" - -/************/ -/* Typedefs */ -/************/ - -/* Typedef for heap struct (defined in H5HP.c) */ -typedef struct H5HP_t H5HP_t; - -/* Typedef for objects which can be inserted into heaps */ -/* This _must_ be the first field in objects which can be inserted into heaps */ -typedef struct H5HP_info_t { - size_t heap_loc; /* Location of object in heap */ -} H5HP_info_t; - -/* Typedef for type of heap to create */ -typedef enum { - H5HP_MIN_HEAP, /* Minimum values in heap are at the "top" */ - H5HP_MAX_HEAP /* Maximum values in heap are at the "top" */ -} H5HP_type_t; - -/**********/ -/* Macros */ -/**********/ - -/********************/ -/* Private routines */ -/********************/ -H5_DLL H5HP_t *H5HP_create(H5HP_type_t heap_type); -H5_DLL herr_t H5HP_insert(H5HP_t *heap, int val, void *obj); -H5_DLL ssize_t H5HP_count(const H5HP_t *heap); -H5_DLL herr_t H5HP_top(const H5HP_t *heap, int *val); -H5_DLL herr_t H5HP_remove(H5HP_t *heap, int *val, void **ptr); -H5_DLL herr_t H5HP_change(H5HP_t *heap, int val, void *obj); -H5_DLL herr_t H5HP_incr(H5HP_t *heap, unsigned amt, void *obj); -H5_DLL herr_t H5HP_decr(H5HP_t *heap, unsigned amt, void *obj); -H5_DLL herr_t H5HP_close(H5HP_t *heap); - -#endif /* H5HPprivate_H */ diff --git a/src/H5I.c b/src/H5I.c index efb4fd5ba11..967122c1007 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -41,13 +40,13 @@ typedef struct { H5I_search_func_t app_cb; /* Application's callback routine */ - void * app_key; /* Application's "key" (user data) */ - void * ret_obj; /* Object to return */ + void *app_key; /* Application's "key" (user data) */ + void *ret_obj; /* Object to return */ } H5I_search_ud_t; typedef struct { H5I_iterate_func_t op; /* Application's callback routine */ - void * op_data; /* Application's user data */ + void *op_data; /* Application's user data */ } H5I_iterate_pub_ud_t; /********************/ @@ -711,7 +710,7 @@ void * H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) { H5I_search_ud_t udata; /* Context for iteration */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE3("*x", "Itx*x", type, func, key); @@ -779,7 +778,7 @@ H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata) /*------------------------------------------------------------------------- * Function: H5Iiterate * - * Purpose: Call the callback funciton op for each member of the id + * Purpose: Call the callback function op for each member of the id * type type. op takes as parameters the id and a * passthrough of op_data, and returns an herr_t. A positive * return from op will cause the iteration to stop and @@ -890,7 +889,7 @@ H5Iget_file_id(hid_t obj_id) ssize_t H5Iget_name(hid_t id, char *name /*out*/, size_t size) { - H5VL_object_t * vol_obj = NULL; /* Object stored in ID */ + H5VL_object_t *vol_obj = NULL; /* Object stored in ID */ H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ diff --git a/src/H5Idbg.c b/src/H5Idbg.c index 71937e85de5..0bb5718158c 100644 --- a/src/H5Idbg.c +++ b/src/H5Idbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -75,10 +74,10 @@ static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); static int H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t * info = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_id_info_t *info = (H5I_id_info_t *)_item; /* Pointer to the ID node */ H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ const H5G_name_t *path = NULL; /* Path to file object */ - const void * object = NULL; /* Pointer to VOL connector object */ + void *object = NULL; /* Pointer to VOL connector object */ FUNC_ENTER_STATIC_NOERR @@ -94,7 +93,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) object = H5VL_object_data(vol_obj); if (H5_VOL_NATIVE == vol_obj->connector->cls->value) - path = H5G_nameof((const H5G_t *)object); + path = H5G_nameof(object); break; } @@ -103,7 +102,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) object = H5VL_object_data(vol_obj); if (H5_VOL_NATIVE == vol_obj->connector->cls->value) - path = H5D_nameof((const H5D_t *)object); + path = H5D_nameof(object); break; } @@ -111,10 +110,10 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) const H5T_t *dt = (const H5T_t *)info->object; H5_GCC_DIAG_OFF("cast-qual") - object = (void *)H5T_get_actual_type((H5T_t *)dt); /* Casting away const OK - QAK */ + object = (void *)H5T_get_actual_type((H5T_t *)dt); H5_GCC_DIAG_ON("cast-qual") - path = H5T_nameof((const H5T_t *)object); + path = H5T_nameof(object); break; } diff --git a/src/H5Iint.c b/src/H5Iint.c index e512d4b613c..ece8f62fa4c 100644 --- a/src/H5Iint.c +++ b/src/H5Iint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -53,7 +52,7 @@ typedef struct { /* User data for iterator callback for ID iteration */ typedef struct { H5I_search_func_t user_func; /* 'User' function to invoke */ - void * user_udata; /* User data to pass to 'user' function */ + void *user_udata; /* User data to pass to 'user' function */ hbool_t app_ref; /* Whether this is an appl. ref. call */ H5I_type_t obj_type; /* Type of object we are iterating over */ } H5I_iterate_ud_t; @@ -73,9 +72,9 @@ typedef struct { /* Local Prototypes */ /********************/ -static void * H5I__unwrap(void *object, H5I_type_t type); +static void *H5I__unwrap(void *object, H5I_type_t type); static herr_t H5I__mark_node(void *_id, void *key, void *udata); -static void * H5I__remove_common(H5I_type_info_t *type_info, hid_t id); +static void *H5I__remove_common(H5I_type_info_t *type_info, hid_t id); static int H5I__find_id_cb(void *_item, void *_key, void *_udata); /*********************/ @@ -306,8 +305,8 @@ herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) { H5I_clear_type_ud_t udata; /* udata struct for callback */ - H5I_id_info_t * item = NULL; - H5I_id_info_t * tmp = NULL; + H5I_id_info_t *item = NULL; + H5I_id_info_t *tmp = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -372,7 +371,7 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) static herr_t H5I__mark_node(void *_info, void H5_ATTR_UNUSED *key, void *_udata) { - H5I_id_info_t * info = (H5I_id_info_t *)_info; /* Current ID info being worked with */ + H5I_id_info_t *info = (H5I_id_info_t *)_info; /* Current ID info being worked with */ H5I_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ hbool_t mark = FALSE; @@ -497,7 +496,7 @@ hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) { H5I_type_info_t *type_info = NULL; /* Pointer to the type */ - H5I_id_info_t * info = NULL; /* Pointer to the new ID information */ + H5I_id_info_t *info = NULL; /* Pointer to the new ID information */ hid_t new_id = H5I_INVALID_HID; /* New ID */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -560,7 +559,7 @@ herr_t H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, hid_t existing_id) { H5I_type_info_t *type_info = NULL; /* Pointer to the type */ - H5I_id_info_t * info = NULL; /* Pointer to the new ID information */ + H5I_id_info_t *info = NULL; /* Pointer to the new ID information */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -626,7 +625,7 @@ void * H5I_subst(hid_t id, const void *new_object) { H5I_id_info_t *info = NULL; /* Pointer to the ID's info */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -636,7 +635,7 @@ H5I_subst(hid_t id, const void *new_object) /* Get the old object pointer to return */ H5_GCC_DIAG_OFF("cast-qual") - ret_value = (void *)info->object; /* (Casting away const OK -QAK) */ + ret_value = (void *)info->object; H5_GCC_DIAG_ON("cast-qual") /* Set the new object pointer for the ID */ @@ -662,7 +661,7 @@ void * H5I_object(hid_t id) { H5I_id_info_t *info = NULL; /* Pointer to the ID info */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -670,7 +669,7 @@ H5I_object(hid_t id) if (NULL != (info = H5I__find_id(id))) { /* Get the object pointer to return */ H5_GCC_DIAG_OFF("cast-qual") - ret_value = (void *)info->object; /* (Casting away const OK -QAK) */ + ret_value = (void *)info->object; H5_GCC_DIAG_ON("cast-qual") } @@ -696,7 +695,7 @@ void * H5I_object_verify(hid_t id, H5I_type_t type) { H5I_id_info_t *info = NULL; /* Pointer to the ID info */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR @@ -706,7 +705,7 @@ H5I_object_verify(hid_t id, H5I_type_t type) if (type == H5I_TYPE(id) && NULL != (info = H5I__find_id(id))) { /* Get the object pointer to return */ H5_GCC_DIAG_OFF("cast-qual") - ret_value = (void *)info->object; /* (Casting away const OK -QAK) */ + ret_value = (void *)info->object; H5_GCC_DIAG_ON("cast-qual") } @@ -815,7 +814,7 @@ H5I__remove_verify(hid_t id, H5I_type_t type) { void *ret_value = NULL; /*return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Argument checking will be performed by H5I_remove() */ @@ -845,7 +844,7 @@ static void * H5I__remove_common(H5I_type_info_t *type_info, hid_t id) { H5I_id_info_t *info = NULL; /* Pointer to the current ID */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -869,7 +868,7 @@ H5I__remove_common(H5I_type_info_t *type_info, hid_t id) type_info->last_id_info = NULL; H5_GCC_DIAG_OFF("cast-qual") - ret_value = (void *)info->object; /* (Casting away const OK -QAK) */ + ret_value = (void *)info->object; H5_GCC_DIAG_ON("cast-qual") if (!H5I_marking_g) @@ -899,7 +898,7 @@ H5I_remove(hid_t id) { H5I_type_info_t *type_info = NULL; /* Pointer to the ID type */ H5I_type_t type = H5I_BADID; /* ID's type */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1163,7 +1162,7 @@ H5I__inc_type_ref(H5I_type_t type) H5I_type_info_t *type_info = NULL; /* Pointer to the type */ int ret_value = -1; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(type > 0 && (int)type < H5I_next_type_g); @@ -1249,7 +1248,7 @@ H5I__get_type_ref(H5I_type_t type) H5I_type_info_t *type_info = NULL; /* Pointer to the type */ int ret_value = -1; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(type >= 0); @@ -1281,7 +1280,7 @@ H5I__get_type_ref(H5I_type_t type) static int H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t * info = (H5I_id_info_t *)_item; /* Pointer to the ID info */ + H5I_id_info_t *info = (H5I_id_info_t *)_item; /* Pointer to the ID info */ H5I_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ int ret_value = H5_ITER_CONT; /* Callback return value */ @@ -1292,7 +1291,7 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) */ if ((!udata->app_ref) || (info->app_count > 0)) { H5I_type_t type = udata->obj_type; - void * object; + void *object; herr_t cb_ret_val; /* The stored object pointer might be an H5VL_object_t, in which @@ -1356,8 +1355,8 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re /* Only iterate through ID list if it is initialized and there are IDs in type */ if (type_info && type_info->init_count > 0 && type_info->id_count > 0) { H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ - H5I_id_info_t * item = NULL; - H5I_id_info_t * tmp = NULL; + H5I_id_info_t *item = NULL; + H5I_id_info_t *tmp = NULL; /* Set up iterator user data */ iter_udata.user_func = func; @@ -1399,8 +1398,8 @@ H5I__find_id(hid_t id) { H5I_type_t type; /* ID's type */ H5I_type_info_t *type_info = NULL; /* Pointer to the type */ - H5I_id_info_t * id_info = NULL; /* ID's info */ - H5I_id_info_t * ret_value = NULL; /* Return value */ + H5I_id_info_t *id_info = NULL; /* ID's info */ + H5I_id_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -1442,10 +1441,10 @@ H5I__find_id(hid_t id) static int H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t * info = (H5I_id_info_t *)_item; /* Pointer to the ID info */ + H5I_id_info_t *info = (H5I_id_info_t *)_item; /* Pointer to the ID info */ H5I_get_id_ud_t *udata = (H5I_get_id_ud_t *)_udata; /* Pointer to user data */ H5I_type_t type = udata->obj_type; - const void * object = NULL; + const void *object = NULL; int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1498,8 +1497,8 @@ H5I_find_id(const void *object, H5I_type_t type, hid_t *id) /* Only iterate through ID list if it is initialized and there are IDs in type */ if (type_info->init_count > 0 && type_info->id_count > 0) { H5I_get_id_ud_t udata; /* User data */ - H5I_id_info_t * item = NULL; - H5I_id_info_t * tmp = NULL; + H5I_id_info_t *item = NULL; + H5I_id_info_t *tmp = NULL; /* Set up iterator user data */ udata.object = object; diff --git a/src/H5Imodule.h b/src/H5Imodule.h index a2174d735d0..71b8f7d055a 100644 --- a/src/H5Imodule.h +++ b/src/H5Imodule.h @@ -29,9 +29,91 @@ #define H5_MY_PKG_ERR H5E_ATOM #define H5_MY_PKG_INIT NO -/**\defgroup H5I H5I - * \brief Identifier Interface - * \todo Describe concisely what the functions in this module are about. +/** \page H5I_UG The HDF5 Identifiers + * @todo Under Construction + */ + +/** + * \defgroup H5I Identifiers (H5I) + * + * Use the functions in this module to manage identifiers defined by the HDF5 + * library. See \ref H5IUD for user-defined identifiers and identifier + * types. + * + * HDF5 identifiers are usually created as a side-effect of creating HDF5 + * entities such as groups, datasets, attributes, or property lists. + * + * Identifiers defined by the HDF5 library can be used to retrieve information + * such as path names and reference counts, and their validity can be checked. + * + * Identifiers can be updated by manipulating their reference counts. + * + * Unused identifiers should be reclaimed by closing the associated item, e.g., + * HDF5 object, or decrementing the reference count to 0. + * + * \note Identifiers (of type \ref hid_t) are run-time auxiliaries and + * not persisted in the file. + * + * + * + * + * + * + * + * + * + * + * + *
CreateRead
+ * \snippet{lineno} H5I_examples.c create + * + * \snippet{lineno} H5I_examples.c read + *
UpdateDelete
+ * \snippet{lineno} H5I_examples.c update + * + * \snippet{lineno} H5I_examples.c delete + *
+ * + * \defgroup H5IUD User-defined ID Types + * \ingroup H5I + * + * The \ref H5I module contains functions to define new identifier types. + * For convenience, handles of type \ref hid_t can then be associated with the + * new identifier types and user objects. + * + * New identifier types can be created by registering a new identifier type + * with the HDF5 library. Once a new identifier type has bee registered, + * it can be used to generate identifiers for user objects. + * + * User-defined identifier types can be searched and iterated. + * + * Like library-defined identifiers, user-defined identifiers \Emph{and} + * identifier types are reference counted, and the reference counts can be + * manipulated accordingly. + * + * User-defined identifiers no longer in use should be deleted or reclaimed, + * and identifier types should be destroyed if they are no longer required. + * + * + * + * + * + * + * + * + * + * + * + *
CreateRead
+ * \snippet{lineno} H5I_examples.c create_ud + * + * \snippet{lineno} H5I_examples.c read_ud + *
UpdateDelete
+ * \snippet{lineno} H5I_examples.c update_ud + * + * \snippet{lineno} H5I_examples.c delete_ud + *
+ * */ #endif /* H5Imodule_H */ diff --git a/src/H5Ipkg.h b/src/H5Ipkg.h index 1bcea26cb51..24879c1917e 100644 --- a/src/H5Ipkg.h +++ b/src/H5Ipkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -29,15 +28,6 @@ /* Get package's private header */ #include "H5Iprivate.h" -/* uthash is an external, header-only hash table implementation. - * - * We include the file directly in src/ and #define a few functions - * to use our internal memory calls. - */ -#define uthash_malloc(sz) H5MM_malloc(sz) -#define uthash_free(ptr, sz) H5MM_free(ptr) /* Ignoring sz is intentional */ -#include "uthash.h" - /**************************/ /* Package Private Macros */ /**************************/ @@ -85,8 +75,8 @@ typedef struct H5I_type_info_t { unsigned init_count; /* # of times this type has been initialized */ uint64_t id_count; /* Current number of IDs held */ uint64_t nextid; /* ID to use for the next object */ - H5I_id_info_t * last_id_info; /* Info for most recent ID looked up */ - H5I_id_info_t * hash_table; /* Hash table pointer for this ID type */ + H5I_id_info_t *last_id_info; /* Info for most recent ID looked up */ + H5I_id_info_t *hash_table; /* Hash table pointer for this ID type */ } H5I_type_info_t; /*****************************/ @@ -109,10 +99,10 @@ H5_DLLVAR int H5I_next_type_g; /* Package Private Prototypes */ /******************************/ -H5_DLL int H5I__destroy_type(H5I_type_t type); -H5_DLL void *H5I__remove_verify(hid_t id, H5I_type_t type); -H5_DLL int H5I__inc_type_ref(H5I_type_t type); -H5_DLL int H5I__get_type_ref(H5I_type_t type); +H5_DLL int H5I__destroy_type(H5I_type_t type); +H5_DLL void *H5I__remove_verify(hid_t id, H5I_type_t type); +H5_DLL int H5I__inc_type_ref(H5I_type_t type); +H5_DLL int H5I__get_type_ref(H5I_type_t type); H5_DLL H5I_id_info_t *H5I__find_id(hid_t id); /* Testing functions */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index dd7485d95e4..be2e4fe04e9 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -85,10 +84,10 @@ H5_DLL herr_t H5I_find_id(const void *object, H5I_type_t type, hid_t *id /*o */ /* Functions that manipulate objects */ -H5_DLL void * H5I_object(hid_t id); -H5_DLL void * H5I_object_verify(hid_t id, H5I_type_t type); -H5_DLL void * H5I_remove(hid_t id); -H5_DLL void * H5I_subst(hid_t id, const void *new_object); +H5_DLL void *H5I_object(hid_t id); +H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t type); +H5_DLL void *H5I_remove(hid_t id); +H5_DLL void *H5I_subst(hid_t id, const void *new_object); H5_DLL htri_t H5I_is_file_object(hid_t id); /* ID registration functions */ diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 6442a0df628..b9697361c91 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -105,7 +104,7 @@ extern "C" { /* Public API functions */ /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Registers an object under a type and returns an ID for it * @@ -127,7 +126,7 @@ extern "C" { */ H5_DLL hid_t H5Iregister(H5I_type_t type, const void *object); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Returns the object referenced by an ID * @@ -150,7 +149,7 @@ H5_DLL hid_t H5Iregister(H5I_type_t type, const void *object); */ H5_DLL void *H5Iobject_verify(hid_t id, H5I_type_t type); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Removes an ID from its type * @@ -189,12 +188,7 @@ H5_DLL void *H5Iremove_verify(hid_t id, H5I_type_t type); * \return Returns the object type if successful; otherwise #H5I_BADID. * * \details H5Iget_type() retrieves the type of the object identified by - * \p id. - * - * Valid types returned by the function are: - * \id_types - * - * If no valid type can be determined or the identifier submitted is + * \p id. If no valid type can be determined or the identifier submitted is * invalid, the function returns #H5I_BADID. * * This function is of particular use in determining the type of @@ -390,7 +384,7 @@ H5_DLL int H5Idec_ref(hid_t id); */ H5_DLL int H5Iget_ref(hid_t id); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Creates and returns a new ID type * @@ -422,7 +416,7 @@ H5_DLL int H5Iget_ref(hid_t id); */ H5_DLL H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Deletes all identifiers of the given type * @@ -446,7 +440,7 @@ H5_DLL H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free */ H5_DLL herr_t H5Iclear_type(H5I_type_t type, hbool_t force); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Removes an identifier type and all identifiers within that type * @@ -469,7 +463,7 @@ H5_DLL herr_t H5Iclear_type(H5I_type_t type, hbool_t force); */ H5_DLL herr_t H5Idestroy_type(H5I_type_t type); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Increments the reference count on an ID type * @@ -488,7 +482,7 @@ H5_DLL herr_t H5Idestroy_type(H5I_type_t type); */ H5_DLL int H5Iinc_type_ref(H5I_type_t type); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Decrements the reference count on an identifier type * @@ -508,11 +502,11 @@ H5_DLL int H5Iinc_type_ref(H5I_type_t type); */ H5_DLL int H5Idec_type_ref(H5I_type_t type); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Retrieves the reference count on an ID type * - * \param[in] type The identifier of the type whose reference count is to be retieved + * \param[in] type The identifier of the type whose reference count is to be retrieved * * \return Returns the current reference count on success, negative on failure. * @@ -527,7 +521,7 @@ H5_DLL int H5Idec_type_ref(H5I_type_t type); */ H5_DLL int H5Iget_type_ref(H5I_type_t type); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Finds the memory referred to by an ID within the given ID type such * that some criterion is satisfied @@ -568,7 +562,7 @@ H5_DLL int H5Iget_type_ref(H5I_type_t type); */ H5_DLL void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Calls a callback for each member of the identifier type specified * @@ -597,7 +591,7 @@ H5_DLL void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); */ H5_DLL herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Returns the number of identifiers in a given identifier type * @@ -617,7 +611,7 @@ H5_DLL herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); */ H5_DLL herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members); /** - * \ingroup H5I + * \ingroup H5IUD * * \brief Determines whether an identifier type is registered * diff --git a/src/H5Itest.c b/src/H5Itest.c index 7f4ca7ad447..6cdce7dc76c 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5L.c b/src/H5L.c index b7f27524954..9435b393ac3 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -52,16 +51,16 @@ typedef struct { /* User data for path traversal callback to creating a link */ typedef struct { - H5F_t * file; /* Pointer to the file */ - H5P_genplist_t * lc_plist; /* Link creation property list */ - H5G_name_t * path; /* Path to object being linked */ + H5F_t *file; /* Pointer to the file */ + H5P_genplist_t *lc_plist; /* Link creation property list */ + H5G_name_t *path; /* Path to object being linked */ H5O_obj_create_t *ocrt_info; /* Pointer to object creation info */ - H5O_link_t * lnk; /* Pointer to link information to insert */ + H5O_link_t *lnk; /* Pointer to link information to insert */ } H5L_trav_cr_t; /* User data for path traversal routine for moving and renaming a link */ typedef struct { - const char * dst_name; /* Destination name for moving object */ + const char *dst_name; /* Destination name for moving object */ H5T_cset_t cset; /* Char set for new name */ const H5G_loc_t *dst_loc; /* Destination location for moving object */ unsigned dst_target_flags; /* Target flags for destination object */ @@ -71,7 +70,7 @@ typedef struct { /* User data for path traversal routine for moving and renaming an object */ typedef struct { - H5F_t * file; /* Pointer to the file */ + H5F_t *file; /* Pointer to the file */ H5O_link_t *lnk; /* Pointer to link information to insert */ hbool_t copy; /* TRUE if this is a copy operation */ } H5L_trav_mv2_t; @@ -88,7 +87,7 @@ typedef struct { /* User data for path traversal routine for getting link value */ typedef struct { size_t size; /* Size of user buffer */ - void * buf; /* User buffer */ + void *buf; /* User buffer */ } H5L_trav_gv_t; /********************/ @@ -259,9 +258,9 @@ herr_t H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj1 = NULL; /* Object of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t * vol_obj2 = NULL; /* Object of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params2; H5VL_object_t tmp_vol_obj; /* Temporary object */ herr_t ret_value = SUCCEED; /* Return value */ @@ -349,9 +348,9 @@ herr_t H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj1 = NULL; /* Object of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t * vol_obj2 = NULL; /* Object of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object of dst_id */ H5VL_loc_params_t loc_params2; H5VL_object_t tmp_vol_obj; /* Temporary object */ herr_t ret_value = SUCCEED; /* Return value */ @@ -443,7 +442,7 @@ herr_t H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -514,8 +513,8 @@ herr_t H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj1 = NULL; /* Object of cur_loc_id */ - H5VL_object_t * vol_obj2 = NULL; /* Object of new_loc_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object of cur_loc_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object of new_loc_id */ H5VL_object_t tmp_vol_obj; /* Temporary object */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; @@ -617,7 +616,7 @@ herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -681,7 +680,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, con herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -738,7 +737,7 @@ herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -800,7 +799,7 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_i herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -855,7 +854,7 @@ herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -910,7 +909,7 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_ htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; htri_t ret_value = FAIL; /* Return value */ @@ -962,7 +961,7 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) herr_t H5Lget_info2(hid_t loc_id, const char *name, H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1013,7 +1012,7 @@ herr_t H5Lget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info2_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -1210,7 +1209,7 @@ ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ @@ -1273,7 +1272,7 @@ herr_t H5Literate2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate2_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ herr_t ret_value; /* Return value */ @@ -1336,7 +1335,7 @@ herr_t H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -1409,7 +1408,7 @@ H5Literate_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H herr_t H5Lvisit2(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ herr_t ret_value; /* Return value */ @@ -1477,7 +1476,7 @@ herr_t H5Lvisit_by_name2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate2_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -1787,7 +1786,7 @@ H5L__link_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5_AT H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { H5L_trav_cr_t *udata = (H5L_trav_cr_t *)_udata; /* User data passed in */ - H5G_t * grp = NULL; /* H5G_t for this group, opened to pass to user callback */ + H5G_t *grp = NULL; /* H5G_t for this group, opened to pass to user callback */ hid_t grp_id = FAIL; /* Id for this group (passed to user callback */ H5G_loc_t temp_loc; /* For UD callback */ hbool_t temp_loc_init = FALSE; /* Temporary location for UD callback (temp_loc) has been initialized */ @@ -1952,7 +1951,7 @@ static herr_t H5L__create_real(const H5G_loc_t *link_loc, const char *link_name, H5G_name_t *obj_path, H5F_t *obj_file, H5O_link_t *lnk, H5O_obj_create_t *ocrt_info, hid_t lcpl_id) { - char * norm_link_name = NULL; /* Pointer to normalized link name */ + char *norm_link_name = NULL; /* Pointer to normalized link name */ unsigned target_flags = H5G_TARGET_NORMAL; /* Flags to pass to group traversal function */ H5P_genplist_t *lc_plist = NULL; /* Link creation property list */ H5L_trav_cr_t udata; /* User data for callback */ @@ -2032,8 +2031,8 @@ herr_t H5L__create_hard(H5G_loc_t *cur_loc, const char *cur_name, const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id) { - char * norm_cur_name = NULL; /* Pointer to normalized current name */ - H5F_t * link_file = NULL; /* Pointer to file to link to */ + char *norm_cur_name = NULL; /* Pointer to normalized current name */ + H5F_t *link_file = NULL; /* Pointer to file to link to */ H5O_link_t lnk; /* Link to insert */ H5G_loc_t obj_loc; /* Location of object to link to */ H5G_name_t path; /* obj_loc's path*/ @@ -2103,7 +2102,7 @@ H5L__create_hard(H5G_loc_t *cur_loc, const char *cur_name, const H5G_loc_t *link herr_t H5L__create_soft(const char *target_path, const H5G_loc_t *link_loc, const char *link_name, hid_t lcpl_id) { - char * norm_target = NULL; /* Pointer to normalized current name */ + char *norm_target = NULL; /* Pointer to normalized current name */ H5O_link_t lnk; /* Link to insert */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2481,7 +2480,7 @@ H5L__delete_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *ln herr_t H5L__delete(const H5G_loc_t *loc, const char *name) { - char * norm_name = NULL; /* Pointer to normalized name */ + char *norm_name = NULL; /* Pointer to normalized name */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2605,7 +2604,7 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H5G_loc_t *obj_loc, void *_udata /*in,out*/, H5G_own_loc_t *own_loc /*out*/) { H5L_trav_mv2_t *udata = (H5L_trav_mv2_t *)_udata; /* User data passed in */ - H5G_t * grp = NULL; /* H5G_t for this group, opened to pass to user callback */ + H5G_t *grp = NULL; /* H5G_t for this group, opened to pass to user callback */ hid_t grp_id = FAIL; /* ID for this group (passed to user callback */ H5G_loc_t temp_loc; /* For UD callback */ hbool_t temp_loc_init = FALSE; @@ -2718,7 +2717,7 @@ H5L__move_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t *lnk, { H5L_trav_mv_t *udata = (H5L_trav_mv_t *)_udata; /* User data passed in */ H5L_trav_mv2_t udata_out; /* User data for H5L__move_dest_cb traversal */ - char * orig_name = NULL; /* The name of the link in this group */ + char *orig_name = NULL; /* The name of the link in this group */ hbool_t link_copied = FALSE; /* Has udata_out.lnk been allocated? */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2951,8 +2950,8 @@ H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATT if (lnk != NULL) { /* Check for more components to the path */ if (udata->sep) { - H5G_traverse_t cb_func; /* Callback function for tranversal */ - char * next; /* Pointer to next component name */ + H5G_traverse_t cb_func; /* Callback function for traversal */ + char *next; /* Pointer to next component name */ /* Look for another separator */ next = udata->sep; @@ -3002,9 +3001,9 @@ htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name) { H5L_trav_le_t udata; /* User data for traversal */ - H5G_traverse_t cb_func; /* Callback function for tranversal */ - char * name_copy = NULL; /* Duplicate of name */ - char * name_trav; /* Name to traverse */ + H5G_traverse_t cb_func; /* Callback function for traversal */ + char *name_copy = NULL; /* Duplicate of name */ + char *name_trav; /* Name to traverse */ htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Ldeprec.c b/src/H5Ldeprec.c index 3568696399f..3690258e33f 100644 --- a/src/H5Ldeprec.c +++ b/src/H5Ldeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -51,7 +50,7 @@ /* Shim data for using native H5Literate/visit callbacks with the VOL */ typedef struct H5L_shim_data_t { H5L_iterate1_t real_op; - void * real_op_data; + void *real_op_data; } H5L_shim_data_t; /********************/ @@ -141,7 +140,7 @@ herr_t H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate1_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ H5L_shim_data_t shim_data; @@ -219,7 +218,7 @@ herr_t H5Literate_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5L_shim_data_t shim_data; hbool_t is_native_vol_obj; @@ -293,7 +292,7 @@ H5Literate_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H herr_t H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; H5L_info2_t linfo2; /* New-style link info */ hbool_t is_native_vol_obj; @@ -376,7 +375,7 @@ herr_t H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info1_t *linfo /*out*/, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; H5L_info2_t linfo2; /* New-style link info */ hbool_t is_native_vol_obj; @@ -479,7 +478,7 @@ H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H herr_t H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ H5L_shim_data_t shim_data; @@ -563,7 +562,7 @@ herr_t H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5L_shim_data_t shim_data; hbool_t is_native_vol_obj; diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 22d100e555c..302a6917ba2 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -107,25 +106,25 @@ static hid_t H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const void *_udata, size_t H5_ATTR_UNUSED udata_size, hid_t lapl_id, hid_t H5_ATTR_UNUSED dxpl_id) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5G_loc_t root_loc; /* Location of root group in external file */ H5G_loc_t loc; /* Location of object */ - H5F_t * ext_file = NULL; /* File struct for external file */ - const uint8_t * p = (const uint8_t *)_udata; /* Pointer into external link buffer */ - const char * file_name; /* Name of file containing external link's object */ - const char * obj_name; /* Name external link's object */ + H5F_t *ext_file = NULL; /* File struct for external file */ + const uint8_t *p = (const uint8_t *)_udata; /* Pointer into external link buffer */ + const char *file_name; /* Name of file containing external link's object */ + const char *obj_name; /* Name external link's object */ size_t fname_len; /* Length of external link file name */ unsigned intent; /* File access permissions */ H5L_elink_cb_t cb_info; /* Callback info struct */ hid_t fapl_id = H5I_INVALID_HID; /* File access property list for external link's file */ - void * ext_obj = NULL; /* External link's object */ + void *ext_obj = NULL; /* External link's object */ hid_t ext_obj_id = H5I_INVALID_HID; /* ID for external link's object */ H5I_type_t opened_type; /* ID type of external link's object */ - char * parent_group_name = NULL; /* Temporary pointer to group name */ + char *parent_group_name = NULL; /* Temporary pointer to group name */ char local_group_name[H5L_EXT_TRAVERSE_BUF_SIZE]; /* Local buffer to hold group name */ - H5P_genplist_t * fa_plist; /* File access property list pointer */ + H5P_genplist_t *fa_plist; /* File access property list pointer */ H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */ - char * elink_prefix = NULL; /* Pointer to elink prefix */ + char *elink_prefix = NULL; /* Pointer to elink prefix */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC @@ -337,14 +336,14 @@ herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; - char * norm_obj_name = NULL; /* Pointer to normalized current name */ - void * ext_link_buf = NULL; /* Buffer to contain external link */ + char *norm_obj_name = NULL; /* Pointer to normalized current name */ + void *ext_link_buf = NULL; /* Buffer to contain external link */ size_t buf_size; /* Size of buffer to hold external link */ size_t file_name_len; /* Length of file name string */ size_t norm_obj_name_len; /* Length of normalized object name string */ - uint8_t * p; /* Pointer into external link buffer */ + uint8_t *p; /* Pointer into external link buffer */ H5L_type_t link_type = H5L_TYPE_EXTERNAL; herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Lmodule.h b/src/H5Lmodule.h index 54b94a4c43a..f373ba1fe02 100644 --- a/src/H5Lmodule.h +++ b/src/H5Lmodule.h @@ -29,12 +29,40 @@ #define H5_MY_PKG_ERR H5E_LINK #define H5_MY_PKG_INIT YES -/**\defgroup H5L H5L - * \brief Link Interface - * \todo Describe concisely what the functions in this module are about. +/** \page H5L_UG The HDF5 Links + * @todo Under Construction + */ + +/** + * \defgroup H5L Links (H5L) + * + * Use the functions in this module to manage HDF5 links and link types. + * + * + * + * + * + * + * + * + * + * + * + *
CreateRead
+ * \snippet{lineno} H5L_examples.c create + * + * \snippet{lineno} H5L_examples.c iter_cb + * \snippet{lineno} H5L_examples.c read + *
UpdateDelete
+ * \snippet{lineno} H5L_examples.c update + * + * \snippet{lineno} H5L_examples.c delete + *
* * \defgroup TRAV Link Traversal * \ingroup H5L + * \defgroup H5LA Advanced Link Functions + * \ingroup H5L */ #endif /* H5Lmodule_H */ diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h index e37eb107d68..381b99eb646 100644 --- a/src/H5Lpkg.h +++ b/src/H5Lpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index e339d46a1d3..68faf9c3398 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -83,7 +82,7 @@ typedef struct { size_t size; /* Size of name buffer */ /* Out */ - char * name; /* Buffer to return name to user */ + char *name; /* Buffer to return name to user */ ssize_t name_len; /* Length of full name */ } H5L_trav_gnbi_t; @@ -98,7 +97,7 @@ typedef struct { /* Structure for external link traversal callback property */ typedef struct H5L_elink_cb_t { H5L_elink_traverse_t func; - void * user_data; + void *user_data; } H5L_elink_cb_t; /*****************************/ @@ -121,8 +120,8 @@ H5_DLL herr_t H5L_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx hsize_t *idx_p, H5L_iterate2_t op, void *op_data); /* User-defined link functions */ -H5_DLL herr_t H5L_register(const H5L_class_t *cls); -H5_DLL herr_t H5L_unregister(H5L_type_t id); +H5_DLL herr_t H5L_register(const H5L_class_t *cls); +H5_DLL herr_t H5L_unregister(H5L_type_t id); H5_DLL const H5L_class_t *H5L_find_class(H5L_type_t id); #endif /* H5Lprivate_H */ diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index bf1de8684ca..88388184a09 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -44,7 +43,7 @@ /** * \brief Macro to indicate operation occurs on same location */ -#define H5L_SAME_LOC (hid_t)0 +#define H5L_SAME_LOC 0 /* (hid_t) */ /** * \brief Current version of the H5L_class_t struct @@ -154,7 +153,7 @@ typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, typedef struct { int version; /**< Version number of this struct */ H5L_type_t id; /**< Link type ID */ - const char * comment; /**< Comment for debugging */ + const char *comment; /**< Comment for debugging */ H5L_create_func_t create_func; /**< Callback during link creation */ H5L_move_func_t move_func; /**< Callback after moving link */ H5L_copy_func_t copy_func; /**< Callback after copying link */ @@ -495,7 +494,7 @@ H5_DLL herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t * * \return \herr_t * - * \details H5Lget_val() returns tha value of link \p name. For smbolic links, + * \details H5Lget_val() returns the value of link \p name. For smbolic links, * this is the path to which the link points, including the null * terminator. For external and user-defined links, it is the link * buffer. @@ -525,7 +524,7 @@ H5_DLL herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t * * This function should be used only after H5Lget_info() has been * called to verify that \p name is a symbolic link. This can be - * deteremined from the \c link_type field of the \ref H5L_info_t + * determined from the \c link_type field of the \ref H5L_info_t * \c struct. * * \note This function will fail if called on a hard link. @@ -613,7 +612,7 @@ H5_DLL herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t * name includes either a relative path or an absolute path to the * target link, intermediate steps along the path must be verified * before the existence of the target link can be safely checked. If - * the path is not verified and an intermediate element of the path + * the path is not verified, and an intermediate element of the path * does not exist, H5Lexists() will fail. The example in the next * paragraph illustrates one step-by-step method for verifying the * existence of a link with a relative or absolute path. @@ -653,13 +652,13 @@ H5_DLL herr_t H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t * H5Lexists() with arguments \c file, \c "/", and \c lapl * returns a positive value; in other words, * \Code{H5Lexists(file, "/", lapl)} returns a positive value. - * In HDF5 version 1.8.16, this function returns 0. + * In the HDF5 1.8 release, this function returns 0. *
  • Let \c root denote a valid HDF5 group identifier that refers to the * root group of an HDF5 file, and let \c lapl denote a valid link * access property list identifier. A call to H5Lexists() with * arguments c root, \c "/", and \c lapl returns a positive value; - * in other words, \Code{H5Lexists(root, "/", lapl)} returns a postive - * value. In HDF5 version 1.8.16, this function returns 0.
  • + * in other words, \Code{H5Lexists(root, "/", lapl)} returns a positive + * value. In the HDF5 1.8 release, this function returns 0. * * Note that the function accepts link names and path names. This is * potentially misleading to callers, and we plan to separate the @@ -733,7 +732,7 @@ H5_DLL htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id); * \p cset specifies the character set in which the link name is * encoded. Valid values include the following: * \csets - * This value is set with H5Pset_char_encoding(). + * This value is set with #H5Pset_char_encoding. * * \c token is the location that a hard link points to, and * \c val_size is the size of a soft link or user defined link value. @@ -888,10 +887,12 @@ H5_DLL ssize_t H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index * not been indexed by the index type, they will first be sorted by * that index then the iteration will begin; if the links have been * so indexed, the sorting step will be unnecessary, so the iteration - * may begin more quickly. + * may begin more quickly. Valid values include the following: + * \indexes * * \p order specifies the order in which objects are to be inspected - * along the index \p idx_type. + * along the index \p idx_type. Valid values include the following: + * \orders * * \p idx_p tracks the iteration and allows an iteration to be * resumed if it was stopped before all members were processed. It is @@ -1112,7 +1113,7 @@ H5_DLL herr_t H5Lvisit2(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order * \p idx_type specifies the index to be used. If the links have not * been indexed by the index type, they will first be sorted by that * index then the iteration will begin; if the links have been so - * indexed, the sorting step will be unnecesary, so the iteration may + * indexed, the sorting step will be unnecessary, so the iteration may * begin more quickly. Valid values include the following: * \indexes * @@ -1608,7 +1609,7 @@ typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, c typedef struct { int version; /**< Version number of this struct */ H5L_type_t id; /**< Link type ID */ - const char * comment; /**< Comment for debugging */ + const char *comment; /**< Comment for debugging */ H5L_create_func_t create_func; /**< Callback during link creation */ H5L_move_func_t move_func; /**< Callback after moving link */ H5L_copy_func_t copy_func; /**< Callback after copying link */ @@ -1680,7 +1681,7 @@ typedef herr_t (*H5L_iterate1_t)(hid_t group, const char *name, const H5L_info1_ * \c cset specifies the character set in which the link name is * encoded. Valid values include the following: * \csets - * This value is set with H5Pset_char_encoding(). + * This value is set with #H5Pset_char_encoding. * * \c address and \c val_size are returned for hard and symbolic * links, respectively. Symbolic links include soft and external links @@ -1796,10 +1797,12 @@ H5_DLL herr_t H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index * not been indexed by the index type, they will first be sorted by * that index then the iteration will begin; if the links have been * so indexed, the sorting step will be unnecessary, so the iteration - * may begin more quickly. + * may begin more quickly. Valid values include the following: + * \indexes * * \p order specifies the order in which objects are to be inspected - * along the index \p idx_type. + * along the index \p idx_type. Valid values include the following: + * \orders * * \p idx_p tracks the iteration and allows an iteration to be * resumed if it was stopped before all members were processed. It is @@ -2040,7 +2043,7 @@ H5_DLL herr_t H5Lvisit1(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order * \p idx_type specifies the index to be used. If the links have not * been indexed by the index type, they will first be sorted by that * index then the iteration will begin; if the links have been so - * indexed, the sorting step will be unnecesary, so the iteration may + * indexed, the sorting step will be unnecessary, so the iteration may * begin more quickly. Valid values include the following: * \indexes * diff --git a/src/H5M.c b/src/H5M.c index e810e6dbad3..79faa3ead74 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -239,8 +238,8 @@ hid_t H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, hid_t val_type_id, hid_t lcpl_id, hid_t mcpl_id, hid_t mapl_id) { - void * map = NULL; /* New map's info */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *map = NULL; /* New map's info */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -322,8 +321,8 @@ H5Mcreate(hid_t loc_id, const char *name, hid_t key_type_id, hid_t val_type_id, hid_t H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id, hid_t mapl_id) { - void * map = NULL; /* map object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *map = NULL; /* map object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -353,7 +352,7 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id H5P_LINK_CREATE_DEFAULT, key_type_id, val_type_id, mcpl_id, mapl_id, &map) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTINIT, H5I_INVALID_HID, "unable to create map") - /* Get an atom for the map */ + /* Get an ID for the map */ if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register map") @@ -384,8 +383,8 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id hid_t H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id) { - void * map = NULL; /* map object from VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *map = NULL; /* map object from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -415,7 +414,7 @@ H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id) mapl_id, &map) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open map") - /* Register an atom for the map */ + /* Register an ID for the map */ if ((ret_value = H5VL_register(H5I_MAP, map, vol_obj->connector, TRUE)) < 0) HGOTO_ERROR(H5E_MAP, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register map atom") @@ -839,7 +838,7 @@ H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists, herr_t H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, hid_t dxpl_id) { - H5VL_object_t * vol_obj = NULL; + H5VL_object_t *vol_obj = NULL; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -913,7 +912,7 @@ herr_t H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op, void *op_data, hid_t dxpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; + H5VL_object_t *vol_obj = NULL; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -976,7 +975,7 @@ H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, hid_t key_m herr_t H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t dxpl_id) { - H5VL_object_t * vol_obj = NULL; + H5VL_object_t *vol_obj = NULL; H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5MF.c b/src/H5MF.c index b7004c14a62..bd9f74d593f 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -653,8 +652,10 @@ H5MF__add_sect(H5F_t *f, H5FD_mem_t alloc_type, H5FS_t *fspace, H5MF_free_sectio H5AC_set_ring(fsm_ring, &orig_ring); #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: adding node, node->sect_info.addr = %a, node->sect_info.size = %Hu\n", FUNC, - node->sect_info.addr, node->sect_info.size); + HDfprintf(stderr, + "%s: adding node, node->sect_info.addr = %" PRIuHADDR ", node->sect_info.size = %" PRIuHSIZE + "\n", + FUNC, node->sect_info.addr, node->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Add the section */ if (H5FS_sect_add(f, fspace, (H5FS_section_info_t *)node, H5FS_ADD_RETURNED_SPACE, &udata) < 0) @@ -706,7 +707,7 @@ H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, h HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "error locating free space in file") #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: section found = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: section found = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Check for actually finding section */ @@ -734,7 +735,8 @@ H5MF__find_sect(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size, H5FS_t *fspace, h node->sect_info.size -= size; #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: re-adding node, node->sect_info.size = %Hu\n", FUNC, node->sect_info.size); + HDfprintf(stderr, "%s: re-adding node, node->sect_info.size = %" PRIuHSIZE "\n", FUNC, + node->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Re-add the section to the free-space manager */ @@ -777,7 +779,7 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, HADDR_UNDEF) #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); + HDfprintf(stderr, "%s: alloc_type = %u, size = %" PRIuHSIZE "\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_ALLOC_DEBUG */ /* check arguments */ @@ -850,7 +852,8 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); + HDfprintf(stderr, "%s: Leaving: ret_value = %" PRIuHADDR ", size = %" PRIuHSIZE "\n", FUNC, ret_value, + size); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP H5MF__sects_dump(f, stderr); @@ -890,7 +893,7 @@ H5MF__alloc_pagefs(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); + HDfprintf(stderr, "%s: alloc_type = %u, size = %" PRIuHSIZE "\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_ALLOC_DEBUG */ H5MF__alloc_to_fs_type(f->shared, alloc_type, size, &ptype); @@ -987,7 +990,8 @@ H5MF__alloc_pagefs(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) done: #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); + HDfprintf(stderr, "%s: Leaving: ret_value = %" PRIuHADDR ", size = %" PRIuHSIZE "\n", FUNC, ret_value, + size); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP H5MF__sects_dump(f, stderr); @@ -1033,7 +1037,7 @@ H5MF_alloc_tmp(H5F_t *f, hsize_t size) FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size); + HDfprintf(stderr, "%s: size = %" PRIuHSIZE "\n", FUNC, size); #endif /* H5MF_ALLOC_DEBUG */ /* check args */ @@ -1085,8 +1089,8 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)alloc_type, - addr, size); + HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %" PRIuHADDR ", size = %" PRIuHSIZE "\n", FUNC, + (unsigned)alloc_type, addr, size); #endif /* H5MF_ALLOC_DEBUG */ /* check arguments */ @@ -1135,7 +1139,7 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) * space is at the end of the file */ #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: fs_addr = %a\n", FUNC, f->shared->fs_addr[fs_type]); + HDfprintf(stderr, "%s: fs_addr = %" PRIuHADDR "\n", FUNC, f->shared->fs_addr[fs_type]); #endif /* H5MF_ALLOC_DEBUG_MORE */ if (!H5F_addr_defined(f->shared->fs_addr[fs_type])) { htri_t status; /* "can absorb" status for section into */ @@ -1151,7 +1155,9 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) HGOTO_DONE(SUCCEED) else if (size < f->shared->fs_threshold) { #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: dropping addr = %a, size = %Hu, on the floor!\n", FUNC, addr, size); + HDfprintf(stderr, + "%s: dropping addr = %" PRIuHADDR ", size = %" PRIuHSIZE ", on the floor!\n", FUNC, + addr, size); #endif /* H5MF_ALLOC_DEBUG_MORE */ HGOTO_DONE(SUCCEED) } /* end else-if */ @@ -1168,7 +1174,8 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) */ if (f->shared->fs_state[fs_type] == H5F_FS_STATE_DELETING || !H5F_HAVE_FREE_SPACE_MANAGER(f)) { #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: dropping addr = %a, size = %Hu, on the floor!\n", FUNC, addr, size); + HDfprintf(stderr, "%s: dropping addr = %" PRIuHADDR ", size = %" PRIuHSIZE ", on the floor!\n", + FUNC, addr, size); #endif /* H5MF_ALLOC_DEBUG_MORE */ HGOTO_DONE(SUCCEED) } /* end if */ @@ -1277,8 +1284,10 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsi FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: Entering: alloc_type = %u, addr = %a, size = %Hu, extra_requested = %Hu\n", FUNC, - (unsigned)alloc_type, addr, size, extra_requested); + HDfprintf(stderr, + "%s: Entering: alloc_type = %u, addr = %" PRIuHADDR ", size = %" PRIuHSIZE + ", extra_requested = %" PRIuHSIZE "\n", + FUNC, (unsigned)alloc_type, addr, size, extra_requested); #endif /* H5MF_ALLOC_DEBUG */ /* Sanity check */ @@ -1330,7 +1339,7 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsi if ((ret_value = H5F__try_extend(f, map_type, end, extra_requested + frag_size)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending file") #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: extended = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: extended = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* If extending at EOA succeeds: */ @@ -1368,7 +1377,7 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsi HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending aggregation block") #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: H5MF__aggr_try_extend = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: H5MF__aggr_try_extend = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ @@ -1394,7 +1403,7 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsi HGOTO_ERROR(H5E_RESOURCE, H5E_CANTEXTEND, FAIL, "error extending block in free space manager") #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: Try to H5FS_sect_try_extend = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Try to H5FS_sect_try_extend = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ @@ -1405,7 +1414,7 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsi if (frag_size <= H5F_PGEND_META_THRES(f) && extra_requested <= frag_size) ret_value = TRUE; #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: Try to extend into the page end threshold = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Try to extend into the page end threshold = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ } /* end if */ @@ -1417,7 +1426,7 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsi H5AC_set_ring(orig_ring, NULL); #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving: ret_value = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG */ #ifdef H5MF_ALLOC_DEBUG_DUMP H5MF__sects_dump(f, stderr); @@ -1442,7 +1451,7 @@ H5MF_try_extend(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size, hsi htri_t H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) { - H5MF_free_section_t * node = NULL; /* Free space section pointer */ + H5MF_free_section_t *node = NULL; /* Free space section pointer */ H5MF_sect_ud_t udata; /* User data for callback */ const H5FS_section_class_t *sect_cls; /* Section class */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ @@ -1452,8 +1461,8 @@ H5MF_try_shrink(H5F_t *f, H5FD_mem_t alloc_type, haddr_t addr, hsize_t size) FUNC_ENTER_NOAPI_TAG(H5AC__FREESPACE_TAG, FAIL) #ifdef H5MF_ALLOC_DEBUG - HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %a, size = %Hu\n", FUNC, (unsigned)alloc_type, - addr, size); + HDfprintf(stderr, "%s: Entering - alloc_type = %u, addr = %" PRIuHADDR ", size = %" PRIuHSIZE "\n", FUNC, + (unsigned)alloc_type, addr, size); #endif /* H5MF_ALLOC_DEBUG */ /* check arguments */ @@ -1589,8 +1598,9 @@ H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type) HDassert((H5FD_mem_t)type < H5FD_MEM_NTYPES); #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: Check 1.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, - (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); + HDfprintf(stderr, "%s: Check 1.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %" PRIuHADDR "\n", + FUNC, (unsigned)type, (void *)f->shared->fs_man[type], (unsigned)type, + f->shared->fs_addr[type]); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* If the free space manager for this type is open, close it */ @@ -1599,8 +1609,9 @@ H5MF__close_delete_fstype(H5F_t *f, H5F_mem_page_t type) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't close the free space manager") #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: Check 2.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %a\n", FUNC, - (unsigned)type, f->shared->fs_man[type], (unsigned)type, f->shared->fs_addr[type]); + HDfprintf(stderr, "%s: Check 2.0 - f->shared->fs_man[%u] = %p, f->shared->fs_addr[%u] = %" PRIuHADDR "\n", + FUNC, (unsigned)type, (void *)f->shared->fs_man[type], (unsigned)type, + f->shared->fs_addr[type]); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* If there is free space manager info for this type, delete it */ @@ -2123,8 +2134,9 @@ H5MF__close_shrink_eoa(H5F_t *f) curr_ring = needed_ring; } /* end if */ - udata.alloc_type = (H5FD_mem_t)( - (H5FD_mem_t)ptype < H5FD_MEM_NTYPES ? ptype : ((ptype % H5FD_MEM_NTYPES) + 1)); + udata.alloc_type = + (H5FD_mem_t)((H5FD_mem_t)ptype < H5FD_MEM_NTYPES ? ptype + : ((ptype % H5FD_MEM_NTYPES) + 1)); if ((status = H5FS_sect_try_shrink_eoa(f, f->shared->fs_man[ptype], &udata)) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't check for shrinking eoa") @@ -2642,16 +2654,14 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) hbool_t fsm_opened[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ hbool_t fsm_visited[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ - /* Sanity check */ - HDassert(f->shared->sblock); - /* should only be called if file is opened R/W */ HDassert(H5F_INTENT(f) & H5F_ACC_RDWR); /* shouldn't be called unless we have a superblock supporting the * superblock extension. */ - HDassert(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2); + if (f->shared->sblock) + HDassert(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2); /* Initialize fsm_opened and fsm_visited */ HDmemset(fsm_opened, 0, sizeof(fsm_opened)); @@ -2799,40 +2809,44 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) * file space manager info message is guaranteed to exist. * Leave it in for now, but consider removing it. */ - if (H5F_addr_defined(f->shared->sblock->ext_addr)) - if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, - "error in removing message from superblock extension") + if (f->shared->sblock) { + if (H5F_addr_defined(f->shared->sblock->ext_addr)) + if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, + "error in removing message from superblock extension") + } /* As the final element in 1), shrink the EOA for the file */ if (H5MF__close_shrink_eoa(f) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa") - /* 2) Ensure that space is allocated for the free space manager superblock - * extension message. Must do this now, before reallocating file space - * for free space managers, as it is possible that this allocation may - * grab the last section in a FSM -- making it unnecessary to - * re-allocate file space for it. - * - * Do this by writing a free space manager superblock extension message. - * - * Since no free space manager has file space allocated for it, this - * message must be invalid since we can't save addresses of FSMs when - * those addresses are unknown. This is OK -- we will write the correct - * values to the message at free space manager shutdown. - */ - for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) - fsinfo.fs_addr[fsm_type - 1] = HADDR_UNDEF; - fsinfo.strategy = f->shared->fs_strategy; - fsinfo.persist = f->shared->fs_persist; - fsinfo.threshold = f->shared->fs_threshold; - fsinfo.page_size = f->shared->fs_page_size; - fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; - fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; - - if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, - "error in writing fsinfo message to superblock extension") + if (f->shared->sblock) { + /* 2) Ensure that space is allocated for the free space manager superblock + * extension message. Must do this now, before reallocating file space + * for free space managers, as it is possible that this allocation may + * grab the last section in a FSM -- making it unnecessary to + * re-allocate file space for it. + * + * Do this by writing a free space manager superblock extension message. + * + * Since no free space manager has file space allocated for it, this + * message must be invalid since we can't save addresses of FSMs when + * those addresses are unknown. This is OK -- we will write the correct + * values to the message at free space manager shutdown. + */ + for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) + fsinfo.fs_addr[fsm_type - 1] = HADDR_UNDEF; + fsinfo.strategy = f->shared->fs_strategy; + fsinfo.persist = f->shared->fs_persist; + fsinfo.threshold = f->shared->fs_threshold; + fsinfo.page_size = f->shared->fs_page_size; + fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; + fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; + + if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, + "error in writing fsinfo message to superblock extension") + } /* 3) Scan all free space managers not involved in allocating * space for free space managers. For each such free space @@ -3085,10 +3099,10 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hbool_t *fsm_settled) H5F_mem_page_t sm_fssinfo_fs_type; /* small fs sinfo fsm */ H5F_mem_page_t lg_fshdr_fs_type = H5F_MEM_PAGE_DEFAULT; /* large fs hdr fsm */ H5F_mem_page_t lg_fssinfo_fs_type = H5F_MEM_PAGE_DEFAULT; /* large fs sinfo fsm */ - H5FS_t * sm_hdr_fspace = NULL; /* ptr to sm FSM hdr alloc FSM */ - H5FS_t * sm_sinfo_fspace = NULL; /* ptr to sm FSM sinfo alloc FSM */ - H5FS_t * lg_hdr_fspace = NULL; /* ptr to lg FSM hdr alloc FSM */ - H5FS_t * lg_sinfo_fspace = NULL; /* ptr to lg FSM sinfo alloc FSM */ + H5FS_t *sm_hdr_fspace = NULL; /* ptr to sm FSM hdr alloc FSM */ + H5FS_t *sm_sinfo_fspace = NULL; /* ptr to sm FSM sinfo alloc FSM */ + H5FS_t *lg_hdr_fspace = NULL; /* ptr to lg FSM hdr alloc FSM */ + H5FS_t *lg_sinfo_fspace = NULL; /* ptr to lg FSM sinfo alloc FSM */ haddr_t eoa_fsm_fsalloc; /* eoa after file space allocation */ /* for self referential FSMs */ hbool_t continue_alloc_fsm = FALSE; /* Continue allocating addr and sect_addr for FSMs */ diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 68cd26329c1..0afc82dc5bb 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -92,7 +91,7 @@ H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: alloc_type = %u, size = %Hu\n", FUNC, (unsigned)alloc_type, size); + HDfprintf(stderr, "%s: alloc_type = %u, size = %" PRIuHSIZE "\n", FUNC, (unsigned)alloc_type, size); #endif /* H5MF_AGGR_DEBUG */ /* check arguments */ @@ -120,7 +119,8 @@ H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t alloc_type, hsize_t size) done: #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: Leaving: ret_value = %a, size = %Hu\n", FUNC, ret_value, size); + HDfprintf(stderr, "%s: Leaving: ret_value = %" PRIuHADDR ", size = %" PRIuHSIZE "\n", FUNC, ret_value, + size); #endif /* H5MF_AGGR_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) @@ -150,7 +150,7 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F FUNC_ENTER_STATIC #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size); + HDfprintf(stderr, "%s: type = %u, size = %" PRIuHSIZE "\n", FUNC, (unsigned)type, size); #endif /* H5MF_AGGR_DEBUG */ /* check args */ @@ -192,14 +192,15 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F if ((f->shared->feature_flags & aggr->feature_flag) && f->shared->fs_strategy != H5F_FSPACE_STRATEGY_NONE && !f->shared->closing) { #endif - haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregrator fragment */ + haddr_t aggr_frag_addr = HADDR_UNDEF; /* Address of aggregator fragment */ hsize_t aggr_frag_size = 0; /* Size of aggregator fragment */ hsize_t alignment; /* Alignment of this section */ - hsize_t aggr_mis_align = 0; /* Mis-alignment of aggregator */ + hsize_t aggr_mis_align = 0; /* Misalignment of aggregator */ H5FD_mem_t alloc_type, other_alloc_type; /* Current aggregator & 'other' aggregator types */ #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_size, aggr->size); + HDfprintf(stderr, "%s: aggr = {%" PRIuHADDR ", %" PRIuHSIZE ", %" PRIuHSIZE "}\n", FUNC, + aggr->addr, aggr->tot_size, aggr->size); #endif /* H5MF_AGGR_DEBUG */ /* Turn off alignment if allocation < threshold */ @@ -387,7 +388,7 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F done: #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value); + HDfprintf(stderr, "%s: ret_value = %" PRIuHADDR "\n", FUNC, ret_value); #endif /* H5MF_AGGR_DEBUG */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5MF__aggr_alloc() */ @@ -482,7 +483,7 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F } /* end else */ } /* end if */ else { - /* The aggreator is not at end of file */ + /* The aggregator is not at end of file */ /* Check if aggregator has enough internal space to satisfy the extension. */ if (aggr->size >= extra_requested) { /* Extend block into aggregator */ @@ -536,8 +537,11 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F if (H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr) || H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)) { #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: section {%a, %Hu} adjoins aggr = {%a, %Hu}\n", "H5MF__aggr_can_absorb", - sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); + HDfprintf(stderr, + "%s: section {%" PRIuHADDR ", %" PRIuHSIZE "} adjoins aggr = {%" PRIuHADDR + ", %" PRIuHSIZE "}\n", + "H5MF__aggr_can_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, + aggr->size); #endif /* H5MF_AGGR_DEBUG */ /* Check if aggregator would get too large and should be absorbed into section */ if ((aggr->size + sect->sect_info.size) >= aggr->alloc_size) @@ -586,7 +590,9 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F /* Check if the section adjoins the beginning or end of the aggregator */ if (H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr)) { #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins front of section = {%a, %Hu}\n", + HDfprintf(stderr, + "%s: aggr {%" PRIuHADDR ", %" PRIuHSIZE "} adjoins front of section = {%" PRIuHADDR + ", %" PRIuHSIZE "}\n", "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_AGGR_DEBUG */ @@ -598,7 +604,9 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: aggr {%a, %Hu} adjoins end of section = {%a, %Hu}\n", + HDfprintf(stderr, + "%s: aggr {%" PRIuHADDR ", %" PRIuHSIZE "} adjoins end of section = {%" PRIuHADDR + ", %" PRIuHSIZE "}\n", "H5MF__aggr_absorb", aggr->addr, aggr->size, sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_AGGR_DEBUG */ @@ -616,7 +624,9 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F /* Check if the section adjoins the beginning or end of the aggregator */ if (H5F_addr_eq((sect->sect_info.addr + sect->sect_info.size), aggr->addr)) { #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: section {%a, %Hu} adjoins front of aggr = {%a, %Hu}\n", + HDfprintf(stderr, + "%s: section {%" PRIuHADDR ", %" PRIuHSIZE "} adjoins front of aggr = {%" PRIuHADDR + ", %" PRIuHSIZE "}\n", "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); #endif /* H5MF_AGGR_DEBUG */ @@ -634,7 +644,9 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F HDassert(H5F_addr_eq((aggr->addr + aggr->size), sect->sect_info.addr)); #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: section {%a, %Hu} adjoins end of aggr = {%a, %Hu}\n", + HDfprintf(stderr, + "%s: section {%" PRIuHADDR ", %" PRIuHSIZE "} adjoins end of aggr = {%" PRIuHADDR + ", %" PRIuHSIZE "}\n", "H5MF__aggr_absorb", sect->sect_info.addr, sect->sect_info.size, aggr->addr, aggr->size); #endif /* H5MF_AGGR_DEBUG */ @@ -722,7 +734,8 @@ H5MF__aggr_alloc(H5F_t *f, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *other_aggr, H5F tmp_addr = aggr->addr; tmp_size = aggr->size; #ifdef H5MF_AGGR_DEBUG - HDfprintf(stderr, "%s: tmp_addr = %a, tmp_size = %Hu\n", FUNC, tmp_addr, tmp_size); + HDfprintf(stderr, "%s: tmp_addr = %" PRIuHADDR ", tmp_size = %" PRIuHSIZE "\n", FUNC, tmp_addr, + tmp_size); #endif /* H5MF_AGGR_DEBUG */ /* Reset aggregator block information */ diff --git a/src/H5MFdbg.c b/src/H5MFdbg.c index 7b89fd89c8a..a9e754315a4 100644 --- a/src/H5MFdbg.c +++ b/src/H5MFdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -49,8 +48,8 @@ /* User data for free space section iterator callback */ typedef struct { H5FS_t *fspace; /* Free space manager */ - FILE * stream; /* Stream for output */ - int indent; /* Indention amount */ + FILE *stream; /* Stream for output */ + int indent; /* Indentation amount */ int fwidth; /* Field width amount */ } H5MF_debug_iter_ud_t; @@ -91,7 +90,7 @@ static herr_t H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata); static herr_t H5MF__sects_debug_cb(H5FS_section_info_t *_sect, void *_udata) { - H5MF_free_section_t * sect = (H5MF_free_section_t *)_sect; /* Section to dump info */ + H5MF_free_section_t *sect = (H5MF_free_section_t *)_sect; /* Section to dump info */ H5MF_debug_iter_ud_t *udata = (H5MF_debug_iter_ud_t *)_udata; /* User data for callbacks */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index f34c73e1764..2711fcf841a 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -144,21 +143,21 @@ typedef enum { /* User data for free space manager section callbacks */ typedef struct H5MF_sect_ud_t { /* Down */ - H5F_t * f; /* Pointer to file to operate on */ + H5F_t *f; /* Pointer to file to operate on */ H5FD_mem_t alloc_type; /* Type of memory being allocated */ hbool_t allow_sect_absorb; /* Whether sections are allowed to absorb a block aggregator */ hbool_t allow_eoa_shrink_only; /* Whether shrinking eoa is allowed only for the section */ /* Up */ H5MF_shrink_type_t shrink; /* Type of shrink operation to perform */ - H5F_blk_aggr_t * aggr; /* Aggregator block to operate on */ + H5F_blk_aggr_t *aggr; /* Aggregator block to operate on */ } H5MF_sect_ud_t; /* Information about the current free-space manager to use */ typedef struct H5MF_fs_t { H5F_fs_state_t *fs_state; - haddr_t * fs_addr; - H5FS_t ** fs_man; + haddr_t *fs_addr; + H5FS_t **fs_man; hsize_t align_thres; /* Threshold for alignment */ hsize_t alignment; /* Alignment */ } H5MF_fs_t; diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h index 292e85c5f88..82ca2f99923 100644 --- a/src/H5MFprivate.h +++ b/src/H5MFprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5MFsection.c b/src/H5MFsection.c index bf5b88892cb..b3d22321f99 100644 --- a/src/H5MFsection.c +++ b/src/H5MFsection.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -408,7 +407,7 @@ H5MF__sect_simple_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect void H5_ATTR_UNUSED *_udata) { H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ - H5MF_free_section_t * sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ + H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -448,7 +447,7 @@ static htri_t H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ - H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ haddr_t eoa; /* End of address space in the file */ haddr_t end; /* End of section to extend */ htri_t ret_value = FAIL; /* Return value */ @@ -472,8 +471,9 @@ H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) /* Set the shrinking type */ udata->shrink = H5MF_SHRINK_EOA; #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, - sect->sect_info.size, eoa); + HDfprintf(stderr, + "%s: section {%" PRIuHADDR ", %" PRIuHSIZE "}, shrinks file, eoa = %" PRIuHADDR "\n", FUNC, + sect->sect_info.addr, sect->sect_info.size, eoa); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ @@ -496,7 +496,8 @@ H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) /* Set the aggregator to operate on */ udata->aggr = &(udata->f->shared->meta_aggr); #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins metadata aggregator\n", FUNC, + HDfprintf(stderr, + "%s: section {%" PRIuHADDR ", %" PRIuHSIZE "}, adjoins metadata aggregator\n", FUNC, sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ @@ -517,8 +518,9 @@ H5MF__sect_simple_can_shrink(const H5FS_section_info_t *_sect, void *_udata) /* Set the aggregator to operate on */ udata->aggr = &(udata->f->shared->sdata_aggr); #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: section {%a, %Hu}, adjoins small data aggregator\n", FUNC, - sect->sect_info.addr, sect->sect_info.size); + HDfprintf(stderr, + "%s: section {%" PRIuHADDR ", %" PRIuHSIZE "}, adjoins small data aggregator\n", + FUNC, sect->sect_info.addr, sect->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ @@ -551,7 +553,7 @@ static herr_t H5MF__sect_simple_shrink(H5FS_section_info_t **_sect, void *_udata) { H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ - H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -617,7 +619,7 @@ static herr_t H5MF__sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) { H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* Fractal heap free section */ - H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ haddr_t sect_end; hsize_t rem, prem; herr_t ret_value = SUCCEED; /* Return value */ @@ -625,8 +627,8 @@ H5MF__sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) FUNC_ENTER_STATIC #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: Entering, section {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, - (*sect)->sect_info.size); + HDfprintf(stderr, "%s: Entering, section {%" PRIuHADDR ", %" PRIuHSIZE "}\n", FUNC, + (*sect)->sect_info.addr, (*sect)->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Do not adjust the section raw data or global heap data */ @@ -653,8 +655,8 @@ H5MF__sect_small_add(H5FS_section_info_t **_sect, unsigned *flags, void *_udata) else if (prem <= H5F_PGEND_META_THRES(udata->f)) { (*sect)->sect_info.size += prem; #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: section is adjusted {%a, %Hu}\n", FUNC, (*sect)->sect_info.addr, - (*sect)->sect_info.size); + HDfprintf(stderr, "%s: section is adjusted {%" PRIuHADDR ", %" PRIuHSIZE "}\n", FUNC, + (*sect)->sect_info.addr, (*sect)->sect_info.size); #endif /* H5MF_ALLOC_DEBUG_MORE */ } /* end if */ @@ -682,7 +684,7 @@ H5MF__sect_small_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section { const H5MF_free_section_t *sect1 = (const H5MF_free_section_t *)_sect1; /* File free section */ const H5MF_free_section_t *sect2 = (const H5MF_free_section_t *)_sect2; /* File free section */ - H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -702,7 +704,7 @@ H5MF__sect_small_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section ret_value = FALSE; #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving: ret_value = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ FUNC_LEAVE_NOAPI(ret_value) @@ -728,8 +730,8 @@ static herr_t H5MF__sect_small_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void *_udata) { H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ - H5MF_free_section_t * sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ - H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -806,7 +808,7 @@ H5MF__sect_large_can_merge(const H5FS_section_info_t *_sect1, const H5FS_section ret_value = H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr); #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: Leaving: ret_value = %t\n", FUNC, ret_value); + HDfprintf(stderr, "%s: Leaving: ret_value = %d\n", FUNC, ret_value); #endif /* H5MF_ALLOC_DEBUG_MORE */ FUNC_LEAVE_NOAPI(ret_value) @@ -830,7 +832,7 @@ static herr_t H5MF__sect_large_merge(H5FS_section_info_t **_sect1, H5FS_section_info_t *_sect2, void H5_ATTR_UNUSED *_udata) { H5MF_free_section_t **sect1 = (H5MF_free_section_t **)_sect1; /* File free section */ - H5MF_free_section_t * sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ + H5MF_free_section_t *sect2 = (H5MF_free_section_t *)_sect2; /* File free section */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -869,7 +871,7 @@ static htri_t H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) { const H5MF_free_section_t *sect = (const H5MF_free_section_t *)_sect; /* File free section */ - H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ haddr_t eoa; /* End of address space in the file */ haddr_t end; /* End of section to extend */ htri_t ret_value = FALSE; /* Return value */ @@ -894,8 +896,9 @@ H5MF__sect_large_can_shrink(const H5FS_section_info_t *_sect, void *_udata) /* Set the shrinking type */ udata->shrink = H5MF_SHRINK_EOA; #ifdef H5MF_ALLOC_DEBUG_MORE - HDfprintf(stderr, "%s: section {%a, %Hu}, shrinks file, eoa = %a\n", FUNC, sect->sect_info.addr, - sect->sect_info.size, eoa); + HDfprintf(stderr, + "%s: section {%" PRIuHADDR ", %" PRIuHSIZE "}, shrinks file, eoa = %" PRIuHADDR "\n", FUNC, + sect->sect_info.addr, sect->sect_info.size, eoa); #endif /* H5MF_ALLOC_DEBUG_MORE */ /* Indicate shrinking can occur */ @@ -922,7 +925,7 @@ static herr_t H5MF__sect_large_shrink(H5FS_section_info_t **_sect, void *_udata) { H5MF_free_section_t **sect = (H5MF_free_section_t **)_sect; /* File free section */ - H5MF_sect_ud_t * udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ + H5MF_sect_ud_t *udata = (H5MF_sect_ud_t *)_udata; /* User data for callback */ hsize_t frag_size = 0; /* Fragment size */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5MM.c b/src/H5MM.c index b4447f61e77..69029b4baad 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -53,7 +52,7 @@ struct H5MM_block_t; /* Forward declaration for typedef */ typedef struct H5MM_block_t { unsigned char - sig[H5MM_SIG_SIZE]; /* Signature for the block, to indicate it was allocated with H5MM* interface */ + sig[H5MM_SIG_SIZE]; /* Signature for the block, to indicate it was allocated with H5MM* interface */ struct H5MM_block_t *next; /* Pointer to next block in the list of allocated blocks */ struct H5MM_block_t *prev; /* Pointer to previous block in the list of allocated blocks */ union { diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index bb846f408a8..10e536d83d5 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -39,14 +38,14 @@ /* * Library prototypes... */ -H5_DLL void * H5MM_malloc(size_t size); -H5_DLL void * H5MM_calloc(size_t size); -H5_DLL void * H5MM_realloc(void *mem, size_t size); -H5_DLL char * H5MM_xstrdup(const char *s); -H5_DLL char * H5MM_strdup(const char *s); -H5_DLL void * H5MM_xfree(void *mem); -H5_DLL void * H5MM_xfree_const(const void *mem); -H5_DLL void * H5MM_memcpy(void *dest, const void *src, size_t n); +H5_DLL void *H5MM_malloc(size_t size); +H5_DLL void *H5MM_calloc(size_t size); +H5_DLL void *H5MM_realloc(void *mem, size_t size); +H5_DLL char *H5MM_xstrdup(const char *s); +H5_DLL char *H5MM_strdup(const char *s); +H5_DLL void *H5MM_xfree(void *mem); +H5_DLL void *H5MM_xfree_const(const void *mem); +H5_DLL void *H5MM_memcpy(void *dest, const void *src, size_t n); H5_DLL herr_t H5MM_get_alloc_stats(H5_alloc_stats_t *stats); #if defined H5_MEMORY_ALLOC_SANITY_CHECK H5_DLL void H5MM_sanity_check_all(void); diff --git a/src/H5MMpublic.h b/src/H5MMpublic.h index 70ac6445ea5..d5d5a146e76 100644 --- a/src/H5MMpublic.h +++ b/src/H5MMpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -14,8 +13,6 @@ /*------------------------------------------------------------------------- * * Created: H5MMpublic.h - * Jul 10 1997 - * Robb Matzke * * Purpose: Public declarations for the H5MM (memory management) * package. diff --git a/src/H5MP.c b/src/H5MP.c deleted file mode 100644 index 474a99526d5..00000000000 --- a/src/H5MP.c +++ /dev/null @@ -1,446 +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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*------------------------------------------------------------------------- - * - * Created: H5MP.c - * May 2 2005 - * Quincey Koziol - * - * Purpose: Implements memory pools. (Similar to Apache's APR - * memory pools) - * - * Please see the documentation in: - * doc/html/TechNotes/MemoryPools.html for a full description - * of how they work, etc. - * - *------------------------------------------------------------------------- - */ - -#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ - -/* Private headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5MPpkg.h" /* Memory Pools */ - -/****************/ -/* Local Macros */ -/****************/ - -/* Minimum sized block */ -#define H5MP_MIN_BLOCK (H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)) + H5MP_BLOCK_ALIGNMENT) - -/* First block in page */ -#define H5MP_PAGE_FIRST_BLOCK(p) \ - (H5MP_page_blk_t *)((void *)((unsigned char *)(p) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))) - -/******************/ -/* Local Typedefs */ -/******************/ - -/********************/ -/* Local Prototypes */ -/********************/ - -/********************************/ -/* Package Variable Definitions */ -/********************************/ - -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - -/********************/ -/* Static Variables */ -/********************/ - -/* Declare a free list to manage the H5MP_pool_t struct */ -H5FL_DEFINE(H5MP_pool_t); - -/*------------------------------------------------------------------------- - * Function: H5MP_create - * - * Purpose: Create a new memory pool - * - * Return: Pointer to the memory pool "header" on success/NULL on failure - * - * Programmer: Quincey Koziol - * May 2 2005 - * - *------------------------------------------------------------------------- - */ -H5MP_pool_t * -H5MP_create(size_t page_size, unsigned flags) -{ - H5MP_pool_t *mp = NULL; /* New memory pool header */ - H5MP_pool_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Allocate space for the pool header */ - if (NULL == (mp = H5FL_MALLOC(H5MP_pool_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for memory pool header") - - /* Assign information */ - mp->page_size = H5MP_BLOCK_ALIGN(page_size); - mp->flags = flags; - - /* Initialize information */ - mp->free_size = 0; - mp->first = NULL; - mp->max_size = mp->page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)); - - /* Create factory for pool pages */ - if (NULL == (mp->page_fac = H5FL_fac_init(page_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't create page factory") - - /* Set return value */ - ret_value = mp; - -done: - if (NULL == ret_value && mp) - if (H5MP_close(mp) < 0) - HDONE_ERROR(H5E_RESOURCE, H5E_CANTFREE, NULL, "unable to free memory pool header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_create() */ - -/*------------------------------------------------------------------------- - * Function: H5MP__new_page - * - * Purpose: Allocate new page for a memory pool - * - * Return: Pointer to the page allocated on success/NULL on failure - * - * Programmer: Quincey Koziol - * May 4 2005 - * - *------------------------------------------------------------------------- - */ -static H5MP_page_t * -H5MP__new_page(H5MP_pool_t *mp, size_t page_size) -{ - H5MP_page_t * new_page; /* New page created */ - H5MP_page_blk_t *first_blk; /* Pointer to first block in page */ - H5MP_page_t * ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(mp); - HDassert(page_size >= mp->page_size); - - /* Allocate page */ - if (page_size > mp->page_size) { - if (NULL == (new_page = (H5MP_page_t *)H5MM_malloc(page_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") - new_page->free_size = page_size - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)); - new_page->fac_alloc = FALSE; - } /* end if */ - else { - if (NULL == (new_page = (H5MP_page_t *)H5FL_FAC_MALLOC(mp->page_fac))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") - new_page->free_size = mp->max_size; - new_page->fac_alloc = TRUE; - } /* end else */ - - /* Initialize page information */ - first_blk = H5MP_PAGE_FIRST_BLOCK(new_page); - first_blk->size = new_page->free_size; - first_blk->page = new_page; - first_blk->is_free = TRUE; - first_blk->prev = NULL; - first_blk->next = NULL; - - /* Insert into page list */ - new_page->prev = NULL; - new_page->next = mp->first; - if (mp->first) - mp->first->prev = new_page; - mp->first = new_page; - - /* Account for new free space */ - new_page->free_blk = first_blk; - mp->free_size += new_page->free_size; - - /* Assign return value */ - ret_value = new_page; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP__new_page() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_malloc - * - * Purpose: Allocate space in a memory pool - * - * Return: Pointer to the space allocated on success/NULL on failure - * - * Programmer: Quincey Koziol - * May 2 2005 - * - *------------------------------------------------------------------------- - */ -void * -H5MP_malloc(H5MP_pool_t *mp, size_t request) -{ - H5MP_page_t * alloc_page = NULL; /* Page to allocate space from */ - H5MP_page_blk_t *alloc_free; /* Pointer to free space in page */ - size_t needed; /* Size requested, plus block header and alignment */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Sanity check */ - HDassert(mp); - HDassert(request > 0); - - /* Compute actual size needed */ - needed = H5MP_BLOCK_ALIGN(request) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)); - - /* See if the request can be handled by existing free space */ - if (needed <= mp->free_size) { - size_t pool_free_avail; /* Amount of free space possibly available in pool */ - - /* Locate page with enough free space */ - alloc_page = mp->first; - pool_free_avail = mp->free_size; - while (alloc_page && pool_free_avail >= needed) { - /* If we found a page with enough free space, search for large - * enough free block on that page */ - if (alloc_page->free_size >= needed) { - size_t page_free_avail; /* Amount of free space possibly available */ - - /* Locate large enough block */ - alloc_free = alloc_page->free_blk; - page_free_avail = alloc_page->free_size; - while (alloc_free && page_free_avail >= needed) { - if (alloc_free->is_free) { - /* If we found a large enough block, leave now */ - if (alloc_free->size >= needed) - goto found; /* Needed to escape double "while" loop */ - - /* Decrement amount of potential space left */ - page_free_avail -= alloc_free->size; - } /* end if */ - - /* Go to next block */ - alloc_free = alloc_free->next; - } /* end while */ - } /* end if */ - - /* Decrement amount of potential space left */ - pool_free_avail -= alloc_page->free_size; - - /* Go to next page */ - alloc_page = alloc_page->next; - } /* end while */ - } /* end if */ - - { - size_t page_size; /* Size of page needed */ - - /* Check if the request is too large for a standard page */ - page_size = - (needed > mp->max_size) ? (needed + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t))) : mp->page_size; - - /* Allocate new page */ - if (NULL == (alloc_page = H5MP__new_page(mp, page_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for page") - - /* Set the block to allocate from */ - alloc_free = alloc_page->free_blk; - } /* end block */ - - /* Allocate space in page */ -found: - - /* Sanity check */ - HDassert(alloc_page); - HDassert(alloc_free); - - /* Check if we can subdivide the free space */ - if (alloc_free->size > (needed + H5MP_MIN_BLOCK)) { - H5MP_page_blk_t *new_free; /* New free block created */ - - /* Carve out new free block after block to allocate */ - new_free = (H5MP_page_blk_t *)((void *)(((unsigned char *)alloc_free) + needed)); - - /* Link into existing lists */ - new_free->next = alloc_free->next; - if (alloc_free->next) - alloc_free->next->prev = new_free; - new_free->prev = alloc_free; - alloc_free->next = new_free; - - /* Set blocks' information */ - new_free->size = alloc_free->size - needed; - new_free->is_free = TRUE; - new_free->page = alloc_free->page; - alloc_free->size = needed; - alloc_free->is_free = FALSE; - } /* end if */ - else { - /* Use whole free space block for new block */ - alloc_free->is_free = FALSE; - } /* end else */ - - /* Update page & pool's free size information */ - alloc_page->free_size -= alloc_free->size; - if (alloc_page->free_blk == alloc_free) - alloc_page->free_blk = alloc_free->next; - mp->free_size -= alloc_free->size; - - /* Set new space pointer for the return value */ - ret_value = ((unsigned char *)alloc_free) + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_malloc() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_free - * - * Purpose: Release space in a memory pool - * - * Return: NULL on success/NULL on failure - * - * Programmer: Quincey Koziol - * May 3 2005 - * - * Note: Should we release pages that have no used blocks? - * - *------------------------------------------------------------------------- - */ -void * -H5MP_free(H5MP_pool_t *mp, void *spc) -{ - H5MP_page_blk_t *spc_blk; /* Block for space to free */ - H5MP_page_t * spc_page; /* Page containing block to free */ - void * ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Sanity check */ - HDassert(mp); - HDassert(spc); - - /* Get block header for space to free */ - spc_blk = - (H5MP_page_blk_t *)((void *)(((unsigned char *)spc) - H5MP_BLOCK_ALIGN(sizeof(H5MP_page_blk_t)))); - - /* Mark block as free */ - HDassert(spc_blk->is_free == FALSE); - spc_blk->is_free = TRUE; - - /* Add it's space to the amount of free space in the page & pool */ - spc_page = spc_blk->page; - spc_page->free_size += spc_blk->size; - mp->free_size += spc_blk->size; - - /* Move page with newly freed space to front of list of pages in pool */ - if (spc_page != mp->first) { - /* Remove page from list */ - spc_page->prev->next = spc_page->next; - if (spc_page->next) - spc_page->next->prev = spc_page->prev; - - /* Insert page at beginning of list */ - spc_page->prev = NULL; - spc_page->next = mp->first; - mp->first->prev = spc_page; - mp->first = spc_page; - } /* end if */ - - /* Check if block can be merged with free space after it on page */ - if (spc_blk->next != NULL) { - H5MP_page_blk_t *next_blk; /* Block following space to free */ - - next_blk = spc_blk->next; - HDassert(next_blk->prev == spc_blk); - if (next_blk->is_free) { - spc_blk->size += next_blk->size; - spc_blk->next = next_blk->next; - } /* end if */ - } /* end if */ - - /* Check if block can be merged with free space before it on page */ - if (spc_blk->prev != NULL) { - H5MP_page_blk_t *prev_blk; /* Block before space to free */ - - prev_blk = spc_blk->prev; - HDassert(prev_blk->next == spc_blk); - if (prev_blk->is_free) { - prev_blk->size += spc_blk->size; - prev_blk->next = spc_blk->next; - } /* end if */ - } /* end if */ - - /* Check if the block freed becomes the first free block on the page */ - if (spc_page->free_blk == NULL || spc_blk < spc_page->free_blk) - spc_page->free_blk = spc_blk; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_free() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_close - * - * Purpose: Release all memory for a pool and destroy pool - * - * Return: Non-negative on success/negative on failure - * - * Programmer: Quincey Koziol - * May 3 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_close(H5MP_pool_t *mp) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Release memory for pool pages */ - if (mp->first != NULL) { - H5MP_page_t *page, *next_page; /* Pointer to pages in pool */ - - /* Iterate through pages, releasing them */ - page = mp->first; - while (page) { - next_page = page->next; - - /* Free the page appropriately */ - if (page->fac_alloc) - page = (H5MP_page_t *)H5FL_FAC_FREE(mp->page_fac, page); - else - page = (H5MP_page_t *)H5MM_xfree(page); - - page = next_page; - } /* end while */ - } /* end if */ - - /* Release page factory */ - if (mp->page_fac) - if (H5FL_fac_term(mp->page_fac) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, "can't destroy page factory") - -done: - /* Free the memory pool itself */ - mp = H5FL_FREE(H5MP_pool_t, mp); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5MP_close() */ diff --git a/src/H5MPmodule.h b/src/H5MPmodule.h deleted file mode 100644 index 8e34598a20d..00000000000 --- a/src/H5MPmodule.h +++ /dev/null @@ -1,32 +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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5MP package. Including this header means that the source file - * is part of the H5MP package. - */ -#ifndef H5MPmodule_H -#define H5MPmodule_H - -/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error - * reporting macros. - */ -#define H5MP_MODULE -#define H5_MY_PKG H5MP -#define H5_MY_PKG_ERR H5E_RESOURCE -#define H5_MY_PKG_INIT NO - -#endif /* H5MPmodule_H */ diff --git a/src/H5MPpkg.h b/src/H5MPpkg.h deleted file mode 100644 index 64c5293ff03..00000000000 --- a/src/H5MPpkg.h +++ /dev/null @@ -1,99 +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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Programmer: Quincey Koziol - * Monday, May 2, 2005 - * - * Purpose: This file contains declarations which are visible only within - * the H5MP package. Source files outside the H5MP package should - * include H5MPprivate.h instead. - */ -#if !(defined H5MP_FRIEND || defined H5MP_MODULE) -#error "Do not include this file outside the H5MP package!" -#endif - -#ifndef H5MPpkg_H -#define H5MPpkg_H - -/* Get package's private header */ -#include "H5MPprivate.h" /* Memory Pools */ - -/* Other private headers needed by this file */ -#include "H5FLprivate.h" /* Free Lists */ - -/**************************/ -/* Package Private Macros */ -/**************************/ - -/* Alignment macros */ -/* (Ideas from Apache APR :-) */ - -/* Default alignment necessary */ -#define H5MP_BLOCK_ALIGNMENT 8 - -/* General alignment macro */ -/* (this only works for aligning to power of 2 boundary) */ -#define H5MP_ALIGN(x, a) (((x) + ((size_t)(a)) - 1) & ~(((size_t)(a)) - 1)) - -/* Default alignment */ -#define H5MP_BLOCK_ALIGN(x) H5MP_ALIGN(x, H5MP_BLOCK_ALIGNMENT) - -/****************************/ -/* Package Private Typedefs */ -/****************************/ - -/* Free block in pool */ -typedef struct H5MP_page_blk_t { - size_t size; /* Size of block (includes this H5MP_page_blk_t info) */ - unsigned is_free : 1; /* Flag to indicate the block is free */ - struct H5MP_page_t * page; /* Pointer to page block is located in */ - struct H5MP_page_blk_t *prev; /* Pointer to previous block in page */ - struct H5MP_page_blk_t *next; /* Pointer to next block in page */ -} H5MP_page_blk_t; - -/* Memory pool page */ -typedef struct H5MP_page_t { - size_t free_size; /* Total amount of free space in page */ - unsigned fac_alloc : 1; /* Flag to indicate the page was allocated by the pool's factory */ - H5MP_page_blk_t * free_blk; /* Pointer to first free block in page */ - struct H5MP_page_t *next; /* Pointer to next page in pool */ - struct H5MP_page_t *prev; /* Pointer to previous page in pool */ -} H5MP_page_t; - -/* Memory pool header */ -struct H5MP_pool_t { - H5FL_fac_head_t *page_fac; /* Free-list factory for pages */ - size_t page_size; /* Page size for pool */ - size_t free_size; /* Total amount of free space in pool */ - size_t max_size; /* Maximum block that will fit in a standard page */ - H5MP_page_t * first; /* Pointer to first page in pool */ - unsigned flags; /* Bit flags for pool settings */ -}; - -/*****************************************/ -/* Package Private Variable Declarations */ -/*****************************************/ - -/******************************/ -/* Package Private Prototypes */ -/******************************/ -#ifdef H5MP_TESTING -H5_DLL herr_t H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size); -H5_DLL htri_t H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp); -H5_DLL herr_t H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page); -H5_DLL herr_t H5MP_get_page_free_size(const H5MP_page_t *mp, size_t *page); -H5_DLL herr_t H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **next_page); -#endif /* H5MP_TESTING */ - -#endif /* H5MPpkg_H */ diff --git a/src/H5MPprivate.h b/src/H5MPprivate.h deleted file mode 100644 index 2b066502018..00000000000 --- a/src/H5MPprivate.h +++ /dev/null @@ -1,57 +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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*------------------------------------------------------------------------- - * - * Created: H5MPprivate.h - * May 2 2005 - * Quincey Koziol - * - * Purpose: Private header for memory pool routines. - * - *------------------------------------------------------------------------- - */ - -#ifndef H5MPprivate_H -#define H5MPprivate_H - -/* Include package's public header (not yet) */ -/* #include "H5MPpublic.h" */ - -/* Private headers needed by this file */ - -/**************************/ -/* Library Private Macros */ -/**************************/ - -/* Pool creation flags */ -/* Default settings */ -#define H5MP_FLG_DEFAULT 0 -#define H5MP_PAGE_SIZE_DEFAULT 4096 /* (bytes) */ - -/****************************/ -/* Library Private Typedefs */ -/****************************/ - -/* Memory pool header (defined in H5MPpkg.c) */ -typedef struct H5MP_pool_t H5MP_pool_t; - -/***************************************/ -/* Library-private Function Prototypes */ -/***************************************/ -H5_DLL H5MP_pool_t *H5MP_create(size_t page_size, unsigned flags); -H5_DLL void * H5MP_malloc(H5MP_pool_t *mp, size_t request); -H5_DLL void * H5MP_free(H5MP_pool_t *mp, void *spc); -H5_DLL herr_t H5MP_close(H5MP_pool_t *mp); - -#endif /* H5MPprivate_H */ diff --git a/src/H5MPtest.c b/src/H5MPtest.c deleted file mode 100644 index 27e7bbe0541..00000000000 --- a/src/H5MPtest.c +++ /dev/null @@ -1,213 +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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - * Purpose: Memory pool testing functions. - */ - -#include "H5MPmodule.h" /* This source code file is part of the H5MP module */ -#define H5MP_TESTING /*include H5MP testing funcs*/ - -/* Private headers */ -#include "H5private.h" /* Generic Functions */ -#include "H5MPpkg.h" /* Memory Pools */ -#include "H5Eprivate.h" /* Error handling */ - -/* Static Prototypes */ - -/* Package variables */ - -/*------------------------------------------------------------------------- - * Function: H5MP_get_pool_free_size - * - * Purpose: Retrieve the total amount of free space in entire pool - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_get_pool_free_size(const H5MP_pool_t *mp, size_t *free_size) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(mp); - HDassert(free_size); - - /* Get memory pool's free space */ - *free_size = mp->free_size; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MP_get_pool_free_size() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_get_pool_first_page - * - * Purpose: Retrieve the first page in a memory pool - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_get_pool_first_page(const H5MP_pool_t *mp, H5MP_page_t **page) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(mp); - HDassert(page); - - /* Get memory pool's first page */ - *page = mp->first; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MP_get_pool_first_page() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_pool_is_free_size_correct - * - * Purpose: Check that the free space reported in each page corresponds - * to the free size in each page and that the free space in the - * free blocks for a page corresponds with the free space for - * the page. - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Wednesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -htri_t -H5MP_pool_is_free_size_correct(const H5MP_pool_t *mp) -{ - H5MP_page_t *page; /* Pointer to current page */ - size_t pool_free; /* Size of pages' free space */ - htri_t ret_value = TRUE; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(mp); - - /* Iterate through pages, checking the free size & accumulating the - * free space for all the pages */ - page = mp->first; - pool_free = 0; - while (page != NULL) { - H5MP_page_blk_t *blk; /* Pointer to current free block */ - size_t page_free; /* Size of blocks on free list */ - - /* Iterate through the blocks in page, accumulating free space */ - blk = (H5MP_page_blk_t *)((void *)((unsigned char *)page + H5MP_BLOCK_ALIGN(sizeof(H5MP_page_t)))); - page_free = 0; - while (blk != NULL) { - if (blk->is_free) - page_free += blk->size; - blk = blk->next; - } /* end while */ - - /* Check that the free space from the blocks on the free list - * corresponds to space in page */ - if (page_free != page->free_size) - HGOTO_DONE(FALSE) - - /* Increment the amount of free space in pool */ - pool_free += page->free_size; - - /* Advance to next page */ - page = page->next; - } /* end while */ - - /* Check that the free space from the pages - * corresponds to free space in pool */ - if (pool_free != mp->free_size) - HGOTO_DONE(FALSE) - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5MP_pool_is_free_size_correct() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_get_page_free_size - * - * Purpose: Retrieve the amount of free space in given page - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_get_page_free_size(const H5MP_page_t *page, size_t *free_size) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(page); - HDassert(free_size); - - /* Get memory page's free space */ - *free_size = page->free_size; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MP_get_page_free_size() */ - -/*------------------------------------------------------------------------- - * Function: H5MP_get_page_next_page - * - * Purpose: Retrieve the next page in the pool - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Tuesday, May 3, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5MP_get_page_next_page(const H5MP_page_t *page, H5MP_page_t **next_page) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments. */ - HDassert(page); - HDassert(next_page); - - /* Get next memory page */ - *next_page = page->next; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5MP_get_page_next_page() */ diff --git a/src/H5Mmodule.h b/src/H5Mmodule.h index 3dae3e26682..6c49a45d181 100644 --- a/src/H5Mmodule.h +++ b/src/H5Mmodule.h @@ -27,8 +27,22 @@ #define H5_MY_PKG_INIT YES /** - * \defgroup H5M H5M - * \brief Map Interface + * \page H5M_UG The HDF5 VOL Data Mapping + * \Bold{The HDF5 Data Mapping can only be used with the HDF5 VOL connectors that + * implement map objects.} The native HDF5 library does not support this feature. + * + * \section sec_map The HDF5 Map Object + * + * \todo Describe the map life cycle. + * + * \todo How does MAPL fit into \ref subsubsec_plist_class. + * + * Previous Chapter \ref sec_vol - Next Chapter \ref sec_addition + * + */ + +/** + * \defgroup H5M VOL Mapping (H5M) * * \details \Bold{The interface can only be used with the HDF5 VOL connectors that * implement map objects.} The native HDF5 library does not support this diff --git a/src/H5Mpkg.h b/src/H5Mpkg.h index be6749b1853..d6b86ffa6dd 100644 --- a/src/H5Mpkg.h +++ b/src/H5Mpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h index 1a2524e2425..d299cc677a6 100644 --- a/src/H5Mprivate.h +++ b/src/H5Mprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h index f645bc9aacf..8218b9a1006 100644 --- a/src/H5Mpublic.h +++ b/src/H5Mpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -139,7 +138,7 @@ H5_DLL hid_t H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, * H5Mclose() when the application is not longer interested in * accessing it. * - * \since 1.13.0 + * \since 1.12.0 * */ H5_DLL hid_t H5Mopen(hid_t loc_id, const char *name, hid_t mapl_id); @@ -208,7 +207,10 @@ H5_DLL hid_t H5Mget_val_type(hid_t map_id); * \details H5Mget_create_plist() returns an identifier for a copy of the * creation property list for a map object specified by \p map_id. * - * \since 1.13.0 + * The creation property list identifier should be released with + * H5Pclose() to prevent resource leaks. + * + * \since 1.12.0 * */ H5_DLL hid_t H5Mget_create_plist(hid_t map_id); diff --git a/src/H5O.c b/src/H5O.c index 72f9d420514..d75f0467d64 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -93,9 +92,9 @@ hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t opened_type; - void * opened_obj = NULL; + void *opened_obj = NULL; H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; @@ -162,9 +161,9 @@ hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t opened_type; - void * opened_obj = NULL; + void *opened_obj = NULL; H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; @@ -223,10 +222,10 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_ite hid_t H5Oopen_by_token(hid_t loc_id, H5O_token_t token) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ H5I_type_t opened_type; /* Opened object type */ - void * opened_obj = NULL; /* Opened object */ + void *opened_obj = NULL; /* Opened object */ H5VL_loc_params_t loc_params; /* Location parameters */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -286,8 +285,8 @@ H5Oopen_by_token(hid_t loc_id, H5O_token_t token) herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t * vol_obj1 = NULL; /* object of obj_id */ - H5VL_object_t * vol_obj2 = NULL; /* object of new_loc_id */ + H5VL_object_t *vol_obj1 = NULL; /* object of obj_id */ + H5VL_object_t *vol_obj2 = NULL; /* object of new_loc_id */ H5VL_object_t tmp_vol_obj; /* Temporary object */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; @@ -380,7 +379,7 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid herr_t H5Oincr_refcount(hid_t object_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; @@ -430,7 +429,7 @@ H5Oincr_refcount(hid_t object_id) herr_t H5Odecr_refcount(hid_t object_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -473,7 +472,7 @@ H5Odecr_refcount(hid_t object_id) htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; htri_t ret_value = FAIL; /* Return value */ @@ -524,7 +523,7 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) herr_t H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -569,7 +568,7 @@ H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields) herr_t H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -627,7 +626,7 @@ herr_t H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info2_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -686,7 +685,7 @@ H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index_t idx_type, H herr_t H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -732,7 +731,7 @@ herr_t H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_native_info_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -790,7 +789,7 @@ herr_t H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_native_info_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -854,7 +853,7 @@ H5Oget_native_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_t herr_t H5Oset_comment(hid_t obj_id, const char *comment) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -902,7 +901,7 @@ H5Oset_comment(hid_t obj_id, const char *comment) herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -955,7 +954,7 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_ ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ @@ -998,7 +997,7 @@ H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ @@ -1071,7 +1070,7 @@ herr_t H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -1145,7 +1144,7 @@ herr_t H5Ovisit_by_name3(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -1291,7 +1290,7 @@ H5O_disable_mdc_flushes(H5O_loc_t *oloc) herr_t H5Odisable_mdc_flushes(hid_t object_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1359,7 +1358,7 @@ H5O_enable_mdc_flushes(H5O_loc_t *oloc) herr_t H5Oenable_mdc_flushes(hid_t object_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1432,7 +1431,7 @@ H5O_are_mdc_flushes_disabled(H5O_loc_t *oloc, hbool_t *are_disabled) herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index 10c9edefb1d..bbe02274c5a 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -32,16 +31,16 @@ #include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void * H5O__ainfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__ainfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__ainfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__ainfo_copy(const void *_mesg, void *_dest); +static void *H5O__ainfo_copy(const void *_mesg, void *_dest); static size_t H5O__ainfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__ainfo_free(void *_mesg); static herr_t H5O__ainfo_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); static herr_t H5O__ainfo_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static void * H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, +static void *H5O__ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); static herr_t H5O__ainfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info); @@ -52,7 +51,7 @@ const H5O_msg_class_t H5O_MSG_AINFO[1] = {{ H5O_AINFO_ID, /*message id number */ "ainfo", /*message name for debugging */ sizeof(H5O_ainfo_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__ainfo_decode, /*decode message */ H5O__ainfo_encode, /*encode message */ H5O__ainfo_copy, /*copy the native value */ @@ -99,9 +98,9 @@ static void * H5O__ainfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_ainfo_t * ainfo = NULL; /* Attribute info */ + H5O_ainfo_t *ainfo = NULL; /* Attribute info */ unsigned char flags; /* Flags for encoding attribute info */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -225,8 +224,8 @@ static void * H5O__ainfo_copy(const void *_mesg, void *_dest) { const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - H5O_ainfo_t * dest = (H5O_ainfo_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_ainfo_t *dest = (H5O_ainfo_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -396,7 +395,7 @@ H5O__ainfo_copy_file(H5F_t H5_ATTR_NDEBUG_UNUSED *file_src, void *mesg_src, H5F_ { H5O_ainfo_t *ainfo_src = (H5O_ainfo_t *)mesg_src; H5O_ainfo_t *ainfo_dst = NULL; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index bad89ae51cb..8a6abbecdc5 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -326,7 +325,7 @@ H5O__alloc_null(H5F_t *f, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new { H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */ - H5O_mesg_t * alloc_msg; /* Pointer to null message to allocate out of */ + H5O_mesg_t *alloc_msg; /* Pointer to null message to allocate out of */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -496,7 +495,7 @@ H5O__alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, size hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ size_t delta; /* Change in chunk's size */ size_t aligned_size = H5O_ALIGN_OH(oh, size); - uint8_t * old_image; /* Old address of chunk's image in memory */ + uint8_t *old_image; /* Old address of chunk's image in memory */ size_t old_size; /* Old size of chunk */ htri_t was_extended; /* If chunk can be extended */ size_t extend_msg = 0; /* Index of null message to extend */ @@ -868,12 +867,12 @@ herr_t H5O__alloc_chunk(H5F_t *f, H5O_t *oh, size_t size, size_t found_null, const H5O_msg_alloc_info_t *found_msg, size_t *new_idx) { - H5O_mesg_t * curr_msg; /* Pointer to current message to operate on */ + H5O_mesg_t *curr_msg; /* Pointer to current message to operate on */ H5O_chunk_proxy_t *chk_proxy; /* Chunk that message is in */ size_t cont_size; /*continuation message size */ size_t idx; /* Message number */ - uint8_t * p = NULL; /* Pointer into new chunk image */ - H5O_cont_t * cont = NULL; /*native continuation message */ + uint8_t *p = NULL; /* Pointer into new chunk image */ + H5O_cont_t *cont = NULL; /*native continuation message */ unsigned chunkno; /* Chunk allocated */ haddr_t new_chunk_addr; /* Address of new chunk in file */ unsigned u; /* Local index variable */ @@ -1219,16 +1218,16 @@ H5O__alloc_find_best_null(const H5O_t *oh, size_t size, size_t *mesg_idx) else /* If we've got more than one exact fit, choose the one in the earliest chunk */ if (oh->mesg[idx].chunkno < oh->mesg[found_null].chunkno) { - found_null = (ssize_t)idx; + found_null = (ssize_t)idx; - /* If we found an exact fit in object header chunk #0, we can get out */ - /* (Could extend this to look for earliest message in - * chunk #0 - QAK, 2016/10/21) - */ - if (0 == oh->mesg[idx].chunkno) - break; - } /* end if */ - } /* end if */ + /* If we found an exact fit in object header chunk #0, we can get out */ + /* (Could extend this to look for earliest message in + * chunk #0 - QAK, 2016/10/21) + */ + if (0 == oh->mesg[idx].chunkno) + break; + } /* end if */ + } /* end if */ /* Look for null message that's larger than needed */ else if (oh->mesg[idx].raw_size > size) { /* Keep first one found */ @@ -1426,7 +1425,7 @@ static htri_t H5O__move_cont(H5F_t *f, H5O_t *oh, unsigned cont_u) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that continuation message is in */ - H5O_mesg_t * cont_msg; /* Pointer to the continuation message */ + H5O_mesg_t *cont_msg; /* Pointer to the continuation message */ unsigned deleted_chunkno; /* Chunk # to delete */ hbool_t chk_dirtied = FALSE; /* Flags for unprotecting chunk */ htri_t ret_value = TRUE; /* Return value */ @@ -1849,7 +1848,7 @@ H5O__move_msgs_forward(H5F_t *f, H5O_t *oh) null_msg->raw + null_msg->raw_size, gap_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert gap in chunk") - /* Re-use message # for new null message taking place of non-null message */ + /* Reuse message # for new null message taking place of non-null message */ new_null_msg = v; } /* end if */ else { @@ -2367,10 +2366,10 @@ H5O__condense_header(H5F_t *f, H5O_t *oh) static herr_t H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) { - H5O_chunk_t * chunk = &oh->chunk[chunkno]; /* Chunk to shrink */ + H5O_chunk_t *chunk = &oh->chunk[chunkno]; /* Chunk to shrink */ H5O_chunk_proxy_t *chk_proxy = NULL; /* Metadata cache proxy for chunk to shrink */ - H5O_mesg_t * curr_msg; /* Current message to examine */ - uint8_t * old_image = chunk->image; /* Old address of chunk's image in memory */ + H5O_mesg_t *curr_msg; /* Current message to examine */ + uint8_t *old_image = chunk->image; /* Old address of chunk's image in memory */ size_t old_size = chunk->size; /* Old size of chunk */ size_t new_size = chunk->size - chunk->gap; /* Size of shrunk chunk */ size_t total_msg_size; /* Size of the messages in this chunk */ @@ -2407,7 +2406,7 @@ H5O__alloc_shrink_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno) if (curr_msg->raw + curr_msg->raw_size < old_image + new_size - sizeof_chksum) { unsigned v; /* Index */ H5O_mesg_t *curr_msg2; - uint8_t * src = curr_msg->raw + curr_msg->raw_size; /* Source location */ + uint8_t *src = curr_msg->raw + curr_msg->raw_size; /* Source location */ /* Slide down the raw data */ HDmemmove(curr_msg->raw - sizeof_msghdr, src, diff --git a/src/H5Oattr.c b/src/H5Oattr.c index db53eafb6a9..cb06f25a725 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -31,7 +30,7 @@ static size_t H5O__attr_size(const H5F_t *f, const void *_mesg); static herr_t H5O__attr_free(void *mesg); static herr_t H5O__attr_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static void * H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, void *native_src, +static void *H5O__attr_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, void *udata); static herr_t H5O__attr_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, H5O_copy_t *cpy_info); @@ -65,7 +64,7 @@ const H5O_msg_class_t H5O_MSG_ATTR[1] = {{ H5O_ATTR_ID, /* message id number */ "attribute", /* message name for debugging */ sizeof(H5A_t), /* native message size */ - H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ + H5O_SHARE_IS_SHARABLE, /* messages are shareable? */ H5O__attr_shared_decode, /* decode message */ H5O__attr_shared_encode, /* encode message */ H5O__attr_copy, /* copy the native value */ @@ -120,14 +119,14 @@ static void * H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p) { - H5A_t * attr = NULL; + H5A_t *attr = NULL; H5S_extent_t *extent; /*extent dimensionality information */ size_t name_len; /*attribute name length */ size_t dt_size; /* Datatype size */ hssize_t sds_size; /* Signed Dataspace size */ hsize_t ds_size; /* Dataspace size */ unsigned flags = 0; /* Attribute flags */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -222,10 +221,6 @@ H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, u else p += attr->shared->ds_size; - /* Get the datatype's size */ - if (0 == (dt_size = H5T_get_size(attr->shared->dt))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size") - /* Get the datatype & dataspace sizes */ if (0 == (dt_size = H5T_get_size(attr->shared->dt))) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "unable to get datatype size") @@ -235,6 +230,9 @@ H5O__attr_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, u /* Compute the size of the data */ H5_CHECKED_ASSIGN(attr->shared->data_size, size_t, ds_size * (hsize_t)dt_size, hsize_t); + /* Check if multiplication has overflown */ + if ((attr->shared->data_size / dt_size) != ds_size) + HGOTO_ERROR(H5E_RESOURCE, H5E_OVERFLOW, NULL, "data size exceeds addressable range") /* Go get the data */ if (attr->shared->data_size) { @@ -789,7 +787,7 @@ static herr_t H5O__attr_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const H5A_t *mesg = (const H5A_t *)_mesg; - const char * s; /* Temporary string pointer */ + const char *s; /* Temporary string pointer */ char buf[128]; /* Temporary string buffer */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index b21a6549c0e..88f621ef439 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -49,7 +48,7 @@ /* User data for iteration when converting attributes to dense storage */ typedef struct { - H5F_t * f; /* Pointer to file for insertion */ + H5F_t *f; /* Pointer to file for insertion */ H5O_ainfo_t *ainfo; /* Attribute info struct */ } H5O_iter_cvt_t; @@ -75,7 +74,7 @@ typedef struct { /* User data for iteration when renaming an attribute */ typedef struct { /* down */ - H5F_t * f; /* Pointer to file attribute is in */ + H5F_t *f; /* Pointer to file attribute is in */ const char *old_name; /* Old name of attribute */ const char *new_name; /* New name of attribute */ @@ -86,7 +85,7 @@ typedef struct { /* User data for iteration when removing an attribute */ typedef struct { /* down */ - H5F_t * f; /* Pointer to file attribute is in */ + H5F_t *f; /* Pointer to file attribute is in */ const char *name; /* Name of attribute to open */ /* up */ @@ -150,7 +149,7 @@ H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_U unsigned *oh_modified, void *_udata /*in,out*/) { H5O_iter_cvt_t *udata = (H5O_iter_cvt_t *)_udata; /* Operator user data */ - H5A_t * attr = (H5A_t *)mesg->native; /* Pointer to attribute to insert */ + H5A_t *attr = (H5A_t *)mesg->native; /* Pointer to attribute to insert */ herr_t ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -194,7 +193,7 @@ H5O__attr_to_dense_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_U herr_t H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ herr_t ret_value = SUCCEED; /* Return value */ @@ -239,19 +238,19 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) /* Check if switching to "dense" attribute storage is possible */ if (!H5F_addr_defined(ainfo.fheap_addr)) { - htri_t sharable; /* Whether the attribute will be shared */ + htri_t shareable; /* Whether the attribute will be shared */ size_t raw_size = 0; /* Raw size of message */ - /* Check for attribute being sharable */ - if ((sharable = H5SM_can_share(loc->file, NULL, NULL, H5O_ATTR_ID, attr)) < 0) + /* Check for attribute being shareable */ + if ((shareable = H5SM_can_share(loc->file, NULL, NULL, H5O_ATTR_ID, attr)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADMESG, FAIL, "can't determine attribute sharing status") - else if (sharable == FALSE) { + else if (shareable == FALSE) { /* Compute the size needed to encode the attribute */ raw_size = (H5O_MSG_ATTR->raw_size)(loc->file, FALSE, attr); } /* end if */ /* Check for condititions for switching to "dense" attribute storage are met */ - if (ainfo.nattrs == oh->max_compact || (!sharable && raw_size >= H5O_MESG_MAX_SIZE)) { + if (ainfo.nattrs == oh->max_compact || (!shareable && raw_size >= H5O_MESG_MAX_SIZE)) { H5O_iter_cvt_t udata; /* User data for callback */ H5O_mesg_operator_t op; /* Wrapper for operator */ @@ -314,7 +313,7 @@ H5O__attr_create(const H5O_loc_t *loc, H5A_t *attr) else /* Append new message to object header */ if (H5O__msg_append_real(loc->file, oh, H5O_MSG_ATTR, 0, 0, attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new attribute in header") + HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create new attribute in header") /* Increment reference count for shared attribute object for the * object handle created by the caller function H5A__create. The count @@ -434,12 +433,12 @@ H5O__attr_open_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned sequence, H5A_t * H5O__attr_open_by_name(const H5O_loc_t *loc, const char *name) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ - H5A_t * exist_attr = NULL; /* Existing opened attribute object */ - H5A_t * opened_attr = NULL; /* Newly opened attribute object */ + H5A_t *exist_attr = NULL; /* Existing opened attribute object */ + H5A_t *opened_attr = NULL; /* Newly opened attribute object */ htri_t found_open_attr = FALSE; /* Whether opened object is found */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -567,10 +566,10 @@ H5A_t * H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { H5A_attr_iter_op_t attr_op; /* Attribute operator */ - H5A_t * exist_attr = NULL; /* Existing opened attribute object */ - H5A_t * opened_attr = NULL; /* Newly opened attribute object */ + H5A_t *exist_attr = NULL; /* Existing opened attribute object */ + H5A_t *opened_attr = NULL; /* Newly opened attribute object */ htri_t found_open_attr = FALSE; /* Whether opened object is found */ - H5A_t * ret_value = NULL; /* Return value */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -638,7 +637,7 @@ H5O__attr_open_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t static htri_t H5O__attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char *name_to_open) { - hid_t * attr_id_list = NULL; /* List of IDs for opened attributes */ + hid_t *attr_id_list = NULL; /* List of IDs for opened attributes */ unsigned long loc_fnum; /* File serial # for object */ size_t num_open_attr; /* Number of opened attributes */ htri_t ret_value = FALSE; /* Return value */ @@ -789,7 +788,7 @@ static herr_t H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata /*in,out*/) { - H5O_iter_wrt_t * udata = (H5O_iter_wrt_t *)_udata; /* Operator user data */ + H5O_iter_wrt_t *udata = (H5O_iter_wrt_t *)_udata; /* Operator user data */ H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ herr_t ret_value = H5_ITER_CONT; /* Return value */ @@ -870,7 +869,7 @@ H5O__attr_write_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUS herr_t H5O__attr_write(const H5O_loc_t *loc, H5A_t *attr) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ herr_t ret_value = SUCCEED; /* Return value */ @@ -991,7 +990,7 @@ static herr_t H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNUSED sequence, unsigned *oh_modified, void *_udata /*in,out*/) { - H5O_iter_ren_t * udata = (H5O_iter_ren_t *)_udata; /* Operator user data */ + H5O_iter_ren_t *udata = (H5O_iter_ren_t *)_udata; /* Operator user data */ H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ herr_t ret_value = H5_ITER_CONT; /* Return value */ @@ -1115,7 +1114,7 @@ H5O__attr_rename_mod_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR herr_t H5O__attr_rename(const H5O_loc_t *loc, const char *old_name, const char *new_name) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1202,7 +1201,7 @@ herr_t H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ herr_t ret_value = FAIL; /* Return value */ @@ -1497,7 +1496,7 @@ H5O__attr_remove_cb(H5O_t *oh, H5O_mesg_t *mesg /*in,out*/, unsigned H5_ATTR_UNU herr_t H5O__attr_remove(const H5O_loc_t *loc, const char *name) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1578,7 +1577,7 @@ H5O__attr_remove(const H5O_loc_t *loc, const char *name) herr_t H5O__attr_remove_by_idx(const H5O_loc_t *loc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ H5A_attr_table_t atable = {0, NULL}; /* Table of attributes */ @@ -1759,7 +1758,7 @@ H5O__attr_exists_cb(H5O_t H5_ATTR_UNUSED *oh, H5O_mesg_t *mesg /*in,out*/, unsig htri_t H5O__attr_exists(const H5O_loc_t *loc, const char *name) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ret_value = FAIL; /* Return value */ diff --git a/src/H5Obogus.c b/src/H5Obogus.c index c7fcdb901de..33f7fe22729 100644 --- a/src/H5Obogus.c +++ b/src/H5Obogus.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -36,7 +35,7 @@ #ifdef H5O_ENABLE_BOGUS /* PRIVATE PROTOTYPES */ -static void * H5O__bogus_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__bogus_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__bogus_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); static size_t H5O__bogus_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); @@ -47,7 +46,7 @@ const H5O_msg_class_t H5O_MSG_BOGUS_VALID[1] = {{ H5O_BOGUS_VALID_ID, /*message id number */ "bogus valid", /*message name for debugging */ 0, /*native message size */ - H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ + H5O_SHARE_IS_SHARABLE, /* messages are shareable? */ H5O__bogus_decode, /*decode message */ H5O__bogus_encode, /*encode message */ NULL, /*copy the native value */ @@ -71,7 +70,7 @@ const H5O_msg_class_t H5O_MSG_BOGUS_INVALID[1] = {{ H5O_BOGUS_INVALID_ID, /*message id number */ "bogus invalid", /*message name for debugging */ 0, /*native message size */ - H5O_SHARE_IS_SHARABLE, /* messages are sharable? */ + H5O_SHARE_IS_SHARABLE, /* messages are shareable? */ H5O__bogus_decode, /*decode message */ H5O__bogus_encode, /*encode message */ NULL, /*copy the native value */ @@ -110,7 +109,7 @@ H5O__bogus_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_bogus_t *mesg = NULL; - void * ret_value; /* Return value */ + void *ret_value; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Obtreek.c b/src/H5Obtreek.c index a78336673ec..d38cab542d2 100644 --- a/src/H5Obtreek.c +++ b/src/H5Obtreek.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -25,10 +24,10 @@ #include "H5Opkg.h" /* Object headers */ #include "H5MMprivate.h" /* Memory management */ -static void * H5O__btreek_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__btreek_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__btreek_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__btreek_copy(const void *_mesg, void *_dest); +static void *H5O__btreek_copy(const void *_mesg, void *_dest); static size_t H5O__btreek_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__btreek_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -37,7 +36,7 @@ const H5O_msg_class_t H5O_MSG_BTREEK[1] = {{ H5O_BTREEK_ID, /*message id number */ "v1 B-tree 'K' values", /*message name for debugging */ sizeof(H5O_btreek_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__btreek_decode, /*decode message */ H5O__btreek_encode, /*encode message */ H5O__btreek_copy, /*copy the native value */ @@ -78,7 +77,7 @@ H5O__btreek_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsig unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_btreek_t *mesg; /* Native message */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -158,8 +157,8 @@ static void * H5O__btreek_copy(const void *_mesg, void *_dest) { const H5O_btreek_t *mesg = (const H5O_btreek_t *)_mesg; - H5O_btreek_t * dest = (H5O_btreek_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_btreek_t *dest = (H5O_btreek_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 62dc2f24803..31bea2e1d00 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -60,7 +59,7 @@ static herr_t H5O__cache_get_initial_load_size(void *udata, size_t *image_len); static herr_t H5O__cache_get_final_load_size(const void *image_ptr, size_t image_len, void *udata, size_t *actual_len); static htri_t H5O__cache_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5O__cache_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5O__cache_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5O__cache_image_len(const void *thing, size_t *image_len); static herr_t H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5O__cache_notify(H5AC_notify_action_t action, void *_thing); @@ -68,7 +67,7 @@ static herr_t H5O__cache_free_icr(void *thing); static herr_t H5O__cache_chk_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5O__cache_chk_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5O__cache_chk_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5O__cache_chk_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5O__cache_chk_image_len(const void *thing, size_t *image_len); static herr_t H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing); @@ -78,8 +77,8 @@ static herr_t H5O__cache_chk_free_icr(void *thing); static herr_t H5O__prefix_deserialize(const uint8_t *image, H5O_cache_ud_t *udata); /* Chunk routines */ -static herr_t H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, - H5O_common_cache_ud_t *udata, hbool_t *dirty); +static herr_t H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t chunk_size, const uint8_t *image, + size_t len, H5O_common_cache_ud_t *udata, hbool_t *dirty); static herr_t H5O__chunk_serialize(const H5F_t *f, H5O_t *oh, unsigned chunkno); /* Misc. routines */ @@ -229,7 +228,7 @@ H5O__cache_get_final_load_size(const void *image, size_t H5_ATTR_NDEBUG_UNUSED i static htri_t H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ htri_t ret_value = TRUE; /* Return value */ @@ -275,7 +274,7 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) * * Note that the object header is read with with a speculative read. * If the initial read is too small, make note of this fact and return - * without error. H5C__load_entry() will note the size discrepency + * without error. H5C__load_entry() will note the size discrepancy * and retry the deserialize operation with the correct size read. * * Return: Success: Pointer to in core representation @@ -287,11 +286,11 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata) *------------------------------------------------------------------------- */ static void * -H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t *dirty) +H5O__cache_deserialize(const void *image, size_t len, void *_udata, hbool_t *dirty) { - H5O_t * oh = NULL; /* Object header read in */ + H5O_t *oh = NULL; /* Object header read in */ H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -333,7 +332,7 @@ H5O__cache_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void oh->proxy = NULL; /* Parse the first chunk */ - if (H5O__chunk_deserialize(oh, udata->common.addr, udata->chunk0_size, (const uint8_t *)image, + if (H5O__chunk_deserialize(oh, udata->common.addr, udata->chunk0_size, (const uint8_t *)image, len, &(udata->common), dirty) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't deserialize first object header chunk") @@ -403,7 +402,7 @@ H5O__cache_image_len(const void *_thing, size_t *image_len) static herr_t H5O__cache_serialize(const H5F_t *f, void *image, size_t len, void *_thing) { - H5O_t * oh = (H5O_t *)_thing; /* Object header to encode */ + H5O_t *oh = (H5O_t *)_thing; /* Object header to encode */ uint8_t *chunk_image; /* Pointer to object header prefix buffer */ herr_t ret_value = SUCCEED; /* Return value */ @@ -696,7 +695,7 @@ H5O__cache_chk_get_initial_load_size(void *_udata, size_t *image_len) static htri_t H5O__cache_chk_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */ htri_t ret_value = TRUE; /* Return value */ @@ -736,11 +735,11 @@ H5O__cache_chk_verify_chksum(const void *_image, size_t len, void *_udata) *------------------------------------------------------------------------- */ static void * -H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t *dirty) +H5O__cache_chk_deserialize(const void *image, size_t len, void *_udata, hbool_t *dirty) { - H5O_chunk_proxy_t * chk_proxy = NULL; /* Chunk proxy object */ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk proxy object */ H5O_chk_cache_ud_t *udata = (H5O_chk_cache_ud_t *)_udata; /* User data for callback */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -763,7 +762,7 @@ H5O__cache_chk_deserialize(const void *image, size_t H5_ATTR_NDEBUG_UNUSED len, HDassert(udata->common.cont_msg_info); /* Parse the chunk */ - if (H5O__chunk_deserialize(udata->oh, udata->common.addr, udata->size, (const uint8_t *)image, + if (H5O__chunk_deserialize(udata->oh, udata->common.addr, udata->size, (const uint8_t *)image, len, &(udata->common), dirty) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't deserialize object header chunk") @@ -1107,7 +1106,7 @@ static herr_t H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) { const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ - H5O_t * oh = NULL; /* Object header read in */ + H5O_t *oh = NULL; /* Object header read in */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1275,11 +1274,11 @@ H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata) *------------------------------------------------------------------------- */ static herr_t -H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, +H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t chunk_size, const uint8_t *image, size_t len, H5O_common_cache_ud_t *udata, hbool_t *dirty) { const uint8_t *chunk_image; /* Pointer into buffer to decode */ - uint8_t * eom_ptr; /* Pointer to end of messages for a chunk */ + uint8_t *eom_ptr; /* Pointer to end of messages for a chunk */ unsigned merged_null_msgs = 0; /* Number of null messages merged together */ unsigned chunkno; /* Current chunk's index */ #ifndef NDEBUG @@ -1295,6 +1294,7 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image HDassert(oh); HDassert(H5F_addr_defined(addr)); HDassert(image); + HDassert(len); HDassert(udata->f); HDassert(udata->cont_msg_info); @@ -1315,14 +1315,16 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image oh->chunk[chunkno].addr = addr; if (chunkno == 0) /* First chunk's 'image' includes room for the object header prefix */ - oh->chunk[0].size = len + (size_t)H5O_SIZEOF_HDR(oh); + oh->chunk[0].size = chunk_size + (size_t)H5O_SIZEOF_HDR(oh); else - oh->chunk[chunkno].size = len; + oh->chunk[chunkno].size = chunk_size; if (NULL == (oh->chunk[chunkno].image = H5FL_BLK_MALLOC(chunk_image, oh->chunk[chunkno].size))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed") oh->chunk[chunkno].chunk_proxy = NULL; /* Copy disk image into chunk's image */ + if (len < oh->chunk[chunkno].size) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "attempted to copy too many disk image bytes into buffer") H5MM_memcpy(oh->chunk[chunkno].image, image, oh->chunk[chunkno].size); /* Point into chunk image to decode */ diff --git a/src/H5Ocache_image.c b/src/H5Ocache_image.c index 2603f7171ce..713fbd269fc 100644 --- a/src/H5Ocache_image.c +++ b/src/H5Ocache_image.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -40,7 +39,7 @@ static void *H5O__mdci_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__mdci_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__mdci_copy(const void *_mesg, void *_dest); +static void *H5O__mdci_copy(const void *_mesg, void *_dest); static size_t H5O__mdci_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__mdci_free(void *mesg); static herr_t H5O__mdci_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); @@ -51,7 +50,7 @@ const H5O_msg_class_t H5O_MSG_MDCI[1] = {{ H5O_MDCI_MSG_ID, /* message id number */ "mdci", /* message name for debugging */ sizeof(H5O_mdci_t), /* native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__mdci_decode, /* decode message */ H5O__mdci_encode, /* encode message */ H5O__mdci_copy, /* copy method */ @@ -95,7 +94,7 @@ H5O__mdci_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_mdci_t *mesg; /* Native message */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -173,8 +172,8 @@ static void * H5O__mdci_copy(const void *_mesg, void *_dest) { const H5O_mdci_t *mesg = (const H5O_mdci_t *)_mesg; - H5O_mdci_t * dest = (H5O_mdci_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_mdci_t *dest = (H5O_mdci_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index 66e11c8216b..c37a2a6fe9a 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -412,12 +411,12 @@ H5O__chunk_dest(H5O_chunk_proxy_t *chk_proxy) HDassert(chk_proxy); /* Decrement reference count of object header */ - if (chk_proxy->oh && H5O__dec_rc(chk_proxy->oh) < 0) + if (H5O__dec_rc(chk_proxy->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count on object header") +done: /* Release the chunk proxy object */ chk_proxy = H5FL_FREE(H5O_chunk_proxy_t, chk_proxy); -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5O__chunk_dest() */ diff --git a/src/H5Ocont.c b/src/H5Ocont.c index 080225a08c0..1fd1aea578b 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -47,7 +46,7 @@ const H5O_msg_class_t H5O_MSG_CONT[1] = {{ H5O_CONT_ID, /*message id number */ "hdr continuation", /*message name for debugging */ sizeof(H5O_cont_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__cont_decode, /*decode message */ H5O__cont_encode, /*encode message */ NULL, /*no copy method */ @@ -88,7 +87,7 @@ H5O__cont_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_cont_t *cont = NULL; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 6cf402ba8b3..90c7ed82ae5 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -54,13 +53,13 @@ /* Key object for skiplist of committed datatypes */ typedef struct H5O_copy_search_comm_dt_key_t { - H5T_t * dt; /* Datatype */ + H5T_t *dt; /* Datatype */ unsigned long fileno; /* File number */ } H5O_copy_search_comm_dt_key_t; /* Callback struct for building a list of committed datatypes */ typedef struct H5O_copy_search_comm_dt_ud_t { - H5SL_t * dst_dt_list; /* Skip list of committed datatypes */ + H5SL_t *dst_dt_list; /* Skip list of committed datatypes */ H5G_loc_t *dst_root_loc; /* Starting location for iteration */ H5O_loc_t obj_oloc; /* Object location (for attribute iteration callback) */ } H5O_copy_search_comm_dt_ud_t; @@ -188,9 +187,9 @@ herr_t H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) { - H5VL_object_t * vol_obj1 = NULL; /* object of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* object of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t * vol_obj2 = NULL; /* object of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* object of dst_id */ H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -334,11 +333,11 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5 H5O_type_t *obj_type, void **udata /*out*/) { H5O_addr_map_t *addr_map = NULL; /* Address mapping of object copied */ - H5O_t * oh_src = NULL; /* Object header for source object */ - H5O_t * oh_dst = NULL; /* Object header for destination object */ + H5O_t *oh_src = NULL; /* Object header for source object */ + H5O_t *oh_dst = NULL; /* Object header for destination object */ unsigned mesgno = 0; haddr_t addr_new = HADDR_UNDEF; - hbool_t * deleted = NULL; /* Array of flags indicating whether messages should be copied */ + hbool_t *deleted = NULL; /* Array of flags indicating whether messages should be copied */ hbool_t inserted = FALSE; /* Whether the destination object header has been inserted into the cache */ size_t null_msgs; /* Number of NULL messages found in each loop */ size_t orig_dst_msgs; /* Original # of messages in dest. object */ @@ -346,11 +345,11 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5 H5O_mesg_t *mesg_dst; /* Message in destination object header */ const H5O_msg_class_t *copy_type; /* Type of message to use for copying */ const H5O_obj_class_t *obj_class = NULL; /* Type of object we are copying */ - void * cpy_udata = NULL; /* User data for passing to message callbacks */ + void *cpy_udata = NULL; /* User data for passing to message callbacks */ uint64_t dst_oh_size; /* Total size of the destination OH */ size_t dst_oh_null; /* Size of the null message to add to destination OH */ size_t dst_oh_gap; /* Size of the gap in chunk #0 of destination OH */ - uint8_t * current_pos; /* Current position in destination image */ + uint8_t *current_pos; /* Current position in destination image */ size_t msghdr_size; herr_t ret_value = SUCCEED; @@ -396,7 +395,7 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5 /* Search for a matching committed datatype, building the list if * necessary */ if ((merge = H5O__copy_search_comm_dt(oloc_src->file, oh_src, oloc_dst, cpy_info)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't search for matching committed datatype") + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't search for matching committed datatype") if (merge) { /* Found a match, add to skip list and exit */ @@ -665,10 +664,15 @@ H5O__copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, H5 HDassert((oh_dst->flags & H5O_HDR_CHUNK0_SIZE) == H5O_HDR_CHUNK0_1); /* Determine whether to create gap or NULL message */ - if (delta < H5O_SIZEOF_MSGHDR_OH(oh_dst)) + if ((oh_dst->version > H5O_VERSION_1) && (delta < H5O_SIZEOF_MSGHDR_OH(oh_dst))) dst_oh_gap = delta; - else + else { + /* NULL message must be at least size of message header */ + if (delta < H5O_SIZEOF_MSGHDR_OH(oh_dst)) + delta = H5O_SIZEOF_MSGHDR_OH(oh_dst); + dst_oh_null = delta; + } /* Increase destination object header size */ dst_oh_size += delta; @@ -1069,7 +1073,7 @@ static herr_t H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, hid_t ocpypl_id, hid_t lcpl_id) { H5O_copy_t cpy_info; /* Information for copying object */ - H5P_genplist_t * ocpy_plist; /* Object copy property list created */ + H5P_genplist_t *ocpy_plist; /* Object copy property list created */ H5O_copy_dtype_merge_list_t *dt_list = NULL; /* List of datatype merge suggestions */ H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ unsigned cpy_option = 0; /* Copy options */ @@ -1094,7 +1098,7 @@ H5O__copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, hid_t if (H5P_get(ocpy_plist, H5O_CPY_OPTION_NAME, &cpy_option) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag") - /* Retrieve the marge committed datatype list */ + /* Retrieve the merge committed datatype list */ if (H5P_peek(ocpy_plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge committed datatype list") @@ -1168,7 +1172,7 @@ H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, hid_ H5G_name_t new_path; /* Copied object group hier. path */ H5O_loc_t new_oloc; /* Copied object object location */ H5G_loc_t new_loc; /* Group location of object copied */ - H5F_t * cached_dst_file; /* Cached destination file */ + H5F_t *cached_dst_file; /* Cached destination file */ hbool_t entry_inserted = FALSE; /* Flag to indicate that the new entry was inserted into a group */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1227,7 +1231,7 @@ H5O__copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, hid_ static herr_t H5O__copy_free_comm_dt_cb(void *item, void *_key, void H5_ATTR_UNUSED *_op_data) { - haddr_t * addr = (haddr_t *)item; + haddr_t *addr = (haddr_t *)item; H5O_copy_search_comm_dt_key_t *key = (H5O_copy_search_comm_dt_key_t *)_key; FUNC_ENTER_STATIC_NOERR @@ -1301,10 +1305,10 @@ H5O__copy_comm_dt_cmp(const void *_key1, const void *_key2) static herr_t H5O__copy_search_comm_dt_attr_cb(const H5A_t *attr, void *_udata) { - H5O_copy_search_comm_dt_ud_t * udata = (H5O_copy_search_comm_dt_ud_t *)_udata; - H5T_t * dt = NULL; /* Datatype */ + H5O_copy_search_comm_dt_ud_t *udata = (H5O_copy_search_comm_dt_ud_t *)_udata; + H5T_t *dt = NULL; /* Datatype */ H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - haddr_t * addr = NULL; /* Destination address */ + haddr_t *addr = NULL; /* Destination address */ hbool_t obj_inserted = FALSE; /* Object inserted into skip list */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1382,10 +1386,10 @@ static herr_t H5O__copy_search_comm_dt_check(H5O_loc_t *obj_oloc, H5O_copy_search_comm_dt_ud_t *udata) { H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - haddr_t * addr = NULL; /* Destination address */ + haddr_t *addr = NULL; /* Destination address */ hbool_t obj_inserted = FALSE; /* Object inserted into skip list */ H5A_attr_iter_op_t attr_op; /* Attribute iteration operator */ - const H5O_obj_class_t * obj_class = NULL; /* Type of object */ + const H5O_obj_class_t *obj_class = NULL; /* Type of object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1563,7 +1567,7 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*i H5O_copy_t *cpy_info) { H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - haddr_t * dst_addr; /* Destination datatype address */ + haddr_t *dst_addr; /* Destination datatype address */ H5G_loc_t dst_root_loc = {NULL, NULL}; /* Destination root group location */ H5O_copy_search_comm_dt_ud_t udata; /* Group iteration user data */ herr_t ret_value = FALSE; /* Return value */ @@ -1628,10 +1632,10 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst /*i else /* Check object and add to skip list if appropriate */ if (H5O__copy_search_comm_dt_check(&obj_oloc, &udata) < 0) { - if (H5G_loc_free(&obj_loc) < 0) - HERROR(H5E_OHDR, H5E_CANTRELEASE, "can't free location"); - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't check object") - } /* end if */ + if (H5G_loc_free(&obj_loc) < 0) + HERROR(H5E_OHDR, H5E_CANTRELEASE, "can't free location"); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't check object") + } /* end if */ /* Free location */ if (H5G_loc_free(&obj_loc) < 0) @@ -1730,7 +1734,7 @@ static herr_t H5O__copy_insert_comm_dt(H5F_t *file_src, H5O_t *oh_src, H5O_loc_t *oloc_dst, H5O_copy_t *cpy_info) { H5O_copy_search_comm_dt_key_t *key = NULL; /* Skiplist key */ - haddr_t * addr = NULL; /* Destination object address */ + haddr_t *addr = NULL; /* Destination object address */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c index f2372c1ace8..04988eb1972 100644 --- a/src/H5Ocopy_ref.c +++ b/src/H5Ocopy_ref.c @@ -153,8 +153,8 @@ static herr_t H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info) { - const hobj_ref_t * src_ref = (const hobj_ref_t *)buf_src; - hobj_ref_t * dst_ref = (hobj_ref_t *)buf_dst; + const hobj_ref_t *src_ref = (const hobj_ref_t *)buf_src; + hobj_ref_t *dst_ref = (hobj_ref_t *)buf_dst; const unsigned char zeros[H5R_OBJ_REF_BUF_SIZE] = {0}; size_t buf_size = H5R_OBJ_REF_BUF_SIZE; size_t i; /* Local index variable */ @@ -166,7 +166,7 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t /* Making equivalent references in the destination file */ for (i = 0; i < ref_count; i++) { const unsigned char *src_buf = (const unsigned char *)&src_ref[i]; - unsigned char * dst_buf = (unsigned char *)&dst_ref[i]; + unsigned char *dst_buf = (unsigned char *)&dst_ref[i]; H5O_token_t tmp_token = {0}; /* If data is not initialized, copy zeros and skip */ @@ -215,7 +215,7 @@ H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info) { const hdset_reg_ref_t *src_ref = (const hdset_reg_ref_t *)buf_src; - hdset_reg_ref_t * dst_ref = (hdset_reg_ref_t *)buf_dst; + hdset_reg_ref_t *dst_ref = (hdset_reg_ref_t *)buf_dst; const unsigned char zeros[H5R_DSET_REG_REF_BUF_SIZE] = {0}; size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; size_t i; /* Local index variable */ @@ -226,11 +226,11 @@ H5O__copy_expand_ref_region1(H5O_loc_t *src_oloc, const void *buf_src, H5O_loc_t /* Making equivalent references in the destination file */ for (i = 0; i < ref_count; i++) { const unsigned char *src_buf = (const unsigned char *)&src_ref[i]; - unsigned char * dst_buf = (unsigned char *)&dst_ref[i]; - unsigned char * data = NULL; + unsigned char *dst_buf = (unsigned char *)&dst_ref[i]; + unsigned char *data = NULL; size_t data_size; - const uint8_t * p; - uint8_t * q; + const uint8_t *p; + uint8_t *q; /* If data is not initialized, copy zeros and skip */ if (0 == HDmemcmp(src_buf, zeros, buf_size)) @@ -288,18 +288,18 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, size_t nbytes_src, H5O_loc_t *dst_oloc, H5G_loc_t *dst_root_loc, void *buf_dst, size_t ref_count, H5O_copy_t *cpy_info) { - H5T_t * dt_mem = NULL; /* Memory datatype */ - H5T_t * dt_dst = NULL; /* Destination datatype */ + H5T_t *dt_mem = NULL; /* Memory datatype */ + H5T_t *dt_dst = NULL; /* Destination datatype */ hid_t tid_mem = H5I_INVALID_HID; /* Datatype ID for memory datatype */ hid_t tid_dst = H5I_INVALID_HID; /* Datatype ID for memory datatype */ H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ size_t i; /* Local index variable */ hbool_t reg_tid_src = (tid_src == H5I_INVALID_HID); hid_t dst_loc_id = H5I_INVALID_HID; - void * conv_buf = NULL; /* Buffer for converting data */ + void *conv_buf = NULL; /* Buffer for converting data */ size_t conv_buf_size = 0; /* Buffer size */ - void * reclaim_buf = NULL; /* Buffer for reclaiming data */ - H5S_t * buf_space = NULL; /* Dataspace describing buffer */ + void *reclaim_buf = NULL; /* Buffer for reclaiming data */ + H5S_t *buf_space = NULL; /* Dataspace describing buffer */ hsize_t buf_dim[1] = {ref_count}; /* Dimension for buffer */ size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file); herr_t ret_value = SUCCEED; @@ -318,7 +318,7 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") } /* end if */ - /* create reference datatype at the destinaton file */ + /* create reference datatype at the destination file */ if (NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy") if (H5T_set_loc(dt_dst, H5F_VOL_OBJ(dst_oloc->file), H5T_LOC_DISK) < 0) { @@ -353,7 +353,7 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src, /* Making equivalent references in the destination file */ for (i = 0; i < ref_count; i++) { - H5R_ref_t * ref_ptr = (H5R_ref_t *)conv_buf; + H5R_ref_t *ref_ptr = (H5R_ref_t *)conv_buf; H5R_ref_priv_t *ref = (H5R_ref_priv_t *)&ref_ptr[i]; H5O_token_t tmp_token = {0}; diff --git a/src/H5Odbg.c b/src/H5Odbg.c index 2826bcdcecd..203d41136ef 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -155,7 +154,7 @@ H5O__assert(const H5O_t *oh) if (H5O_NULL_ID == curr_msg->type->id) free_space += curr_tot_size; else if (H5O_CONT_ID == curr_msg->type->id) { - H5O_cont_t * cont = (H5O_cont_t *)curr_msg->native; + H5O_cont_t *cont = (H5O_cont_t *)curr_msg->native; hbool_t H5_ATTR_NDEBUG_UNUSED found_chunk = FALSE; /* Found a chunk that matches */ HDassert(cont); @@ -512,7 +511,7 @@ H5O__debug_real(H5F_t *f, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int herr_t H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth) { - H5O_t * oh = NULL; /* Object header to display */ + H5O_t *oh = NULL; /* Object header to display */ H5O_loc_t loc; /* Object location for object to delete */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 2a0a32157f7..2f3bdee6e1a 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -52,7 +51,7 @@ typedef struct H5O_visit1_adapter_t { H5O_iterate1_t real_op; /* Application callback to invoke */ unsigned fields; /* Original fields passed to H5Ovisit */ - void * real_op_data; /* Application op_data */ + void *real_op_data; /* Application op_data */ } H5O_visit1_adapter_t; /********************/ @@ -122,7 +121,7 @@ H5O__iterate1_adapter(hid_t obj_id, const char *name, const H5O_info2_t *oinfo2, H5O_info1_t oinfo; /* Deprecated object info struct */ unsigned dm_fields; /* Fields for data model query */ unsigned nat_fields; /* Fields for native query */ - H5VL_object_t * vol_obj; /* Object of obj_id */ + H5VL_object_t *vol_obj; /* Object of obj_id */ H5VL_loc_params_t loc_params; /* Location parameters for VOL callback */ herr_t ret_value = H5_ITER_CONT; /* Return value */ @@ -323,10 +322,10 @@ H5O__get_info_old(H5VL_object_t *vol_obj, H5VL_loc_params_t *loc_params, H5O_inf hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ H5I_type_t opened_type; /* Opened object type */ - void * opened_obj = NULL; /* Opened object */ + void *opened_obj = NULL; /* Opened object */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ hbool_t is_native_vol_obj; @@ -387,7 +386,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) herr_t H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -427,7 +426,7 @@ H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo) herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t *oinfo, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -482,7 +481,7 @@ herr_t H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -540,7 +539,7 @@ H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H herr_t H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; hbool_t is_native_vol_obj; herr_t ret_value = SUCCEED; /* Return value */ @@ -595,7 +594,7 @@ H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields) herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info1_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; hbool_t is_native_vol_obj; herr_t ret_value = SUCCEED; /* Return value */ @@ -663,7 +662,7 @@ herr_t H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info1_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; hbool_t is_native_vol_obj; herr_t ret_value = SUCCEED; /* Return value */ @@ -750,7 +749,7 @@ H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ herr_t ret_value; /* Return value */ @@ -825,7 +824,7 @@ herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data, hid_t lapl_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ herr_t ret_value; /* Return value */ @@ -913,7 +912,7 @@ herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data, unsigned fields) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ hbool_t is_native_vol_obj; @@ -1002,7 +1001,7 @@ herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate1_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5VL_object_t * vol_obj; /* Object of loc_id */ + H5VL_object_t *vol_obj; /* Object of loc_id */ H5VL_loc_params_t loc_params; H5O_visit1_adapter_t shim_data; /* Adapter for passing app callback & user data */ hbool_t is_native_vol_obj; diff --git a/src/H5Odrvinfo.c b/src/H5Odrvinfo.c index 8bebc6d3cd7..296be0a0043 100644 --- a/src/H5Odrvinfo.c +++ b/src/H5Odrvinfo.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -25,10 +24,10 @@ #include "H5Opkg.h" /* Object headers */ #include "H5MMprivate.h" /* Memory management */ -static void * H5O__drvinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__drvinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__drvinfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__drvinfo_copy(const void *_mesg, void *_dest); +static void *H5O__drvinfo_copy(const void *_mesg, void *_dest); static size_t H5O__drvinfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__drvinfo_reset(void *_mesg); static herr_t H5O__drvinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -38,7 +37,7 @@ const H5O_msg_class_t H5O_MSG_DRVINFO[1] = {{ H5O_DRVINFO_ID, /*message id number */ "driver info", /*message name for debugging */ sizeof(H5O_drvinfo_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__drvinfo_decode, /*decode message */ H5O__drvinfo_encode, /*encode message */ H5O__drvinfo_copy, /*copy the native value */ @@ -80,7 +79,7 @@ H5O__drvinfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_drvinfo_t *mesg; /* Native message */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -175,8 +174,8 @@ static void * H5O__drvinfo_copy(const void *_mesg, void *_dest) { const H5O_drvinfo_t *mesg = (const H5O_drvinfo_t *)_mesg; - H5O_drvinfo_t * dest = (H5O_drvinfo_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_drvinfo_t *dest = (H5O_drvinfo_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 1be9522beb1..b6aaa7a9c6c 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -27,9 +26,9 @@ /* PRIVATE PROTOTYPES */ static herr_t H5O__dtype_encode(H5F_t *f, uint8_t *p, const void *mesg); -static void * H5O__dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__dtype_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); -static void * H5O__dtype_copy(const void *_mesg, void *_dest); +static void *H5O__dtype_copy(const void *_mesg, void *_dest); static size_t H5O__dtype_size(const H5F_t *f, const void *_mesg); static herr_t H5O__dtype_reset(void *_mesg); static herr_t H5O__dtype_free(void *_mesg); @@ -37,7 +36,7 @@ static herr_t H5O__dtype_set_share(void *_mesg, const H5O_shared_t *sh); static htri_t H5O__dtype_can_share(const void *_mesg); static herr_t H5O__dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata); -static void * H5O__dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, void *native_src, +static void *H5O__dtype_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, H5O_copy_t *cpy_info, void *udata); static herr_t H5O__dtype_shared_post_copy_upd(const H5O_loc_t *src_oloc, const void *mesg_src, @@ -89,7 +88,7 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ H5O_DTYPE_ID, /* message id number */ "datatype", /* message name for debugging */ sizeof(H5T_t), /* native message size */ - H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are shareable? */ H5O__dtype_shared_decode, /* decode message */ H5O__dtype_shared_encode, /* encode message */ H5O__dtype_copy, /* copy the native value */ @@ -109,35 +108,46 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{ }}; /*------------------------------------------------------------------------- - * Function: H5O__dtype_decode_helper + * Function: H5O__dtype_decode_helper * - * Purpose: Decodes a datatype + * Purpose: Decodes a datatype * - * Return: TRUE if we can upgrade the parent type's version even + * Return: TRUE if we can upgrade the parent type's version even * with strict format checks * FALSE if we cannot - * Negative on failure - * - * Programmer: Robb Matzke - * Monday, December 8, 1997 - * + * NEGATIVE on failure *------------------------------------------------------------------------- */ static htri_t -H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t *dt) +H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t *dt, hbool_t skip, + const uint8_t *p_end) { - unsigned flags, version; - unsigned i; - size_t z; - htri_t ret_value = FALSE; /* Return value */ + unsigned flags; + unsigned version; + htri_t ret_value = FALSE; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - /* check args */ HDassert(pp && *pp); HDassert(dt && dt->shared); + /* XXX NOTE! + * + * H5Tencode() does not take a buffer size, so normal bounds checking in + * that case is impossible. + * + * Instead of using our normal H5_IS_BUFFER_OVERFLOW macro, use + * H5_IS_KNOWN_BUFFER_OVERFLOW, which will skip the check when the + * we're decoding a buffer from H5Tconvert(). + * + * Even if this is fixed at some point in the future, as long as we + * support the old, size-less API call, we will need to use the modified + * macros. + */ + /* Version, class & flags */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 4, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); UINT32DECODE(*pp, flags); version = (flags >> 4) & 0x0f; if (version < H5O_DTYPE_VERSION_1 || version > H5O_DTYPE_VERSION_LATEST) @@ -147,8 +157,14 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t flags >>= 8; /* Size */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 4, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); UINT32DECODE(*pp, dt->shared->size); + /* Check for invalid datatype size */ + if (dt->shared->size == 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "invalid datatype size") + switch (dt->shared->type) { case H5T_INTEGER: /* @@ -158,6 +174,8 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE; + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 2 + 2, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; @@ -175,7 +193,7 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t /* VAX order if both 1st and 6th bits are turned on*/ if (flags & 0x40) dt->shared->u.atomic.order = H5T_ORDER_VAX; - } /* end if */ + } dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO; @@ -194,21 +212,40 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown floating-point normalization") - } /* end switch */ + } dt->shared->u.atomic.u.f.sign = (flags >> 8) & 0xff; + + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 2 + 2, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); + + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 1 + 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); dt->shared->u.atomic.u.f.epos = *(*pp)++; dt->shared->u.atomic.u.f.esize = *(*pp)++; - HDassert(dt->shared->u.atomic.u.f.esize > 0); + if (dt->shared->u.atomic.u.f.esize == 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "exponent size can't be zero") + + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 1 + 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); dt->shared->u.atomic.u.f.mpos = *(*pp)++; dt->shared->u.atomic.u.f.msize = *(*pp)++; - HDassert(dt->shared->u.atomic.u.f.msize > 0); + if (dt->shared->u.atomic.u.f.msize == 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "mantissa size can't be zero") + + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 4, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); UINT32DECODE(*pp, dt->shared->u.atomic.u.f.ebias); break; - case H5T_TIME: /* Time datatypes */ + case H5T_TIME: + /* + * Time datatypes... + */ dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 2, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; @@ -233,29 +270,42 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE; dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO; dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO; + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 2 + 2, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); UINT16DECODE(*pp, dt->shared->u.atomic.offset); UINT16DECODE(*pp, dt->shared->u.atomic.prec); break; - case H5T_OPAQUE: + case H5T_OPAQUE: { + size_t z; + /* * Opaque types... */ + + /* The opaque tag flag field must be aligned */ z = flags & (H5T_OPAQUE_TAG_MAX - 1); - HDassert(0 == (z & 0x7)); /*must be aligned*/ + if (0 != (z & 0x7)) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "opaque flag field must be aligned") + if (NULL == (dt->shared->u.opaque.tag = (char *)H5MM_malloc(z + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, z, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); H5MM_memcpy(dt->shared->u.opaque.tag, *pp, z); dt->shared->u.opaque.tag[z] = '\0'; + *pp += z; break; + } case H5T_COMPOUND: { + unsigned nmembs; /* Number of compound members */ unsigned offset_nbytes; /* Size needed to encode member offsets */ size_t max_memb_pos = 0; /* Maximum member covered, so far */ unsigned max_version = 0; /* Maximum member version */ unsigned upgrade_to = 0; /* Version number we can "soft" upgrade to */ - unsigned j; /* Compute the # of bytes required to store a member offset */ offset_nbytes = H5VM_limit_enc_size((uint64_t)dt->shared->size); @@ -263,76 +313,146 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t /* * Compound datatypes... */ - dt->shared->u.compnd.nmembs = flags & 0xffff; - if (dt->shared->u.compnd.nmembs == 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid number of members: %u", - dt->shared->u.compnd.nmembs) - dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs; - dt->shared->u.compnd.memb = - (H5T_cmemb_t *)H5MM_calloc(dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)); - dt->shared->u.compnd.memb_size = 0; - if (NULL == dt->shared->u.compnd.memb) + nmembs = flags & 0xffff; + if (nmembs == 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid number of members: %u", nmembs) + if (NULL == + (dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_calloc(nmembs * sizeof(H5T_cmemb_t)))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed") - for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { - unsigned ndims = 0; /* Number of dimensions of the array field */ - htri_t can_upgrade; /* Whether we can upgrade this type's version */ - hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */ - H5T_t * array_dt; /* Temporary pointer to the array datatype */ - H5T_t * temp_type; /* Temporary pointer to the field's datatype */ + dt->shared->u.compnd.nalloc = nmembs; + + if (dt->shared->u.compnd.memb_size != 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "member size not initialized to zero") + + for (dt->shared->u.compnd.nmembs = 0; dt->shared->u.compnd.nmembs < nmembs; + dt->shared->u.compnd.nmembs++) { + + size_t actual_name_length = 0; /* Actual length of name */ + unsigned ndims = 0; /* Number of dimensions of the array field */ + htri_t can_upgrade; /* Whether we can upgrade this type's version */ + hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */ + H5T_t *array_dt; /* Temporary pointer to the array datatype */ + H5T_t *temp_type; /* Temporary pointer to the field's datatype */ + + /* Get the length of the field name */ + if (!skip) { + /* There is a realistic buffer end, so check bounds */ + + size_t max = (size_t)(p_end - *pp + 1); /* Max possible name length */ + + actual_name_length = HDstrnlen((const char *)*pp, max); + if (actual_name_length == max) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "field name not null terminated") + } + else { + /* The buffer end can't be determined when it's an unbounded buffer + * passed via H5Tdecode(), so don't bounds check and hope for + * the best. + */ + actual_name_length = HDstrlen((const char *)*pp); + } + + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, actual_name_length, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); /* Decode the field name */ - dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp); + if (NULL == (dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name = + H5MM_xstrdup((const char *)*pp))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, + "can't duplicate compound member name string") /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */ - if (version >= H5O_DTYPE_VERSION_3) + if (version >= H5O_DTYPE_VERSION_3) { /* Advance past name, including null terminator */ - *pp += HDstrlen((const char *)*pp) + 1; - else + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, actual_name_length + 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); + *pp += actual_name_length + 1; + } + else { /* Advance multiple of 8 w/ null terminator */ - *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, ((actual_name_length + 8) / 8) * 8, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); + *pp += ((actual_name_length + 8) / 8) * 8; + } /* Decode the field offset */ /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ - if (version >= H5O_DTYPE_VERSION_3) - UINT32DECODE_VAR(*pp, dt->shared->u.compnd.memb[i].offset, offset_nbytes) - else - UINT32DECODE(*pp, dt->shared->u.compnd.memb[i].offset) + if (version >= H5O_DTYPE_VERSION_3) { + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, offset_nbytes, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); + UINT32DECODE_VAR(*pp, dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset, + offset_nbytes) + } + else { + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 4, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); + UINT32DECODE(*pp, dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset) + } /* Older versions of the library allowed a field to have * intrinsic 'arrayness'. Newer versions of the library * use the separate array datatypes. */ if (version == H5O_DTYPE_VERSION_1) { /* Decode the number of dimensions */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); ndims = *(*pp)++; /* Check that ndims is valid */ - if (ndims > 4) + if (ndims > 4) { + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name = + H5MM_xfree(dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name); HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array") + } - *pp += 3; /*reserved bytes */ + /* Skip reserved bytes */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 3, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); + *pp += 3; /* Skip dimension permutation */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 4, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); *pp += 4; /* Skip reserved bytes */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 4, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); *pp += 4; /* Decode array dimension sizes */ - for (j = 0; j < 4; j++) - UINT32DECODE(*pp, dim[j]); - } /* end if */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, (4 * 4), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); + for (int i = 0; i < 4; i++) + UINT32DECODE(*pp, dim[i]); + } /* Allocate space for the field's datatype */ - if (NULL == (temp_type = H5T__alloc())) + if (NULL == (temp_type = H5T__alloc())) { + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name = + H5MM_xfree(dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + } /* Decode the field's datatype information */ - if ((can_upgrade = H5O__dtype_decode_helper(ioflags, pp, temp_type)) < 0) { - for (j = 0; j <= i; j++) - H5MM_xfree(dt->shared->u.compnd.memb[j].name); - H5MM_xfree(dt->shared->u.compnd.memb); + if ((can_upgrade = H5O__dtype_decode_helper(ioflags, pp, temp_type, skip, p_end)) < 0) { + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name = + H5MM_xfree(dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name); + if (H5T_close_real(temp_type) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info") HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type") - } /* end if */ + } + if (temp_type->shared->size == 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "type size can't be zero") /* Upgrade the version if we can and it is necessary */ if (can_upgrade && temp_type->shared->version > version) { @@ -340,7 +460,7 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t /* Pass "can_upgrade" flag down to parent type */ ret_value = TRUE; - } /* end if */ + } /* Go create the array datatype now, for older versions of the datatype message */ if (version == H5O_DTYPE_VERSION_1) { @@ -348,15 +468,21 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t if (ndims > 0) { /* Create the array datatype for the field */ if ((array_dt = H5T__array_create(temp_type, ndims, dim)) == NULL) { - for (j = 0; j <= i; j++) - H5MM_xfree(dt->shared->u.compnd.memb[j].name); - H5MM_xfree(dt->shared->u.compnd.memb); + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name = + H5MM_xfree(dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name); + if (H5T_close_real(temp_type) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, + "can't release datatype info") HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype") - } /* end if */ + } /* Close the base type for the array */ - (void)H5T_close_real(temp_type); + if (H5T_close_real(temp_type) < 0) { + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name = + H5MM_xfree(dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].name); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info") + } /* Make the array type the type that is set for the field */ temp_type = array_dt; @@ -372,43 +498,51 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t /* Set the return value to indicate that we should freely * upgrade parent types */ ret_value = TRUE; - } /* end else */ - } /* end if */ - } /* end if */ + } + } + } /* Keep track of the maximum member version found */ if (temp_type->shared->version > max_version) max_version = temp_type->shared->version; - /* - * Set the "force conversion" flag if VL datatype fields exist in this + /* Set the "force conversion" flag if VL datatype fields exist in this * type or any component types */ if (temp_type->shared->force_conv == TRUE) dt->shared->force_conv = TRUE; /* Member size */ - dt->shared->u.compnd.memb[i].size = temp_type->shared->size; + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].size = temp_type->shared->size; dt->shared->u.compnd.memb_size += temp_type->shared->size; /* Set the field datatype (finally :-) */ - dt->shared->u.compnd.memb[i].type = temp_type; - - /* Check if this field overlaps with a prior field */ - /* (probably indicates that the file is corrupt) */ - if (i > 0 && dt->shared->u.compnd.memb[i].offset < max_memb_pos) { - for (j = 0; j < i; j++) - if (dt->shared->u.compnd.memb[i].offset >= dt->shared->u.compnd.memb[j].offset && - dt->shared->u.compnd.memb[i].offset < - (dt->shared->u.compnd.memb[j].offset + dt->shared->u.compnd.memb[j].size)) + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].type = temp_type; + + /* Check if this field overlaps with a prior field + * (probably indicates that the file is corrupt) + */ + if (dt->shared->u.compnd.nmembs > 0 && + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset < max_memb_pos) { + for (unsigned u = 0; u < dt->shared->u.compnd.nmembs; u++) + if ((dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset >= + dt->shared->u.compnd.memb[u].offset && + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset < + (dt->shared->u.compnd.memb[u].offset + dt->shared->u.compnd.memb[u].size)) || + (dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset < + dt->shared->u.compnd.memb[u].offset && + (dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset + + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].size) > + dt->shared->u.compnd.memb[u].offset)) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "member overlaps with previous member") - } /* end if */ + } /* Update the maximum member position covered */ - max_memb_pos = MAX(max_memb_pos, - (dt->shared->u.compnd.memb[i].offset + dt->shared->u.compnd.memb[i].size)); - } /* end for */ + max_memb_pos = + MAX(max_memb_pos, (dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].offset + + dt->shared->u.compnd.memb[dt->shared->u.compnd.nmembs].size)); + } /* Check if the compound type is packed */ H5T__update_packed(dt); @@ -421,14 +555,17 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t /* We won't mark the message dirty since there were no * errors in the file, simply type versions that we will no * longer encode. */ - } /* end if */ + } /* Check that no member of this compound has a version greater * than the compound itself. */ H5O_DTYPE_CHECK_VERSION(dt, version, max_version, ioflags, "compound", FAIL) } break; - case H5T_REFERENCE: /* Reference datatypes... */ + case H5T_REFERENCE: + /* + * Reference datatypes... + */ dt->shared->u.atomic.order = H5T_ORDER_NONE; dt->shared->u.atomic.prec = 8 * dt->shared->size; dt->shared->u.atomic.offset = 0; @@ -462,57 +599,102 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") break; - case H5T_ENUM: + case H5T_ENUM: { + unsigned nmembs; + /* * Enumeration datatypes... */ - dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff; + nmembs = flags & 0xffff; if (NULL == (dt->shared->parent = H5T__alloc())) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate parent datatype") + if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent, skip, p_end) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent datatype") + if (dt->shared->parent->shared->size != dt->shared->size) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "ENUM datatype size does not match parent") /* Check if the parent of this enum has a version greater than the * enum itself. */ H5O_DTYPE_CHECK_VERSION(dt, version, dt->shared->parent->shared->version, ioflags, "enum", FAIL) - if (NULL == (dt->shared->u.enumer.name = - (char **)H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char *))) || - NULL == (dt->shared->u.enumer.value = (uint8_t *)H5MM_calloc( - dt->shared->u.enumer.nalloc * dt->shared->parent->shared->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + /* Allocate name and value arrays */ + if (NULL == (dt->shared->u.enumer.name = (char **)H5MM_calloc(nmembs * sizeof(char *))) || + NULL == (dt->shared->u.enumer.value = + (uint8_t *)H5MM_calloc(nmembs * dt->shared->parent->shared->size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed") + dt->shared->u.enumer.nalloc = nmembs; /* Names */ - for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { - dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char *)*pp); + for (dt->shared->u.enumer.nmembs = 0; dt->shared->u.enumer.nmembs < nmembs; + dt->shared->u.enumer.nmembs++) { + + size_t actual_name_length = 0; /* Actual length of name */ + + /* Get the length of the enum name */ + if (!skip) { + /* There is a realistic buffer end, so check bounds */ + + size_t max = (size_t)(p_end - *pp + 1); /* Max possible name length */ + + actual_name_length = HDstrnlen((const char *)*pp, max); + if (actual_name_length == max) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "enum name not null terminated") + } + else { + /* The buffer end can't be determined when it's an unbounded buffer + * passed via H5Tdecode(), so don't bounds check and hope for + * the best. + */ + actual_name_length = HDstrlen((const char *)*pp); + } + + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, actual_name_length, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); + if (NULL == (dt->shared->u.enumer.name[dt->shared->u.enumer.nmembs] = + H5MM_xstrdup((const char *)*pp))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "can't duplicate enum name string") /* Version 3 of the datatype message eliminated the padding to multiple of 8 bytes */ - if (version >= H5O_DTYPE_VERSION_3) + if (version >= H5O_DTYPE_VERSION_3) { /* Advance past name, including null terminator */ - *pp += HDstrlen((const char *)*pp) + 1; - else + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, actual_name_length + 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); + *pp += actual_name_length + 1; + } + else { /* Advance multiple of 8 w/ null terminator */ - *pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8; - } /* end for */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, ((actual_name_length + 8) / 8) * 8, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, + "ran off end of input buffer while decoding"); + *pp += ((actual_name_length + 8) / 8) * 8; + } + } + if (dt->shared->u.enumer.nmembs != nmembs) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "incorrect number of enum members decoded"); /* Values */ - H5MM_memcpy(dt->shared->u.enumer.value, *pp, - dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size); - *pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size; - break; + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, nmembs * dt->shared->parent->shared->size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); + H5MM_memcpy(dt->shared->u.enumer.value, *pp, nmembs * dt->shared->parent->shared->size); + *pp += nmembs * dt->shared->parent->shared->size; + } break; - case H5T_VLEN: /* Variable length datatypes... */ + case H5T_VLEN: + /* + * Variable length datatypes... + */ /* Set the type of VL information, either sequence or string */ dt->shared->u.vlen.type = (H5T_vlen_type_t)(flags & 0x0f); if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { dt->shared->u.vlen.pad = (H5T_str_t)((flags >> 4) & 0x0f); dt->shared->u.vlen.cset = (H5T_cset_t)((flags >> 8) & 0x0f); - } /* end if */ + } /* Decode base type of VL information */ if (NULL == (dt->shared->parent = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed") - if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) + if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent, skip, p_end) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type") /* Check if the parent of this vlen has a version greater than the @@ -527,8 +709,13 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") break; - case H5T_ARRAY: /* Array datatypes */ + case H5T_ARRAY: + /* + * Array datatypes... + */ /* Decode the number of dimensions */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); dt->shared->u.array.ndims = *(*pp)++; /* Double-check the number of dimensions */ @@ -536,23 +723,32 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "too many dimensions for array datatype") /* Skip reserved bytes, if version has them */ - if (version < H5O_DTYPE_VERSION_3) + if (version < H5O_DTYPE_VERSION_3) { + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, 3, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); *pp += 3; + } /* Decode array dimension sizes & compute number of elements */ - for (i = 0, dt->shared->u.array.nelem = 1; i < (unsigned)dt->shared->u.array.ndims; i++) { - UINT32DECODE(*pp, dt->shared->u.array.dim[i]); - dt->shared->u.array.nelem *= dt->shared->u.array.dim[i]; - } /* end for */ + dt->shared->u.array.nelem = 1; + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, (dt->shared->u.array.ndims * 4), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); + for (unsigned u = 0; u < dt->shared->u.array.ndims; u++) { + UINT32DECODE(*pp, dt->shared->u.array.dim[u]); + dt->shared->u.array.nelem *= dt->shared->u.array.dim[u]; + } /* Skip array dimension permutations, if version has them */ - if (version < H5O_DTYPE_VERSION_3) + if (version < H5O_DTYPE_VERSION_3) { + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *pp, (dt->shared->u.array.ndims * 4), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, FAIL, "ran off end of input buffer while decoding"); *pp += dt->shared->u.array.ndims * 4; + } /* Decode base type of array */ if (NULL == (dt->shared->parent = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed") - if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent) < 0) + if (H5O__dtype_decode_helper(ioflags, pp, dt->shared->parent, skip, p_end) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode array parent type") /* Check if the parent of this array has a version greater than the @@ -562,8 +758,7 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t /* There should be no array datatypes with version < 2. */ H5O_DTYPE_CHECK_VERSION(dt, version, H5O_DTYPE_VERSION_2, ioflags, "array", FAIL) - /* - * Set the "force conversion" flag if a VL base datatype is used or + /* Set the "force conversion" flag if a VL base datatype is used or * or if any components of the base datatype are VL types. */ if (dt->shared->parent->shared->force_conv == TRUE) @@ -574,17 +769,15 @@ H5O__dtype_decode_helper(unsigned *ioflags /*in,out*/, const uint8_t **pp, H5T_t case H5T_NCLASSES: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown datatype class found") - } /* end switch */ + } done: + /* Cleanup on error */ if (ret_value < 0) - if (dt != NULL) { - if (dt->shared != NULL) { - HDassert(!dt->shared->owned_vol_obj); - dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); - } /* end if */ - dt = H5FL_FREE(H5T_t, dt); - } /* end if */ + /* Release (reset) dt but do not free it - leave it as an empty datatype as was the case on + * function entry */ + if (H5T__free(dt) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't release datatype info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_decode_helper() */ @@ -614,7 +807,7 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt) size_t n, z; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* check args */ HDassert(pp && *pp); @@ -1114,33 +1307,48 @@ H5O__dtype_encode_helper(uint8_t **pp, const H5T_t *dt) Pointer to the new message in native order on success, NULL on failure DESCRIPTION This function decodes the "raw" disk form of a simple datatype message - into a struct in memory native format. The struct is allocated within this - function using malloc() and is returned to the caller. + into a struct in memory native format. The struct is allocated within this + function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * H5O__dtype_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned *ioflags /*in,out*/, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned *ioflags /*in,out*/, size_t p_size, const uint8_t *p) { - H5T_t *dt = NULL; - void * ret_value = NULL; /* Return value */ + hbool_t skip; + H5T_t *dt = NULL; + const uint8_t *p_end = p + p_size - 1; + void *ret_value = NULL; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE - /* check args */ + HDassert(f); HDassert(p); /* Allocate datatype message */ if (NULL == (dt = H5T__alloc())) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + /* If we are decoding a buffer from H5Tdecode(), we won't have the size + * of the buffer and bounds checking will be impossible. In this case, + * the library will have set p_size to SIZE_MAX and we can use that + * as a signal to skip bounds checking. + */ + skip = (p_size == SIZE_MAX ? TRUE : FALSE); + /* Perform actual decode of message */ - if (H5O__dtype_decode_helper(ioflags, &p, dt) < 0) + if (H5O__dtype_decode_helper(ioflags, &p, dt, skip, p_end) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type") /* Set return value */ ret_value = dt; done: + /* Cleanup on error */ + if (!ret_value) + /* Free dt */ + if (H5T_close_real(dt) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "can't release datatype info") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_decode() */ @@ -1167,7 +1375,7 @@ H5O__dtype_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *mesg) const H5T_t *dt = (const H5T_t *)mesg; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* check args */ HDassert(f); @@ -1203,10 +1411,10 @@ static void * H5O__dtype_copy(const void *_src, void *_dst) { const H5T_t *src = (const H5T_t *)_src; - H5T_t * dst; - void * ret_value = NULL; /* Return value */ + H5T_t *dst; + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* check args */ HDassert(src); @@ -1252,7 +1460,7 @@ H5O__dtype_size(const H5F_t *f, const void *_mesg) unsigned u; /* Local index variable */ size_t ret_value = 0; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR HDassert(f); HDassert(dt); @@ -1380,7 +1588,7 @@ H5O__dtype_reset(void *_mesg) { H5T_t *dt = (H5T_t *)_mesg; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR if (dt) H5T__free(dt); @@ -1405,7 +1613,7 @@ H5O__dtype_free(void *mesg) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(mesg); @@ -1436,7 +1644,7 @@ H5O__dtype_set_share(void *_mesg /*in,out*/, const H5O_shared_t *sh) H5T_t *dt = (H5T_t *)_mesg; herr_t ret_value = SUCCEED; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE HDassert(dt); HDassert(sh); @@ -1492,7 +1700,7 @@ H5O__dtype_can_share(const void *_mesg) htri_t tri_ret; htri_t ret_value = TRUE; - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE HDassert(mesg); @@ -1531,11 +1739,11 @@ static herr_t H5O__dtype_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void *_udata) { - const H5T_t * dt_src = (const H5T_t *)mesg_src; /* Source datatype */ + const H5T_t *dt_src = (const H5T_t *)mesg_src; /* Source datatype */ H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* check args */ HDassert(file_src); @@ -1588,9 +1796,9 @@ H5O__dtype_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const H5O_msg_class_t *mesg H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { H5T_t *dst_mesg; /* Destination datatype */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Perform a normal copy of the object header message */ if (NULL == (dst_mesg = (H5T_t *)H5O__dtype_copy(native_src, NULL))) @@ -1630,7 +1838,7 @@ H5O__dtype_shared_post_copy_upd(const H5O_loc_t H5_ATTR_UNUSED *src_oloc, const H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE if (dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { HDassert(H5T_is_named(dt_dst)); @@ -1669,12 +1877,12 @@ static herr_t H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidth) { const H5T_t *dt = (const H5T_t *)mesg; - const char * s; + const char *s; char buf[256]; unsigned i; size_t k; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_PACKAGE_NOERR /* check args */ HDassert(f); @@ -1731,7 +1939,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_NO_CLASS: case H5T_NCLASSES: default: - HDsprintf(buf, "H5T_CLASS_%d", (int)(dt->shared->type)); + HDsnprintf(buf, sizeof(buf), "H5T_CLASS_%d", (int)(dt->shared->type)); s = buf; break; } /* end switch */ @@ -1746,7 +1954,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of members:", dt->shared->u.compnd.nmembs); for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { - HDsprintf(buf, "Member %u:", i); + HDsnprintf(buf, sizeof(buf), "Member %u:", i); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.compnd.memb[i].name); HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3), "Byte offset:", (unsigned long)(dt->shared->u.compnd.memb[i].offset)); @@ -1759,7 +1967,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of members:", dt->shared->u.enumer.nmembs); for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { - HDsprintf(buf, "Member %u:", i); + HDsnprintf(buf, sizeof(buf), "Member %u:", i); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.enumer.name[i]); HDfprintf(stream, "%*s%-*s 0x", indent, "", fwidth, "Raw bytes of value:"); for (k = 0; k < dt->shared->parent->shared->size; k++) @@ -1799,13 +2007,14 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_CSET_RESERVED_13: case H5T_CSET_RESERVED_14: case H5T_CSET_RESERVED_15: - HDsprintf(buf, "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.cset)); + HDsnprintf(buf, sizeof(buf), "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.cset)); s = buf; break; case H5T_CSET_ERROR: default: - HDsprintf(buf, "Unknown character set: %d", (int)(dt->shared->u.atomic.u.s.cset)); + HDsnprintf(buf, sizeof(buf), "Unknown character set: %d", + (int)(dt->shared->u.atomic.u.s.cset)); s = buf; break; } /* end switch */ @@ -1837,13 +2046,14 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: - HDsprintf(buf, "H5T_STR_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.pad)); + HDsnprintf(buf, sizeof(buf), "H5T_STR_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.pad)); s = buf; break; case H5T_STR_ERROR: default: - HDsprintf(buf, "Unknown string padding: %d", (int)(dt->shared->u.atomic.u.s.pad)); + HDsnprintf(buf, sizeof(buf), "Unknown string padding: %d", + (int)(dt->shared->u.atomic.u.s.pad)); s = buf; break; } /* end switch */ @@ -1862,7 +2072,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_VLEN_BADTYPE: case H5T_VLEN_MAXTYPE: default: - HDsprintf(buf, "H5T_VLEN_%d", dt->shared->u.vlen.type); + HDsnprintf(buf, sizeof(buf), "H5T_VLEN_%d", dt->shared->u.vlen.type); s = buf; break; } /* end switch */ @@ -1880,7 +2090,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_LOC_BADLOC: case H5T_LOC_MAXLOC: default: - HDsprintf(buf, "H5T_LOC_%d", (int)dt->shared->u.vlen.loc); + HDsnprintf(buf, sizeof(buf), "H5T_LOC_%d", (int)dt->shared->u.vlen.loc); s = buf; break; } /* end switch */ @@ -1911,13 +2121,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_CSET_RESERVED_13: case H5T_CSET_RESERVED_14: case H5T_CSET_RESERVED_15: - HDsprintf(buf, "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.vlen.cset)); + HDsnprintf(buf, sizeof(buf), "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.vlen.cset)); s = buf; break; case H5T_CSET_ERROR: default: - HDsprintf(buf, "Unknown character set: %d", (int)(dt->shared->u.vlen.cset)); + HDsnprintf(buf, sizeof(buf), "Unknown character set: %d", (int)(dt->shared->u.vlen.cset)); s = buf; break; } /* end switch */ @@ -1949,13 +2159,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: - HDsprintf(buf, "H5T_STR_RESERVED_%d", (int)(dt->shared->u.vlen.pad)); + HDsnprintf(buf, sizeof(buf), "H5T_STR_RESERVED_%d", (int)(dt->shared->u.vlen.pad)); s = buf; break; case H5T_STR_ERROR: default: - HDsprintf(buf, "Unknown string padding: %d", (int)(dt->shared->u.vlen.pad)); + HDsnprintf(buf, sizeof(buf), "Unknown string padding: %d", (int)(dt->shared->u.vlen.pad)); s = buf; break; } /* end switch */ @@ -1995,7 +2205,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_ORDER_ERROR: default: - HDsprintf(buf, "H5T_ORDER_%d", dt->shared->u.atomic.order); + HDsnprintf(buf, sizeof(buf), "H5T_ORDER_%d", dt->shared->u.atomic.order); s = buf; break; } /* end switch */ @@ -2069,9 +2279,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_NPAD: default: if (dt->shared->u.atomic.u.f.pad < 0) - HDsprintf(buf, "H5T_PAD_%d", -(dt->shared->u.atomic.u.f.pad)); + HDsnprintf(buf, sizeof(buf), "H5T_PAD_%d", -(dt->shared->u.atomic.u.f.pad)); else - HDsprintf(buf, "bit-%d", dt->shared->u.atomic.u.f.pad); + HDsnprintf(buf, sizeof(buf), "bit-%d", dt->shared->u.atomic.u.f.pad); s = buf; break; } /* end switch */ @@ -2092,7 +2302,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_NORM_ERROR: default: - HDsprintf(buf, "H5T_NORM_%d", (int)(dt->shared->u.atomic.u.f.norm)); + HDsnprintf(buf, sizeof(buf), "H5T_NORM_%d", (int)(dt->shared->u.atomic.u.f.norm)); s = buf; } /* end switch */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Normalization:", s); @@ -2129,7 +2339,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_SGN_ERROR: case H5T_NSGN: default: - HDsprintf(buf, "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign)); + HDsnprintf(buf, sizeof(buf), "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign)); s = buf; break; } /* end switch */ @@ -2138,4 +2348,4 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O__dtype_debug() */ +} /* end H5O__dtype_debug() */ \ No newline at end of file diff --git a/src/H5Oefl.c b/src/H5Oefl.c index d950249cbdb..394e775b4c1 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -26,13 +25,13 @@ #include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void * H5O__efl_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, +static void *H5O__efl_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__efl_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__efl_copy(const void *_mesg, void *_dest); +static void *H5O__efl_copy(const void *_mesg, void *_dest); static size_t H5O__efl_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__efl_reset(void *_mesg); -static void * H5O__efl_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, +static void *H5O__efl_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); static herr_t H5O__efl_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -41,7 +40,7 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{ H5O_EFL_ID, /*message id number */ "external file list", /*message name for debugging */ sizeof(H5O_efl_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__efl_decode, /*decode message */ H5O__efl_encode, /*encode message */ H5O__efl_copy, /*copy native value */ @@ -68,108 +67,121 @@ const H5O_msg_class_t H5O_MSG_EFL[1] = {{ * Purpose: Decode an external file list message and return a pointer to * the message (and some other data). * - * Return: Success: Ptr to a new message struct. + * We allow zero dimension size starting from the 1.8.7 release. + * The dataset size of external storage can be zero. * + * Return: Success: Pointer to a new message struct * Failure: NULL - * - * Programmer: Robb Matzke - * Tuesday, November 25, 1997 - * - * Modification: - * Raymond Lu - * 11 April 2011 - * We allow zero dimension size starting from the 1.8.7 release. - * The dataset size of external storage can be zero. *------------------------------------------------------------------------- */ static void * H5O__efl_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_efl_t * mesg = NULL; - int version; - const char *s = NULL; - H5HL_t * heap; - size_t u; /* Local index variable */ - void * ret_value = NULL; /* Return value */ + H5O_efl_t *mesg = NULL; + int version; + const uint8_t *p_end = p + p_size - 1; /* pointer to last byte in p */ + const char *s = NULL; + H5HL_t *heap = NULL; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Check args */ HDassert(f); HDassert(p); + HDassert(p_size > 0); if (NULL == (mesg = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed") - /* Version */ + /* Version (1 byte) */ + if ((p + 1 - 1) > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") version = *p++; if (version != H5O_EFL_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for external file list message") - /* Reserved */ + /* Reserved (3 bytes) */ + if ((p + 3 - 1) > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") p += 3; - /* Number of slots */ + /* Number of slots (2x 2 bytes) */ + if ((p + 4 - 1) > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") UINT16DECODE(p, mesg->nalloc); - HDassert(mesg->nalloc > 0); + if (mesg->nalloc <= 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad number of allocated slots when parsing efl msg") UINT16DECODE(p, mesg->nused); - HDassert(mesg->nused <= mesg->nalloc); + if (mesg->nused > mesg->nalloc) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad number of in-use slots when parsing efl msg") /* Heap address */ + if ((p + H5F_SIZEOF_ADDR(f) - 1) > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(mesg->heap_addr)); + if (H5F_addr_defined(mesg->heap_addr) == FALSE) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad local heap address when parsing efl msg") -#ifndef NDEBUG - HDassert(H5F_addr_defined(mesg->heap_addr)); + /* Decode the file list */ + mesg->slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t)); + if (NULL == mesg->slot) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "memory allocation failed") if (NULL == (heap = H5HL_protect(f, mesg->heap_addr, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect local heap") +#ifdef H5O_DEBUG + /* Verify that the name at offset 0 in the local heap is the empty string */ s = (const char *)H5HL_offset_into(heap, 0); - - HDassert(s && !*s); - - if (H5HL_unprotect(heap) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") - heap = NULL; + if (s == NULL) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "could not obtain pointer into local heap") + if (*s != '\0') + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "entry at offset 0 in local heap not an empty string") #endif - /* Decode the file list */ - mesg->slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t)); - if (NULL == mesg->slot) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - if (NULL == (heap = H5HL_protect(f, mesg->heap_addr, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") - for (u = 0; u < mesg->nused; u++) { + for (size_t u = 0; u < mesg->nused; u++) { /* Name */ + if ((p + H5F_SIZEOF_SIZE(f) - 1) > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") H5F_DECODE_LENGTH(f, p, mesg->slot[u].name_offset); if ((s = (const char *)H5HL_offset_into(heap, mesg->slot[u].name_offset)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get external file name") - if (*s == (char)'\0') - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "invalid external file name") + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get external file name") + if (*s == '\0') + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "invalid external file name") mesg->slot[u].name = H5MM_xstrdup(s); - HDassert(mesg->slot[u].name); + if (mesg->slot[u].name == NULL) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "string duplication failed") /* File offset */ + if ((p + H5F_SIZEOF_SIZE(f) - 1) > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") H5F_DECODE_LENGTH(f, p, mesg->slot[u].offset); /* Size */ + if ((p + H5F_SIZEOF_SIZE(f) - 1) > p_end) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off end of input buffer while decoding") H5F_DECODE_LENGTH(f, p, mesg->slot[u].size); - } /* end for */ + } if (H5HL_unprotect(heap) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") - heap = NULL; + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect local heap") /* Set return value */ ret_value = mesg; done: if (ret_value == NULL) - if (mesg != NULL) + if (mesg != NULL) { + if (mesg->slot != NULL) { + for (size_t u = 0; u < mesg->nused; u++) + H5MM_xfree(mesg->slot[u].name); + H5MM_xfree(mesg->slot); + } H5MM_xfree(mesg); + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__efl_decode() */ @@ -251,10 +263,10 @@ static void * H5O__efl_copy(const void *_mesg, void *_dest) { const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; - H5O_efl_t * dest = (H5O_efl_t *)_dest; + H5O_efl_t *dest = (H5O_efl_t *)_dest; size_t u; /* Local index variable */ hbool_t slot_allocated = FALSE; /* Flag to indicate that dynamic allocation has begun */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -342,7 +354,7 @@ H5O__efl_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void * Function: H5O__efl_reset * * Purpose: Frees internal pointers and resets the message to an - * initialial state. + * initial state. * * Return: Non-negative on success/Negative on failure * @@ -435,9 +447,9 @@ H5O__efl_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *mesg_src, H5F_t *file_d { H5O_efl_t *efl_src = (H5O_efl_t *)mesg_src; H5O_efl_t *efl_dst = NULL; - H5HL_t * heap = NULL; /* Pointer to local heap for EFL file names */ + H5HL_t *heap = NULL; /* Pointer to local heap for EFL file names */ size_t idx, size, name_offset, heap_size; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG) diff --git a/src/H5Ofill.c b/src/H5Ofill.c index 2314a84f5a3..513a6676dd8 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -30,15 +29,15 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5Sprivate.h" /* Dataspaces */ -static void * H5O__fill_old_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__fill_old_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__fill_old_encode(H5F_t *f, uint8_t *p, const void *_mesg); static size_t H5O__fill_old_size(const H5F_t *f, const void *_mesg); -static void * H5O__fill_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__fill_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__fill_new_encode(H5F_t *f, uint8_t *p, const void *_mesg); static size_t H5O__fill_new_size(const H5F_t *f, const void *_mesg); -static void * H5O__fill_copy(const void *_mesg, void *_dest); +static void *H5O__fill_copy(const void *_mesg, void *_dest); static herr_t H5O__fill_reset(void *_mesg); static herr_t H5O__fill_free(void *_mesg); static herr_t H5O__fill_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, @@ -107,7 +106,7 @@ const H5O_msg_class_t H5O_MSG_FILL[1] = {{ H5O_FILL_ID, /*message id number */ "fill", /*message name for debugging */ sizeof(H5O_fill_t), /*native message size */ - H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are shareable? */ H5O__fill_shared_decode, /*decode message */ H5O__fill_shared_encode, /*encode message */ H5O__fill_copy, /*copy the native value */ @@ -131,7 +130,7 @@ const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{ H5O_FILL_NEW_ID, /*message id number */ "fill_new", /*message name for debugging */ sizeof(H5O_fill_t), /*native message size */ - H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are shareable? */ H5O__fill_new_shared_decode, /*decode message */ H5O__fill_new_shared_encode, /*encode message */ H5O__fill_copy, /*copy the native value */ @@ -195,9 +194,9 @@ H5O__fill_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_fill_t * fill = NULL; + H5O_fill_t *fill = NULL; const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -314,11 +313,11 @@ static void * H5O__fill_old_decode(H5F_t *f, H5O_t *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_fill_t * fill = NULL; /* Decoded fill value message */ + H5O_fill_t *fill = NULL; /* Decoded fill value message */ htri_t exists = FALSE; - H5T_t * dt = NULL; + H5T_t *dt = NULL; const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -527,8 +526,8 @@ static void * H5O__fill_copy(const void *_src, void *_dst) { const H5O_fill_t *src = (const H5O_fill_t *)_src; - H5O_fill_t * dst = (H5O_fill_t *)_dst; - void * ret_value = NULL; /* Return value */ + H5O_fill_t *dst = (H5O_fill_t *)_dst; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -975,7 +974,7 @@ herr_t H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) { H5T_path_t *tpath; /* Type conversion info */ - void * buf = NULL, *bkg = NULL; /* Conversion buffers */ + void *buf = NULL, *bkg = NULL; /* Conversion buffers */ hid_t src_id = -1, dst_id = -1; /* Datatype identifiers */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1006,6 +1005,8 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) /* Don't bother doing anything if there will be no actual conversion */ if (!H5T_path_noop(tpath)) { + size_t fill_type_size; + if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill->type, H5T_COPY_ALL), FALSE)) < 0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dset_type, H5T_COPY_ALL), FALSE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy/register data type") @@ -1014,13 +1015,11 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) * Datatype conversions are always done in place, so we need a buffer * that is large enough for both source and destination. */ - if (H5T_get_size(fill->type) >= H5T_get_size(dset_type)) - buf = fill->buf; - else { - if (NULL == (buf = H5MM_malloc(H5T_get_size(dset_type)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") - H5MM_memcpy(buf, fill->buf, H5T_get_size(fill->type)); - } /* end else */ + fill_type_size = H5T_get_size(fill->type); + + if (NULL == (buf = H5MM_malloc(MAX(fill_type_size, H5T_get_size(dset_type))))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + H5MM_memcpy(buf, fill->buf, fill_type_size); /* Use CALLOC here to clear the buffer in case later the library thinks there's * data in the background. */ @@ -1032,11 +1031,10 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Update the fill message */ - if (buf != fill->buf) { - H5T_vlen_reclaim_elmt(fill->buf, fill->type); - H5MM_xfree(fill->buf); - fill->buf = buf; - } /* end if */ + H5T_vlen_reclaim_elmt(fill->buf, fill->type); + H5MM_xfree(fill->buf); + fill->buf = buf; + (void)H5T_close_real(fill->type); fill->type = NULL; H5_CHECKED_ASSIGN(fill->size, ssize_t, H5T_get_size(dset_type), size_t); @@ -1050,8 +1048,6 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed) HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") if (dst_id >= 0 && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") - if (buf != fill->buf) - H5MM_xfree(buf); if (bkg) H5MM_xfree(bkg); diff --git a/src/H5Oflush.c b/src/H5Oflush.c index eeba5259621..6bb8aa91700 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -68,7 +67,7 @@ static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t * herr_t H5Oflush(hid_t obj_id) { - H5VL_object_t * vol_obj = NULL; /* Object of obj_id */ + H5VL_object_t *vol_obj = NULL; /* Object of obj_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -112,7 +111,7 @@ H5Oflush(hid_t obj_id) herr_t H5O_flush(H5O_loc_t *oloc, hid_t obj_id) { - void * obj_ptr; /* Pointer to object */ + void *obj_ptr; /* Pointer to object */ const H5O_obj_class_t *obj_class; /* Class of object */ herr_t ret_value = SUCCEED; /* Return value */ @@ -229,7 +228,7 @@ H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag) herr_t H5Orefresh(hid_t oid) { - H5VL_object_t * vol_obj = NULL; /* Object of oid */ + H5VL_object_t *vol_obj = NULL; /* Object of oid */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -280,8 +279,9 @@ H5Orefresh(hid_t oid) herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) { - H5VL_object_t *vol_obj = NULL; /* VOL object associated with the ID */ - hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */ + H5VL_object_t *vol_obj = NULL; /* VOL object associated with the ID */ + hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */ + H5F_t *file = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -292,7 +292,12 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) H5O_loc_t obj_oloc; H5G_name_t obj_path; H5O_shared_t cached_H5O_shared; - H5VL_t * connector = NULL; + H5VL_t *connector = NULL; + + /* Hold a copy of the object's file pointer, since closing the object will + * invalidate the file pointer in the oloc. + */ + file = oloc.file; /* Create empty object location */ obj_loc.oloc = &obj_oloc; @@ -328,7 +333,7 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Re-open the object, re-fetching its metadata */ - if ((H5O_refresh_metadata_reopen(oid, &obj_loc, connector, FALSE)) < 0) + if ((H5O_refresh_metadata_reopen(oid, H5P_DEFAULT, &obj_loc, connector, FALSE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Restore the number of references on the VOL connector */ @@ -342,8 +347,8 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) } /* end if */ done: - if (objs_incr) - H5F_decr_nopen_objs(oloc.file); + if (objs_incr && file) + H5F_decr_nopen_objs(file); FUNC_LEAVE_NOAPI(ret_value); } /* end H5O_refresh_metadata() */ @@ -433,9 +438,10 @@ H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc) *------------------------------------------------------------------------- */ herr_t -H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_connector, hbool_t start_swmr) +H5O_refresh_metadata_reopen(hid_t oid, hid_t apl_id, H5G_loc_t *obj_loc, H5VL_t *vol_connector, + hbool_t start_swmr) { - void * object = NULL; /* Object for this operation */ + void *object = NULL; /* Object for this operation */ H5I_type_t type; /* Type of object for the ID */ herr_t ret_value = SUCCEED; /* Return value */ @@ -462,8 +468,13 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_connector break; case H5I_DATASET: + /* Set dataset access property list in API context if appropriate */ + if (H5CX_set_apl(&apl_id, H5P_CLS_DACC, oid, TRUE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Re-open the dataset */ - if (NULL == (object = H5D_open(obj_loc, H5P_DATASET_ACCESS_DEFAULT))) + if (NULL == + (object = H5D_open(obj_loc, apl_id == H5P_DEFAULT ? H5P_DATASET_ACCESS_DEFAULT : apl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") if (!start_swmr) /* No need to handle multiple opens when H5Fstart_swmr_write() */ if (H5D_mult_refresh_reopen((H5D_t *)object) < 0) diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index b9dc4fea835..1c70e614876 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -31,10 +30,10 @@ #include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void * H5O__fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__fsinfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__fsinfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__fsinfo_copy(const void *_mesg, void *_dest); +static void *H5O__fsinfo_copy(const void *_mesg, void *_dest); static size_t H5O__fsinfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__fsinfo_free(void *mesg); static herr_t H5O__fsinfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -44,7 +43,7 @@ const H5O_msg_class_t H5O_MSG_FSINFO[1] = {{ H5O_FSINFO_ID, /* message id number */ "fsinfo", /* message name for debugging */ sizeof(H5O_fsinfo_t), /* native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__fsinfo_decode, /* decode message */ H5O__fsinfo_encode, /* encode message */ H5O__fsinfo_copy, /* copy the native value */ @@ -90,12 +89,13 @@ H5FL_DEFINE_STATIC(H5O_fsinfo_t); */ static void * H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_fsinfo_t * fsinfo = NULL; /* File space info message */ - H5F_mem_page_t ptype; /* Memory type for iteration */ - unsigned vers; /* message version */ - void * ret_value = NULL; /* Return value */ + H5O_fsinfo_t *fsinfo = NULL; /* File space info message */ + H5F_mem_page_t ptype; /* Memory type for iteration */ + unsigned vers; /* message version */ + const uint8_t *p_end = p + p_size; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -135,8 +135,12 @@ H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU fsinfo->threshold = threshold; if (HADDR_UNDEF == (fsinfo->eoa_pre_fsm_fsalloc = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "unable to get file size") - for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) + for (type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; type++) { + if (p + H5_SIZEOF_HADDR_T > p_end) + HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, + "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(fsinfo->fs_addr[type - 1])); + } break; case H5F_FILE_SPACE_ALL: @@ -170,7 +174,7 @@ H5O__fsinfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* Free-space section threshold */ H5F_DECODE_LENGTH(f, p, fsinfo->page_size); /* File space page size */ - UINT16DECODE(p, fsinfo->pgend_meta_thres); /* Page end metdata threshold */ + UINT16DECODE(p, fsinfo->pgend_meta_thres); /* Page end metadata threshold */ H5F_addr_decode(f, &p, &(fsinfo->eoa_pre_fsm_fsalloc)); /* EOA before free-space header and section info */ @@ -251,8 +255,8 @@ static void * H5O__fsinfo_copy(const void *_mesg, void *_dest) { const H5O_fsinfo_t *fsinfo = (const H5O_fsinfo_t *)_mesg; - H5O_fsinfo_t * dest = (H5O_fsinfo_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_fsinfo_t *dest = (H5O_fsinfo_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c index 8540cc4817a..cdfacdf09a5 100644 --- a/src/H5Oginfo.c +++ b/src/H5Oginfo.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -30,10 +29,10 @@ #include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void * H5O__ginfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__ginfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__ginfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__ginfo_copy(const void *_mesg, void *_dest); +static void *H5O__ginfo_copy(const void *_mesg, void *_dest); static size_t H5O__ginfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__ginfo_free(void *_mesg); static herr_t H5O__ginfo_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -43,7 +42,7 @@ const H5O_msg_class_t H5O_MSG_GINFO[1] = {{ H5O_GINFO_ID, /*message id number */ "ginfo", /*message name for debugging */ sizeof(H5O_ginfo_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__ginfo_decode, /*decode message */ H5O__ginfo_encode, /*encode message */ H5O__ginfo_copy, /*copy the native value */ @@ -92,9 +91,9 @@ static void * H5O__ginfo_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_ginfo_t * ginfo = NULL; /* Pointer to group information message */ + H5O_ginfo_t *ginfo = NULL; /* Pointer to group information message */ unsigned char flags; /* Flags for encoding group info */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -214,8 +213,8 @@ static void * H5O__ginfo_copy(const void *_mesg, void *_dest) { const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)_mesg; - H5O_ginfo_t * dest = (H5O_ginfo_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_ginfo_t *dest = (H5O_ginfo_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Oint.c b/src/H5Oint.c index 18b2db05f3a..16a50280b7e 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -55,10 +54,10 @@ /* User data for recursive traversal over objects from a group */ typedef struct { hid_t obj_id; /* The ID for the starting group */ - H5G_loc_t * start_loc; /* Location of starting group */ - H5SL_t * visited; /* Skip list for tracking visited nodes */ + H5G_loc_t *start_loc; /* Location of starting group */ + H5SL_t *visited; /* Skip list for tracking visited nodes */ H5O_iterate2_t op; /* Application callback */ - void * op_data; /* Application's op data */ + void *op_data; /* Application's op data */ unsigned fields; /* Selection of object info */ } H5O_iter_visit_ud_t; @@ -315,9 +314,9 @@ H5O_t * H5O_create_ohdr(H5F_t *f, hid_t ocpl_id) { H5P_genplist_t *oc_plist; - H5O_t * oh = NULL; /* Object header in Freelist */ + H5O_t *oh = NULL; /* Object header in Freelist */ uint8_t oh_flags; /* Initial status flags */ - H5O_t * ret_value = NULL; + H5O_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -607,7 +606,7 @@ H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type) H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -658,7 +657,7 @@ H5O__open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5 H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -707,7 +706,7 @@ H5O__open_by_addr(const H5G_loc_t *loc, haddr_t addr, H5I_type_t *opened_type) H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -747,7 +746,7 @@ void * H5O_open_by_loc(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { const H5O_obj_class_t *obj_class; /* Class of object for location */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -962,7 +961,7 @@ H5O__link_oh(H5F_t *f, int adjust, H5O_t *oh, hbool_t *deleted) int H5O_link(const H5O_loc_t *loc, int adjust) { - H5O_t * oh = NULL; + H5O_t *oh = NULL; hbool_t deleted = FALSE; /* Whether the object was deleted */ int ret_value = -1; /* Return value */ @@ -1009,11 +1008,11 @@ H5O_link(const H5O_loc_t *loc, int adjust) H5O_t * H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) { - H5O_t * oh = NULL; /* Object header protected */ + H5O_t *oh = NULL; /* Object header protected */ H5O_cache_ud_t udata; /* User data for protecting object header */ H5O_cont_msgs_t cont_msg_info; /* Continuation message info */ unsigned file_intent; /* R/W intent on file */ - H5O_t * ret_value = NULL; /* Return value */ + H5O_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, NULL) @@ -1170,9 +1169,14 @@ H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks) ret_value = oh; done: - if (ret_value == NULL && oh) + if (ret_value == NULL && oh) { + /* Release any continuation messages built up */ + if (cont_msg_info.msgs) + cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs); + if (H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + } FUNC_LEAVE_NOAPI_TAG(ret_value) } /* end H5O_protect() */ @@ -1426,7 +1430,7 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force) herr_t H5O_touch(const H5O_loc_t *loc, hbool_t force) { - H5O_t * oh = NULL; /* Object header to modify */ + H5O_t *oh = NULL; /* Object header to modify */ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1441,7 +1445,7 @@ H5O_touch(const H5O_loc_t *loc, hbool_t force) /* Create/Update the modification time message */ if (H5O_touch_oh(loc->file, oh, force) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update object modificaton time") + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update object modification time") /* Mark object header as changed */ oh_flags |= H5AC__DIRTIED_FLAG; @@ -1540,7 +1544,7 @@ H5O_bogus_oh(H5F_t *f, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) herr_t H5O_delete(H5F_t *f, haddr_t addr) { - H5O_t * oh = NULL; /* Object header information */ + H5O_t *oh = NULL; /* Object header information */ H5O_loc_t loc; /* Object location for object to delete */ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ hbool_t corked; @@ -1716,7 +1720,7 @@ H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type) const H5O_obj_class_t * H5O__obj_class(const H5O_loc_t *loc) { - H5O_t * oh = NULL; /* Object header for location */ + H5O_t *oh = NULL; /* Object header for location */ const H5O_obj_class_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_TAG(loc->addr) @@ -2099,7 +2103,7 @@ H5O_get_hdr_info(const H5O_loc_t *loc, H5O_hdr_info_t *hdr) static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) { - const H5O_mesg_t * curr_msg; /* Pointer to current message being operated on */ + const H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ const H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */ unsigned u; /* Local index variable */ @@ -2180,7 +2184,7 @@ herr_t H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields) { const H5O_obj_class_t *obj_class; /* Class of object for header */ - H5O_t * oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -2289,7 +2293,7 @@ herr_t H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fields) { const H5O_obj_class_t *obj_class; /* Class of object for header */ - H5O_t * oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL) @@ -2448,7 +2452,7 @@ void * H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc) { size_t u; /* Local index variable */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2761,7 +2765,7 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_or H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ H5O_info2_t oinfo; /* Object info struct */ - void * obj = NULL; /* Object */ + void *obj = NULL; /* Object */ H5I_type_t opened_type; /* ID type of object */ hid_t obj_id = H5I_INVALID_HID; /* ID of object */ herr_t ret_value = FAIL; /* Return value */ @@ -2925,7 +2929,8 @@ H5O__dec_rc(H5O_t *oh) FUNC_ENTER_PACKAGE /* check args */ - HDassert(oh); + if (!oh) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object header") /* Decrement reference count */ oh->rc--; diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 651e317a2c9..0c5c993f566 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -32,17 +31,17 @@ /* Local macros */ /* PRIVATE PROTOTYPES */ -static void * H5O__layout_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__layout_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__layout_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__layout_copy(const void *_mesg, void *_dest); +static void *H5O__layout_copy(const void *_mesg, void *_dest); static size_t H5O__layout_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__layout_reset(void *_mesg); static herr_t H5O__layout_free(void *_mesg); static herr_t H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); static herr_t H5O__layout_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static void * H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, +static void *H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); static herr_t H5O__layout_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -51,7 +50,7 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{ H5O_LAYOUT_ID, /* message id number */ "layout", /* message name for debugging */ sizeof(H5O_layout_t), /* native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__layout_decode, /* decode message */ H5O__layout_encode, /* encode message */ H5O__layout_copy, /* copy the native value */ @@ -92,11 +91,11 @@ static void * H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_layout_t * mesg = NULL; - uint8_t * heap_block = NULL; + const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ + H5O_layout_t *mesg = NULL; + uint8_t *heap_block = NULL; unsigned u; - const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -106,39 +105,55 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU /* decode */ if (NULL == (mesg = H5FL_CALLOC(H5O_layout_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed") mesg->storage.type = H5D_LAYOUT_ERROR; + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") mesg->version = *p++; + if (mesg->version < H5O_LAYOUT_VERSION_1 || mesg->version > H5O_LAYOUT_VERSION_4) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for layout message") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad version number for layout message") if (mesg->version < H5O_LAYOUT_VERSION_3) { unsigned ndims; /* Num dimensions in chunk */ /* Dimensionality */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") ndims = *p++; + if (!ndims || ndims > H5O_LAYOUT_NDIMS) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is out of range") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "dimensionality is out of range") /* Layout class */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") mesg->type = (H5D_layout_t)*p++; - HDassert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type || H5D_COMPACT == mesg->type); + + if (H5D_CONTIGUOUS != mesg->type && H5D_CHUNKED != mesg->type && H5D_COMPACT != mesg->type) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad layout type for layout message") /* Set the storage type */ mesg->storage.type = mesg->type; /* Reserved bytes */ + if (H5_IS_BUFFER_OVERFLOW(p, 5, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") p += 5; /* Address */ if (mesg->type == H5D_CONTIGUOUS) { + if (H5_IS_BUFFER_OVERFLOW(p, H5F_SIZEOF_ADDR(f), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); /* Set the layout operations */ mesg->ops = H5D_LOPS_CONTIG; } /* end if */ else if (mesg->type == H5D_CHUNKED) { + if (H5_IS_BUFFER_OVERFLOW(p, H5F_SIZEOF_ADDR(f), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); /* Set the layout operations */ @@ -165,27 +180,46 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU * size in the dataset code, where we've got the dataspace * information available also. - QAK 5/26/04 */ - p += ndims * 4; /* Skip over dimension sizes (32-bit quantities) */ - } /* end if */ + if (H5_IS_BUFFER_OVERFLOW(p, (ndims * sizeof(uint32_t)), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") + p += ndims * sizeof(uint32_t); /* Skip over dimension sizes */ + } /* end if */ else { + if (ndims < 2) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad dimensions for chunked storage") mesg->u.chunk.ndims = ndims; - for (u = 0; u < ndims; u++) + + if (H5_IS_BUFFER_OVERFLOW(p, (ndims * sizeof(uint32_t)), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") + + for (u = 0; u < ndims; u++) { UINT32DECODE(p, mesg->u.chunk.dim[u]); + /* Just in case that something goes very wrong, such as file corruption. */ + if (mesg->u.chunk.dim[u] == 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "bad chunk dimension value when parsing layout message - chunk dimension " + "must be positive: mesg->u.chunk.dim[%u] = %u", + u, mesg->u.chunk.dim[u]) + } + /* Compute chunk size */ for (u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < ndims; u++) mesg->u.chunk.size *= mesg->u.chunk.dim[u]; } /* end if */ if (mesg->type == H5D_COMPACT) { + if (H5_IS_BUFFER_OVERFLOW(p, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") UINT32DECODE(p, mesg->storage.u.compact.size); + if (mesg->storage.u.compact.size > 0) { /* Ensure that size doesn't exceed buffer size, due to possible data corruption */ - if (p + mesg->storage.u.compact.size - 1 > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "storage size exceeds buffer size") + if (H5_IS_BUFFER_OVERFLOW(p, mesg->storage.u.compact.size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") if (NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed for compact data buffer") H5MM_memcpy(mesg->storage.u.compact.buf, p, mesg->storage.u.compact.size); p += mesg->storage.u.compact.size; @@ -194,18 +228,23 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU } /* end if */ else { /* Layout & storage class */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") mesg->type = mesg->storage.type = (H5D_layout_t)*p++; /* Interpret the rest of the message according to the layout class */ switch (mesg->type) { case H5D_COMPACT: /* Compact data size */ + if (H5_IS_BUFFER_OVERFLOW(p, sizeof(uint16_t), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") UINT16DECODE(p, mesg->storage.u.compact.size); if (mesg->storage.u.compact.size > 0) { /* Ensure that size doesn't exceed buffer size, due to possible data corruption */ - if (p + mesg->storage.u.compact.size - 1 > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "storage size exceeds buffer size") + if (H5_IS_BUFFER_OVERFLOW(p, mesg->storage.u.compact.size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") /* Allocate space for compact data */ if (NULL == (mesg->storage.u.compact.buf = H5MM_malloc(mesg->storage.u.compact.size))) @@ -223,9 +262,13 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU case H5D_CONTIGUOUS: /* Contiguous storage address */ + if (H5_IS_BUFFER_OVERFLOW(p, H5F_SIZEOF_ADDR(f), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(mesg->storage.u.contig.addr)); /* Contiguous storage size */ + if (H5_IS_BUFFER_OVERFLOW(p, H5F_SIZEOF_SIZE(f), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") H5F_DECODE_LENGTH(f, p, mesg->storage.u.contig.size); /* Set the layout operations */ @@ -238,22 +281,36 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU mesg->u.chunk.flags = (uint8_t)0; /* Dimensionality */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.ndims = *p++; + if (mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is too large") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "dimensionality is too large") + if (mesg->u.chunk.ndims < 2) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad dimensions for chunked storage") /* B-tree address */ + if (H5_IS_BUFFER_OVERFLOW(p, H5F_SIZEOF_ADDR(f), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); + if (H5_IS_BUFFER_OVERFLOW(p, (mesg->u.chunk.ndims * sizeof(uint32_t)), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") + /* Chunk dimensions */ for (u = 0; u < mesg->u.chunk.ndims; u++) { UINT32DECODE(p, mesg->u.chunk.dim[u]); /* Just in case that something goes very wrong, such as file corruption. */ if (mesg->u.chunk.dim[u] == 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, - "chunk dimension must be positive: mesg->u.chunk.dim[%u] = %u", u, - mesg->u.chunk.dim[u]) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "bad chunk dimension value when parsing layout message - chunk " + "dimension must be positive: mesg->u.chunk.dim[%u] = %u", + u, mesg->u.chunk.dim[u]) } /* end for */ /* Compute chunk size */ @@ -267,6 +324,9 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU } /* end if */ else { /* Get the chunked layout flags */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.flags = *p++; /* Check for valid flags */ @@ -277,25 +337,50 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "bad flag value for message") /* Dimensionality */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.ndims = *p++; + if (mesg->u.chunk.ndims > H5O_LAYOUT_NDIMS) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "dimensionality is too large") /* Encoded # of bytes for each chunk dimension */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.enc_bytes_per_dim = *p++; + if (mesg->u.chunk.enc_bytes_per_dim == 0 || mesg->u.chunk.enc_bytes_per_dim > 8) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "encoded chunk dimension size is too large") + if (H5_IS_BUFFER_OVERFLOW(p, (mesg->u.chunk.ndims * mesg->u.chunk.enc_bytes_per_dim), + p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") + /* Chunk dimensions */ - for (u = 0; u < mesg->u.chunk.ndims; u++) + for (u = 0; u < mesg->u.chunk.ndims; u++) { UINT64DECODE_VAR(p, mesg->u.chunk.dim[u], mesg->u.chunk.enc_bytes_per_dim); + /* Just in case that something goes very wrong, such as file corruption. */ + if (mesg->u.chunk.dim[u] == 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "bad chunk dimension value when parsing layout message - chunk " + "dimension must be positive: mesg->u.chunk.dim[%u] = %u", + u, mesg->u.chunk.dim[u]) + } + /* Compute chunk size */ for (u = 1, mesg->u.chunk.size = mesg->u.chunk.dim[0]; u < mesg->u.chunk.ndims; u++) mesg->u.chunk.size *= mesg->u.chunk.dim[u]; /* Chunk index type */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.idx_type = (H5D_chunk_index_t)*p++; + if (mesg->u.chunk.idx_type >= H5D_CHUNK_IDX_NTYPES) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "unknown chunk index type") mesg->storage.u.chunk.idx_type = mesg->u.chunk.idx_type; @@ -312,6 +397,9 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU case H5D_CHUNK_IDX_SINGLE: /* Single Chunk Index */ if (mesg->u.chunk.flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) { + if (H5_IS_BUFFER_OVERFLOW(p, H5F_SIZEOF_SIZE(f) + sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") H5F_DECODE_LENGTH(f, p, mesg->storage.u.chunk.u.single.nbytes); UINT32DECODE(p, mesg->storage.u.chunk.u.single.filter_mask); } /* end if */ @@ -322,9 +410,13 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU case H5D_CHUNK_IDX_FARRAY: /* Fixed array creation parameters */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits = *p++; + if (0 == mesg->u.chunk.u.farray.cparam.max_dblk_page_nelmts_bits) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid fixed array creation parameter") /* Set the chunk operations */ @@ -333,25 +425,49 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU case H5D_CHUNK_IDX_EARRAY: /* Extensible array creation parameters */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.u.earray.cparam.max_nelmts_bits = *p++; + if (0 == mesg->u.chunk.u.earray.cparam.max_nelmts_bits) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid extensible array creation parameter") + + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.u.earray.cparam.idx_blk_elmts = *p++; + if (0 == mesg->u.chunk.u.earray.cparam.idx_blk_elmts) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid extensible array creation parameter") + + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs = *p++; + if (0 == mesg->u.chunk.u.earray.cparam.sup_blk_min_data_ptrs) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid extensible array creation parameter") + + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.u.earray.cparam.data_blk_min_elmts = *p++; + if (0 == mesg->u.chunk.u.earray.cparam.data_blk_min_elmts) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid extensible array creation parameter") + + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits = *p++; + if (0 == mesg->u.chunk.u.earray.cparam.max_dblk_page_nelmts_bits) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid extensible array creation parameter") /* Set the chunk operations */ @@ -359,10 +475,35 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU break; case H5D_CHUNK_IDX_BT2: /* v2 B-tree index */ + if (H5_IS_BUFFER_OVERFLOW(p, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") UINT32DECODE(p, mesg->u.chunk.u.btree2.cparam.node_size); + + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.u.btree2.cparam.split_percent = *p++; + + if (mesg->u.chunk.u.btree2.cparam.split_percent == 0 || + mesg->u.chunk.u.btree2.cparam.split_percent > 100) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "bad value for v2 B-tree split percent value - must be > 0 and " + "<= 100: split percent = %" PRIu8, + mesg->u.chunk.u.btree2.cparam.split_percent) + + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") mesg->u.chunk.u.btree2.cparam.merge_percent = *p++; + if (mesg->u.chunk.u.btree2.cparam.merge_percent == 0 || + mesg->u.chunk.u.btree2.cparam.merge_percent > 100) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, + "bad value for v2 B-tree merge percent value - must be > 0 and " + "<= 100: merge percent = %" PRIu8, + mesg->u.chunk.u.btree2.cparam.merge_percent) + /* Set the chunk operations */ mesg->storage.u.chunk.ops = H5D_COPS_BT2; break; @@ -373,6 +514,9 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU } /* end switch */ /* Chunk index address */ + if (H5_IS_BUFFER_OVERFLOW(p, H5F_SIZEOF_ADDR(f), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(mesg->storage.u.chunk.idx_addr)); } /* end else */ @@ -386,7 +530,13 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "invalid layout version with virtual layout") /* Heap information */ + if (H5_IS_BUFFER_OVERFLOW(p, H5F_SIZEOF_ADDR(f), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(mesg->storage.u.virt.serial_list_hobjid.addr)); + /* NOTE: virtual mapping global heap entry address could be undefined */ + + if (H5_IS_BUFFER_OVERFLOW(p, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") UINT32DECODE(p, mesg->storage.u.virt.serial_list_hobjid.idx); /* Initialize other fields */ @@ -402,66 +552,114 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU /* Decode heap block if it exists */ if (mesg->storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { const uint8_t *heap_block_p; + const uint8_t *heap_block_p_end; uint8_t heap_vers; size_t block_size = 0; size_t tmp_size; hsize_t tmp_hsize; uint32_t stored_chksum; uint32_t computed_chksum; - size_t i; /* Read heap */ if (NULL == (heap_block = (uint8_t *)H5HG_read( f, &(mesg->storage.u.virt.serial_list_hobjid), NULL, &block_size))) HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "Unable to read global heap block") - heap_block_p = (const uint8_t *)heap_block; + heap_block_p = (const uint8_t *)heap_block; + heap_block_p_end = heap_block_p + block_size - 1; /* Decode the version number of the heap block encoding */ + if (H5_IS_BUFFER_OVERFLOW(heap_block_p, 1, heap_block_p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") heap_vers = (uint8_t)*heap_block_p++; + if ((uint8_t)H5O_LAYOUT_VDS_GH_ENC_VERS != heap_vers) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "bad version # of encoded VDS heap information, expected %u, got %u", (unsigned)H5O_LAYOUT_VDS_GH_ENC_VERS, (unsigned)heap_vers) /* Number of entries */ + if (H5_IS_BUFFER_OVERFLOW(heap_block_p, H5F_SIZEOF_SIZE(f), heap_block_p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") H5F_DECODE_LENGTH(f, heap_block_p, tmp_hsize) /* Allocate entry list */ if (NULL == (mesg->storage.u.virt.list = (H5O_storage_virtual_ent_t *)H5MM_calloc( (size_t)tmp_hsize * sizeof(H5O_storage_virtual_ent_t)))) - HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, "unable to allocate heap block") + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "unable to allocate heap block") mesg->storage.u.virt.list_nalloc = (size_t)tmp_hsize; mesg->storage.u.virt.list_nused = (size_t)tmp_hsize; /* Decode each entry */ - for (i = 0; i < mesg->storage.u.virt.list_nused; i++) { + for (size_t i = 0; i < mesg->storage.u.virt.list_nused; i++) { + ptrdiff_t avail_buffer_space; + + avail_buffer_space = heap_block_p_end - heap_block_p + 1; + if (avail_buffer_space <= 0) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") + /* Source file name */ - tmp_size = HDstrlen((const char *)heap_block_p) + 1; + tmp_size = HDstrnlen((const char *)heap_block_p, (size_t)avail_buffer_space); + if (tmp_size == (size_t)avail_buffer_space) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding - unterminated source " + "file name string") + else + tmp_size += 1; /* Add space for NUL terminator */ + if (NULL == (mesg->storage.u.virt.list[i].source_file_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "unable to allocate memory for source file name") H5MM_memcpy(mesg->storage.u.virt.list[i].source_file_name, heap_block_p, tmp_size); heap_block_p += tmp_size; + avail_buffer_space = heap_block_p_end - heap_block_p + 1; + if (avail_buffer_space <= 0) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") + /* Source dataset name */ - tmp_size = HDstrlen((const char *)heap_block_p) + 1; + tmp_size = HDstrnlen((const char *)heap_block_p, (size_t)avail_buffer_space); + if (tmp_size == (size_t)avail_buffer_space) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding - unterminated source " + "dataset name string") + else + tmp_size += 1; /* Add space for NUL terminator */ + if (NULL == (mesg->storage.u.virt.list[i].source_dset_name = (char *)H5MM_malloc(tmp_size))) - HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, NULL, + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "unable to allocate memory for source dataset name") H5MM_memcpy(mesg->storage.u.virt.list[i].source_dset_name, heap_block_p, tmp_size); heap_block_p += tmp_size; /* Source selection */ - if (H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_select, - &heap_block_p) < 0) + avail_buffer_space = heap_block_p_end - heap_block_p + 1; + + if (avail_buffer_space <= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, NULL, + "buffer overflow while decoding layout") + + if (H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_select, &heap_block_p, + (size_t)(avail_buffer_space)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode source space selection") /* Virtual selection */ + + /* Buffer space must be updated after previous deserialization */ + avail_buffer_space = heap_block_p_end - heap_block_p + 1; + + if (avail_buffer_space <= 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, NULL, + "buffer overflow while decoding layout") + if (H5S_SELECT_DESERIALIZE(&mesg->storage.u.virt.list[i].source_dset.virtual_select, - &heap_block_p) < 0) + &heap_block_p, (size_t)(avail_buffer_space)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't decode virtual space selection") @@ -532,6 +730,9 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU } /* end for */ /* Read stored checksum */ + if (H5_IS_BUFFER_OVERFLOW(heap_block_p, sizeof(uint32_t), heap_block_p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, + "ran off end of input buffer while decoding") UINT32DECODE(heap_block_p, stored_chksum) /* Compute checksum */ @@ -555,7 +756,7 @@ H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: default: - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "Invalid layout class") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "Invalid layout class") } /* end switch */ } /* end else */ @@ -754,8 +955,8 @@ static void * H5O__layout_copy(const void *_mesg, void *_dest) { const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg; - H5O_layout_t * dest = (H5O_layout_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_layout_t *dest = (H5O_layout_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1039,10 +1240,10 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, H5O_copy_t *cpy_info, void *_udata) { H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */ - H5O_layout_t * layout_src = (H5O_layout_t *)mesg_src; - H5O_layout_t * layout_dst = NULL; + H5O_layout_t *layout_src = (H5O_layout_t *)mesg_src; + H5O_layout_t *layout_dst = NULL; hbool_t copied = FALSE; /* Whether the data was copied */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index 711f199c077..46987f91bb1 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -34,10 +33,10 @@ #include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void * H5O__linfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__linfo_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__linfo_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__linfo_copy(const void *_mesg, void *_dest); +static void *H5O__linfo_copy(const void *_mesg, void *_dest); static size_t H5O__linfo_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__linfo_free(void *_mesg); static herr_t H5O__linfo_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); @@ -53,7 +52,7 @@ const H5O_msg_class_t H5O_MSG_LINFO[1] = {{ H5O_LINFO_ID, /*message id number */ "linfo", /*message name for debugging */ sizeof(H5O_linfo_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__linfo_decode, /*decode message */ H5O__linfo_encode, /*encode message */ H5O__linfo_copy, /*copy the native value */ @@ -83,9 +82,9 @@ const H5O_msg_class_t H5O_MSG_LINFO[1] = {{ /* Data exchange structure to use when copying links from src to dst */ typedef struct { const H5O_loc_t *src_oloc; /* Source object location */ - H5O_loc_t * dst_oloc; /* Destination object location */ - H5O_linfo_t * dst_linfo; /* Destination object's link info message */ - H5O_copy_t * cpy_info; /* Information for copy operation */ + H5O_loc_t *dst_oloc; /* Destination object location */ + H5O_linfo_t *dst_linfo; /* Destination object's link info message */ + H5O_copy_t *cpy_info; /* Information for copy operation */ } H5O_linfo_postcopy_ud_t; /* Declare a free list to manage the H5O_linfo_t struct */ @@ -106,11 +105,13 @@ H5FL_DEFINE_STATIC(H5O_linfo_t); */ static void * H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, - unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) + unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_linfo_t * linfo = NULL; /* Link info */ - unsigned char index_flags; /* Flags for encoding link index info */ - void * ret_value = NULL; /* Return value */ + const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ + H5O_linfo_t *linfo = NULL; /* Link info */ + unsigned char index_flags; /* Flags for encoding link index info */ + uint8_t addr_size = H5F_SIZEOF_ADDR(f); /* Temp var */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -118,13 +119,17 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS HDassert(f); HDassert(p); + /* Check input buffer before decoding version and index flags */ + if (H5_IS_BUFFER_OVERFLOW(p, 2, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") + /* Version of message */ if (*p++ != H5O_LINFO_VERSION) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for message") /* Allocate space for message */ if (NULL == (linfo = H5FL_MALLOC(H5O_linfo_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed") /* Get the index flags for the group */ index_flags = *p++; @@ -137,11 +142,18 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS linfo->nlinks = HSIZET_MAX; /* Max. link creation order value for the group, if tracked */ - if (linfo->track_corder) + if (linfo->track_corder) { + if (H5_IS_BUFFER_OVERFLOW(p, 8, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") INT64DECODE(p, linfo->max_corder) + } else linfo->max_corder = 0; + /* Check input buffer before decoding the next two addresses */ + if (H5_IS_BUFFER_OVERFLOW(p, addr_size + addr_size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") + /* Address of fractal heap to store "dense" links */ H5F_addr_decode(f, &p, &(linfo->fheap_addr)); @@ -149,8 +161,11 @@ H5O__linfo_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUS H5F_addr_decode(f, &p, &(linfo->name_bt2_addr)); /* Address of v2 B-tree to index creation order of links, if there is one */ - if (linfo->index_corder) + if (linfo->index_corder) { + if (H5_IS_BUFFER_OVERFLOW(p, addr_size, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") H5F_addr_decode(f, &p, &(linfo->corder_bt2_addr)); + } else linfo->corder_bt2_addr = HADDR_UNDEF; @@ -235,8 +250,8 @@ static void * H5O__linfo_copy(const void *_mesg, void *_dest) { const H5O_linfo_t *linfo = (const H5O_linfo_t *)_mesg; - H5O_linfo_t * dest = (H5O_linfo_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_linfo_t *dest = (H5O_linfo_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -367,10 +382,10 @@ H5O__linfo_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t *fi hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info, void *_udata) { - H5O_linfo_t * linfo_src = (H5O_linfo_t *)native_src; - H5O_linfo_t * linfo_dst = NULL; + H5O_linfo_t *linfo_src = (H5O_linfo_t *)native_src; + H5O_linfo_t *linfo_dst = NULL; H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *)_udata; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_TAG(H5AC__COPIED_TAG) @@ -485,7 +500,7 @@ H5O__linfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_l void *mesg_dst, unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info) { const H5O_linfo_t *linfo_src = (const H5O_linfo_t *)mesg_src; - H5O_linfo_t * linfo_dst = (H5O_linfo_t *)mesg_dst; + H5O_linfo_t *linfo_dst = (H5O_linfo_t *)mesg_dst; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Olink.c b/src/H5Olink.c index 75456f4449f..c4d541e29f3 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -39,13 +38,13 @@ static void *H5O__link_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__link_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__link_copy(const void *_mesg, void *_dest); +static void *H5O__link_copy(const void *_mesg, void *_dest); static size_t H5O__link_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__link_reset(void *_mesg); static herr_t H5O__link_free(void *_mesg); static herr_t H5O__link_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata); -static void * H5O__link_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, +static void *H5O__link_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata); static herr_t H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info); @@ -56,7 +55,7 @@ const H5O_msg_class_t H5O_MSG_LINK[1] = {{ H5O_LINK_ID, /*message id number */ "link", /*message name for debugging */ sizeof(H5O_link_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__link_decode, /*decode message */ H5O__link_encode, /*encode message */ H5O__link_copy, /*copy the native value */ @@ -114,11 +113,11 @@ static void * H5O__link_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_link_t * lnk = NULL; /* Pointer to link message */ + H5O_link_t *lnk = NULL; /* Pointer to link message */ size_t len = 0; /* Length of a string in the message */ unsigned char link_flags; /* Flags for encoding link info */ const uint8_t *p_end = p + p_size; /* End of the p buffer */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -414,8 +413,8 @@ static void * H5O__link_copy(const void *_mesg, void *_dest) { const H5O_link_t *lnk = (const H5O_link_t *)_mesg; - H5O_link_t * dest = (H5O_link_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_link_t *dest = (H5O_link_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -719,7 +718,7 @@ H5O__link_copy_file(H5F_t H5_ATTR_UNUSED *file_src, void *native_src, H5F_t H5_A H5O_copy_t H5_ATTR_UNUSED *cpy_info, void H5_ATTR_UNUSED *udata) { H5O_link_t *link_src = (H5O_link_t *)native_src; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -758,7 +757,7 @@ H5O__link_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_lo unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info) { const H5O_link_t *link_src = (const H5O_link_t *)mesg_src; - H5O_link_t * link_dst = (H5O_link_t *)mesg_dst; + H5O_link_t *link_dst = (H5O_link_t *)mesg_dst; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 15edf1e2bc8..8c2d4de4f95 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -50,11 +49,11 @@ /* User data for iteration while removing a message */ typedef struct { - H5F_t * f; /* Pointer to file for insertion */ + H5F_t *f; /* Pointer to file for insertion */ int sequence; /* Sequence # to search for */ unsigned nfailed; /* # of failed message removals */ H5O_operator_t op; /* Callback routine for removal operations */ - void * op_data; /* Callback data for removal operations */ + void *op_data; /* Callback data for removal operations */ hbool_t adj_link; /* Whether to adjust links when removing messages */ } H5O_iter_rm_t; @@ -237,7 +236,7 @@ H5O__msg_append_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned herr_t H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, unsigned update_flags, void *mesg) { - H5O_t * oh = NULL; /* Object header to use */ + H5O_t *oh = NULL; /* Object header to use */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value = SUCCEED; /* Return value */ @@ -371,7 +370,7 @@ H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned m HDassert(((H5O_shared_t *)idx_msg->native)->type != H5O_SHARE_TYPE_COMMITTED); /* Also, sanity check that a message doesn't switch status from being - * shared (or sharable) to being unsharable. (Which could cause + * shared (or shareable) to being unshareable. (Which could cause * a message to increase in size in the object header) */ HDassert(!(mesg_flags & H5O_MSG_FLAG_DONTSHARE)); @@ -437,7 +436,7 @@ void * H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg) { H5O_t *oh = NULL; /* Object header to use */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_TAG(loc->addr, NULL) @@ -489,7 +488,7 @@ H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ unsigned idx; /* Message's index in object header */ - void * ret_value = NULL; + void *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -616,7 +615,7 @@ void * H5O_msg_free(unsigned type_id, void *mesg) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -676,12 +675,11 @@ H5O_msg_free_real(const H5O_msg_class_t *type, void *msg_native) { FUNC_ENTER_NOAPI_NOINIT_NOERR - /* check args */ - HDassert(type); + /* Don't assert on args since this could be called in cleanup code */ if (msg_native) { H5O__msg_reset_real(type, msg_native); - if (NULL != (type->free)) + if (type && type->free) (type->free)(msg_native); else H5MM_xfree(msg_native); @@ -709,7 +707,7 @@ void * H5O_msg_copy(unsigned type_id, const void *mesg, void *dst) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -745,7 +743,7 @@ H5O_msg_copy(unsigned type_id, const void *mesg, void *dst) int H5O_msg_count(const H5O_loc_t *loc, unsigned type_id) { - H5O_t * oh = NULL; /* Object header to operate on */ + H5O_t *oh = NULL; /* Object header to operate on */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ unsigned msg_count; /* Message count */ int ret_value = FAIL; /* Return value */ @@ -918,7 +916,7 @@ H5O_msg_exists_oh(const H5O_t *oh, unsigned type_id) herr_t H5O_msg_remove(const H5O_loc_t *loc, unsigned type_id, int sequence, hbool_t adj_link) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value = FAIL; /* Return value */ @@ -968,7 +966,7 @@ herr_t H5O_msg_remove_op(const H5O_loc_t *loc, unsigned type_id, int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value = FAIL; /* Return value */ @@ -1131,7 +1129,7 @@ H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, int seque * Nov 19 2004 * * Description: - * This function interates over the object headers of an object + * This function iterates over the object headers of an object * specified with 'loc' of type 'type_id'. For each object header of the * object, the 'op_data' and some additional information (specified below) are * passed to the 'op' function. @@ -1151,7 +1149,7 @@ H5O__msg_remove_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, int seque herr_t H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, const H5O_mesg_operator_t *op, void *op_data) { - H5O_t * oh = NULL; /* Pointer to actual object header */ + H5O_t *oh = NULL; /* Pointer to actual object header */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ herr_t ret_value = FAIL; /* Return value */ @@ -1194,7 +1192,7 @@ H5O_msg_iterate(const H5O_loc_t *loc, unsigned type_id, const H5O_mesg_operator_ * Sep 6 2005 * * Description: - * This function interates over the object headers of an object + * This function iterates over the object headers of an object * specified with 'ent' of type 'type_id'. For each object header of the * object, the 'op_data' and some additional information (specified below) are * passed to the 'op' function. @@ -1336,7 +1334,7 @@ size_t H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, const void *mesg, size_t extra_raw) { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - H5P_genplist_t * ocpl; /* Object Creation Property list */ + H5P_genplist_t *ocpl; /* Object Creation Property list */ uint8_t oh_flags; /* Object header status flags */ size_t ret_value = 0; /* Return value */ @@ -1544,7 +1542,7 @@ H5O_msg_is_shared(unsigned type_id, const void *mesg) HDassert(type); HDassert(mesg); - /* If messages in a class aren't sharable, then obviously this message isn't shared! :-) */ + /* If messages in a class aren't shareable, then obviously this message isn't shared! :-) */ if (type->share_flags & H5O_SHARE_IS_SHARABLE) ret_value = H5O_IS_STORED_SHARED(((const H5O_shared_t *)mesg)->type); else @@ -1731,7 +1729,7 @@ H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, cons { const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ unsigned ioflags = 0; /* Flags for decode routine */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1878,7 +1876,7 @@ H5O__copy_mesg(H5F_t *f, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, con unsigned mesg_flags, unsigned update_flags) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - H5O_mesg_t * idx_msg = &oh->mesg[idx]; /* Pointer to message to modify */ + H5O_mesg_t *idx_msg = &oh->mesg[idx]; /* Pointer to message to modify */ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2170,9 +2168,9 @@ H5O__flush_msgs(H5F_t *f, H5O_t *oh) herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t *flags) { - H5O_t * oh = NULL; /* Object header to use */ + H5O_t *oh = NULL; /* Object header to use */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ - H5O_mesg_t * idx_msg; /* Pointer to message to modify */ + H5O_mesg_t *idx_msg; /* Pointer to message to modify */ unsigned idx; /* Index of message to modify */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Omodule.h b/src/H5Omodule.h index 134aa920528..0c482c595ce 100644 --- a/src/H5Omodule.h +++ b/src/H5Omodule.h @@ -29,10 +29,52 @@ #define H5_MY_PKG_ERR H5E_OHDR #define H5_MY_PKG_INIT YES -/**\defgroup H5O H5O - * \brief Object Interface +/** \page H5O_UG The HDF5 Objects + * @todo Under Construction + */ + +/** + * \defgroup H5O Objects (H5O) + * + * Use the functions in this module to manage HDF5 objects. + * + * HDF5 objects (groups, datasets, datatype objects) are usually created + * using functions in the object-specific modules (\ref H5G, \ref H5D, + * \ref H5T). However, new objects can also be created by copying existing + * objects. + * + * Many functions in this module are variations on object introspection, + * that is, the retrieval of detailed information about HDF5 objects in a file. + * Objects in an HDF5 file can be "visited" in an iterative fashion. + * + * HDF5 objects are usually updated using functions in the object-specific + * modules. However, there are certain generic object properties, such as + * reference counts, that can be manipulated using functions in this module. + * + * HDF5 objects are deleted as a side effect of rendering them unreachable + * from the root group. The net effect is the diminution of the object's + * reference count to zero, which can (but should not usually) be effected + * by a function in this module. * - * \todo Describe concisely what the functions in this module are about. + * + * + * + * + * + * + * + * + * + * + *
    CreateRead
    + * \snippet{lineno} H5O_examples.c create + * + * \snippet{lineno} H5O_examples.c read + *
    UpdateDelete
    + * \snippet{lineno} H5O_examples.c update + * + * \snippet{lineno} H5O_examples.c delete + *
    * */ #endif /* H5Omodule_H */ diff --git a/src/H5Omtime.c b/src/H5Omtime.c index d48d226242e..93cd370440c 100644 --- a/src/H5Omtime.c +++ b/src/H5Omtime.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -25,15 +24,15 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ -static void * H5O__mtime_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__mtime_new_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__mtime_new_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); static size_t H5O__mtime_new_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); -static void * H5O__mtime_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__mtime_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__mtime_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__mtime_copy(const void *_mesg, void *_dest); +static void *H5O__mtime_copy(const void *_mesg, void *_dest); static size_t H5O__mtime_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__mtime_free(void *_mesg); static herr_t H5O__mtime_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -43,7 +42,7 @@ const H5O_msg_class_t H5O_MSG_MTIME[1] = {{ H5O_MTIME_ID, /*message id number */ "mtime", /*message name for debugging */ sizeof(time_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__mtime_decode, /*decode message */ H5O__mtime_encode, /*encode message */ H5O__mtime_copy, /*copy the native value */ @@ -68,7 +67,7 @@ const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{ H5O_MTIME_NEW_ID, /*message id number */ "mtime_new", /*message name for debugging */ sizeof(time_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__mtime_new_decode, /*decode message */ H5O__mtime_new_encode, /*encode message */ H5O__mtime_copy, /*copy the native value */ @@ -116,9 +115,9 @@ H5O__mtime_new_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - time_t * mesg; + time_t *mesg; uint32_t tmp_time; /* Temporary copy of the time */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -170,10 +169,10 @@ static void * H5O__mtime_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - time_t * mesg, the_time; + time_t *mesg, the_time; struct tm tm; int i; /* Local index variable */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -266,7 +265,7 @@ H5O__mtime_encode(H5F_t H5_ATTR_UNUSED *f, hbool_t H5_ATTR_UNUSED disable_shared const void *_mesg) { const time_t *mesg = (const time_t *)_mesg; - struct tm * tm; + struct tm *tm; FUNC_ENTER_STATIC_NOERR @@ -302,8 +301,8 @@ static void * H5O__mtime_copy(const void *_mesg, void *_dest) { const time_t *mesg = (const time_t *)_mesg; - time_t * dest = (time_t *)_dest; - void * ret_value = NULL; /* Return value */ + time_t *dest = (time_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -422,7 +421,7 @@ static herr_t H5O__mtime_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream, int indent, int fwidth) { const time_t *mesg = (const time_t *)_mesg; - struct tm * tm; + struct tm *tm; char buf[128]; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Oname.c b/src/H5Oname.c index 979b2404bb6..5fffc1d04d4 100644 --- a/src/H5Oname.c +++ b/src/H5Oname.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -33,7 +32,7 @@ static void *H5O__name_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__name_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__name_copy(const void *_mesg, void *_dest); +static void *H5O__name_copy(const void *_mesg, void *_dest); static size_t H5O__name_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__name_reset(void *_mesg); static herr_t H5O__name_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -43,7 +42,7 @@ const H5O_msg_class_t H5O_MSG_NAME[1] = {{ H5O_NAME_ID, /*message id number */ "name", /*message name for debugging */ sizeof(H5O_name_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__name_decode, /*decode message */ H5O__name_encode, /*encode message */ H5O__name_copy, /*copy the native value */ @@ -82,7 +81,7 @@ H5O__name_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigne unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_name_t *mesg; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -157,8 +156,8 @@ static void * H5O__name_copy(const void *_mesg, void *_dest) { const H5O_name_t *mesg = (const H5O_name_t *)_mesg; - H5O_name_t * dest = (H5O_name_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_name_t *dest = (H5O_name_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Onull.c b/src/H5Onull.c index 9b377fbb871..7e6eba7ca93 100644 --- a/src/H5Onull.c +++ b/src/H5Onull.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -31,7 +30,7 @@ const H5O_msg_class_t H5O_MSG_NULL[1] = {{ H5O_NULL_ID, /*message id number */ "null", /*message name for debugging */ 0, /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ NULL, /*no decode method */ NULL, /*no encode method */ NULL, /*no copy method */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 6e203bb48fd..ce22856f46a 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -238,8 +237,8 @@ struct H5O_mesg_t { uint8_t flags; /* message flags */ H5O_msg_crt_idx_t crt_idx; /* message creation index */ unsigned chunkno; /* chunk number for this mesg */ - void * native; /* native format message */ - uint8_t * raw; /* pointer to raw data */ + void *native; /* native format message */ + uint8_t *raw; /* pointer to raw data */ size_t raw_size; /* size with alignment */ }; @@ -258,7 +257,7 @@ typedef struct H5O_chunk_t { haddr_t addr; /*chunk file address */ size_t size; /*chunk size */ size_t gap; /*space at end of chunk too small for null message */ - uint8_t * image; /*image of file */ + uint8_t *image; /*image of file */ struct H5O_chunk_proxy_t *chunk_proxy; /* Pointer to a chunk's proxy when chunk protected */ } H5O_chunk_t; @@ -340,7 +339,7 @@ typedef struct H5O_addr_map_t { hbool_t is_locked; /* Indicate that the destination object is locked currently */ hsize_t inc_ref_count; /* Number of deferred increments to reference count */ const H5O_obj_class_t *obj_class; /* Object class */ - void * udata; /* Object class copy file udata */ + void *udata; /* Object class copy file udata */ } H5O_addr_map_t; /* Stack of continuation messages to interpret */ @@ -352,7 +351,7 @@ typedef struct H5O_cont_msgs_t { /* Common callback information for loading object header prefix from disk */ typedef struct H5O_common_cache_ud_t { - H5F_t * f; /* Pointer to file for object header/chunk */ + H5F_t *f; /* Pointer to file for object header/chunk */ unsigned file_intent; /* Read/write intent for file */ unsigned merged_null_msgs; /* Number of null messages merged together */ H5O_cont_msgs_t *cont_msg_info; /* Pointer to continuation messages to work on */ @@ -364,7 +363,7 @@ typedef struct H5O_cache_ud_t { hbool_t made_attempt; /* Whether the deserialize routine was already attempted */ unsigned v1_pfx_nmesgs; /* Number of messages from v1 prefix header */ size_t chunk0_size; /* Size of serialized first chunk */ - H5O_t * oh; /* Partially deserialized object header, for later use */ + H5O_t *oh; /* Partially deserialized object header, for later use */ hbool_t free_oh; /* Whether to free the object header or not */ H5O_common_cache_ud_t common; /* Common object header cache callback info */ } H5O_cache_ud_t; @@ -374,11 +373,11 @@ typedef struct H5O_chunk_proxy_t { H5AC_info_t cache_info; /* Information for metadata cache functions, _must_ be */ /* first field in structure */ - H5F_t * f; /* Pointer to file for object header/chunk */ - H5O_t * oh; /* Object header for this chunk */ + H5F_t *f; /* Pointer to file for object header/chunk */ + H5O_t *oh; /* Object header for this chunk */ unsigned chunkno; /* Chunk number for this chunk */ - /* Flush depencency parent information (not stored) + /* Flush dependency parent information (not stored) * * The following field is used to store a pointer * to the in-core representation of a new chunk proxy's flush dependency @@ -395,7 +394,7 @@ typedef struct H5O_chunk_proxy_t { /* Callback information for loading object header chunk from disk */ typedef struct H5O_chk_cache_ud_t { hbool_t decoding; /* Whether the object header is being decoded */ - H5O_t * oh; /* Object header for this chunk */ + H5O_t *oh; /* Object header for this chunk */ unsigned chunkno; /* Index of chunk being brought in (for re-loads) */ size_t size; /* Size of chunk in the file */ H5O_common_cache_ud_t common; /* Common object header cache callback info */ @@ -573,7 +572,7 @@ H5_DLL herr_t H5O__flush_msgs(H5F_t *f, H5O_t *oh); H5_DLL herr_t H5O__delete_mesg(H5F_t *f, H5O_t *open_oh, H5O_mesg_t *mesg); /* Object header chunk routines */ -H5_DLL herr_t H5O__chunk_add(H5F_t *f, H5O_t *oh, unsigned idx, unsigned cont_chunkno); +H5_DLL herr_t H5O__chunk_add(H5F_t *f, H5O_t *oh, unsigned idx, unsigned cont_chunkno); H5_DLL H5O_chunk_proxy_t *H5O__chunk_protect(H5F_t *f, H5O_t *oh, unsigned idx); H5_DLL herr_t H5O__chunk_unprotect(H5F_t *f, H5O_chunk_proxy_t *chk_proxy, hbool_t chk_dirtied); H5_DLL herr_t H5O__chunk_update_idx(H5F_t *f, H5O_t *oh, unsigned idx); @@ -594,7 +593,7 @@ H5_DLL herr_t H5O__condense_header(H5F_t *f, H5O_t *oh); H5_DLL herr_t H5O__release_mesg(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link); /* Shared object operators */ -H5_DLL void * H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *buf, +H5_DLL void *H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *buf, const H5O_msg_class_t *type); H5_DLL herr_t H5O__shared_encode(const H5F_t *f, uint8_t *buf /*out*/, const H5O_shared_t *sh_mesg); H5_DLL size_t H5O__shared_size(const H5F_t *f, const H5O_shared_t *sh_mesg); diff --git a/src/H5Opline.c b/src/H5Opline.c index 4b76da9443c..2babcc0a804 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -31,9 +30,9 @@ /* PRIVATE PROTOTYPES */ static herr_t H5O__pline_encode(H5F_t *f, uint8_t *p, const void *mesg); -static void * H5O__pline_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__pline_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); -static void * H5O__pline_copy(const void *_mesg, void *_dest); +static void *H5O__pline_copy(const void *_mesg, void *_dest); static size_t H5O__pline_size(const H5F_t *f, const void *_mesg); static herr_t H5O__pline_reset(void *_mesg); static herr_t H5O__pline_free(void *_mesg); @@ -67,7 +66,7 @@ const H5O_msg_class_t H5O_MSG_PLINE[1] = {{ H5O_PLINE_ID, /* message id number */ "filter pipeline", /* message name for debugging */ sizeof(H5O_pline_t), /* native message size */ - H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are shareable? */ H5O__pline_shared_decode, /* decode message */ H5O__pline_shared_encode, /* encode message */ H5O__pline_copy, /* copy the native value */ @@ -86,7 +85,7 @@ const H5O_msg_class_t H5O_MSG_PLINE[1] = {{ H5O__pline_shared_debug /* debug the message */ }}; -/* Format version bounds for filter pipleline */ +/* Format version bounds for filter pipeline */ const unsigned H5O_pline_ver_bounds[] = { H5O_PLINE_VERSION_1, /* H5F_LIBVER_EARLIEST */ H5O_PLINE_VERSION_2, /* H5F_LIBVER_V18 */ @@ -110,16 +109,17 @@ H5FL_DEFINE(H5O_pline_t); * *------------------------------------------------------------------------- */ + static void * H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5O_pline_t * pline = NULL; /* Pipeline message */ + H5O_pline_t *pline = NULL; /* Pipeline message */ H5Z_filter_info_t *filter; /* Filter to decode */ size_t name_length; /* Length of filter name */ size_t i; /* Local index variable */ - const uint8_t * p_end = p + p_size - 1; /* End of the p buffer */ - void * ret_value = NULL; /* Return value */ + const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -131,6 +131,9 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Version */ + if (p + 4 - 1 > p_end) /* 4 byte is minimum for all versions */ + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "ran off the end of the buffer: current p = %p, p_end = %p", + p + 4, p_end) pline->version = *p++; if (pline->version < H5O_PLINE_VERSION_1 || pline->version > H5O_PLINE_VERSION_LATEST) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "bad version number for filter pipeline message") @@ -159,6 +162,9 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign /* Decode filters */ for (i = 0, filter = &pline->filter[0]; i < pline->nused; i++, filter++) { /* Filter ID */ + if (p + 6 - 1 > p_end) /* 6 bytes minimum */ + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, + "ran off the end of the buffer: current p = %p, p_end = %p", p + 6, p_end) UINT16DECODE(p, filter->id); /* Length of filter name */ @@ -168,6 +174,9 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign UINT16DECODE(p, name_length); if (pline->version == H5O_PLINE_VERSION_1 && name_length % 8) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter name length is not a multiple of eight") + if (p + 4 - 1 > p_end) /* with name_length 4 bytes to go */ + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, + "ran off the end of the buffer: current p = %p, p_end = %p", p + 4, p_end) } /* end if */ /* Filter flags */ @@ -179,9 +188,12 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign /* Filter name, if there is one */ if (name_length) { size_t actual_name_length; /* Actual length of name */ - + size_t len = (size_t)(p_end - p + 1); /* Determine actual name length (without padding, but with null terminator) */ - actual_name_length = HDstrlen((const char *)p) + 1; + actual_name_length = HDstrnlen((const char *)p, len); + if (actual_name_length == len) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "filter name not null terminated") + actual_name_length += 1; /* include \0 byte */ HDassert(actual_name_length <= name_length); /* Allocate space for the filter name, or use the internal buffer */ @@ -255,7 +267,7 @@ H5O__pline_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, unsign static herr_t H5O__pline_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p /*out*/, const void *mesg) { - const H5O_pline_t * pline = (const H5O_pline_t *)mesg; /* Pipeline message to encode */ + const H5O_pline_t *pline = (const H5O_pline_t *)mesg; /* Pipeline message to encode */ const H5Z_filter_info_t *filter; /* Filter to encode */ size_t i, j; /* Local index variables */ @@ -357,9 +369,9 @@ static void * H5O__pline_copy(const void *_src, void *_dst /*out*/) { const H5O_pline_t *src = (const H5O_pline_t *)_src; /* Source pipeline message */ - H5O_pline_t * dst = (H5O_pline_t *)_dst; /* Destination pipeline message */ + H5O_pline_t *dst = (H5O_pline_t *)_dst; /* Destination pipeline message */ size_t i; /* Local index variable */ - H5O_pline_t * ret_value = NULL; /* Return value */ + H5O_pline_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -592,7 +604,7 @@ static herr_t H5O__pline_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void *_udata) { - const H5O_pline_t * pline_src = (const H5O_pline_t *)mesg_src; /* Source pline */ + const H5O_pline_t *pline_src = (const H5O_pline_t *)mesg_src; /* Source pline */ H5O_copy_file_ud_common_t *udata = (H5O_copy_file_ud_common_t *)_udata; /* Object copying user data */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 6d901b38e2b..6da2a67404e 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -158,7 +157,7 @@ typedef union { /* The object location information for an object */ typedef struct H5O_loc_t { - H5F_t * file; /* File that object header is located within */ + H5F_t *file; /* File that object header is located within */ haddr_t addr; /* File address of object header */ hbool_t holding_file; /* True if this object header has incremented * its file's count of open objects. */ @@ -166,14 +165,14 @@ typedef struct H5O_loc_t { /* Typedef for linked list of datatype merge suggestions */ typedef struct H5O_copy_dtype_merge_list_t { - char * path; /* Path to datatype in destination file */ + char *path; /* Path to datatype in destination file */ struct H5O_copy_dtype_merge_list_t *next; /* Next object in list */ } H5O_copy_dtype_merge_list_t; /* Structure for callback property before searching the global list of committed datatypes at destination */ typedef struct H5O_mcdt_cb_info_t { H5O_mcdt_search_cb_t func; - void * user_data; + void *user_data; } H5O_mcdt_cb_info_t; /* Settings/flags for copying an object */ @@ -188,8 +187,8 @@ typedef struct H5O_copy_t { H5O_copy_dtype_merge_list_t *dst_dt_suggestion_list; /* Suggestions for merging committed datatypes */ int curr_depth; /* Current depth in hierarchy copied */ int max_depth; /* Maximum depth in hierarchy to copy */ - H5SL_t * map_list; /* Skip list to hold address mappings */ - H5SL_t * dst_dt_list; /* Skip list to hold committed datatypes in dest file */ + H5SL_t *map_list; /* Skip list to hold address mappings */ + H5SL_t *dst_dt_list; /* Skip list to hold committed datatypes in dest file */ hbool_t dst_dt_list_complete; /* Whether the destination datatype list is complete (i.e. not only populated with "suggestions" from H5Padd_merge_committed_dtype_path) */ H5O_t *oh_dst; /* The destination object header */ @@ -198,7 +197,7 @@ typedef struct H5O_copy_t { the destination file's high bound. The high bound is used to index into the corresponding message's array of versions for doing version bounds check. */ - void * shared_fo; /* The shared pointer for the src object */ + void *shared_fo; /* The shared pointer for the src object */ H5O_mcdt_search_cb_t mcdt_cb; /* The callback to invoke before searching the global list of committed datatypes at destination */ void *mcdt_ud; /* User data passed to callback */ @@ -251,7 +250,7 @@ typedef struct H5O_copy_t { #define H5O_SHARE_TYPE_UNSHARED 0 /* Message is not shared */ #define H5O_SHARE_TYPE_SOHM 1 /* Message is stored in SOHM heap */ #define H5O_SHARE_TYPE_COMMITTED 2 /* Message is stored in another object header */ -#define H5O_SHARE_TYPE_HERE 3 /* Message is stored in this object header, but is sharable */ +#define H5O_SHARE_TYPE_HERE 3 /* Message is stored in this object header, but is shareable */ /* Detect messages that aren't stored in message's object header */ #define H5O_IS_STORED_SHARED(T) \ @@ -276,7 +275,7 @@ typedef struct H5O_mesg_loc_t { */ typedef struct H5O_shared_t { unsigned type; /* Type describing how message is shared */ - H5F_t * file; /* File that message is located within */ + H5F_t *file; /* File that message is located within */ unsigned msg_type_id; /* Message's type ID */ union { H5O_mesg_loc_t loc; /* Object location info */ @@ -334,9 +333,9 @@ struct H5O_fill_t { H5O_shared_t sh_loc; /* Shared message info (must be first) */ unsigned version; /* Encoding version number */ - H5T_t * type; /*type. Null implies same as dataset */ + H5T_t *type; /*type. Null implies same as dataset */ ssize_t size; /*number of bytes in the fill value */ - void * buf; /*the fill value */ + void *buf; /*the fill value */ H5D_alloc_time_t alloc_time; /* time to allocate space */ H5D_fill_time_t fill_time; /* time to write fill value */ hbool_t fill_defined; /* whether fill value is defined */ @@ -355,7 +354,7 @@ typedef struct H5O_link_soft_t { } H5O_link_soft_t; typedef struct H5O_link_ud_t { - void * udata; /* Opaque data supplied by the user */ + void *udata; /* Opaque data supplied by the user */ size_t size; /* Size of udata */ } H5O_link_ud_t; @@ -364,7 +363,7 @@ typedef struct H5O_link_t { hbool_t corder_valid; /* Creation order for link is valid (not stored) */ int64_t corder; /* Creation order for link (stored if it's valid) */ H5T_cset_t cset; /* Character set of link name */ - char * name; /* Link name */ + char *name; /* Link name */ union { H5O_link_hard_t hard; /* Information for hard links */ H5O_link_soft_t soft; /* Information for soft links */ @@ -381,7 +380,7 @@ typedef struct H5O_link_t { typedef struct H5O_efl_entry_t { size_t name_offset; /*offset of name within heap */ - char * name; /*malloc'd name */ + char *name; /*malloc'd name */ HDoff_t offset; /*offset of data within file */ hsize_t size; /*size allocated within file */ } H5O_efl_entry_t; @@ -497,7 +496,7 @@ typedef struct H5O_storage_chunk_t { typedef struct H5O_storage_compact_t { hbool_t dirty; /* Dirty flag for compact dataset */ size_t size; /* Size of buffer in bytes */ - void * buf; /* Buffer for compact dataset */ + void *buf; /* Buffer for compact dataset */ } H5O_storage_compact_t; typedef struct H5O_storage_virtual_srcdset_t { @@ -505,8 +504,8 @@ typedef struct H5O_storage_virtual_srcdset_t { struct H5S_t *virtual_select; /* Selection in the virtual dataset that is mapped to source selection */ /* Not stored */ - char * file_name; /* Source file name used for virtual dataset mapping */ - char * dset_name; /* Source dataset name used for virtual dataset mapping */ + char *file_name; /* Source file name used for virtual dataset mapping */ + char *dset_name; /* Source dataset name used for virtual dataset mapping */ struct H5S_t *clipped_source_select; /* Clipped version of source_select */ struct H5S_t *clipped_virtual_select; /* Clipped version of virtual_select */ struct H5D_t *dset; /* Source dataset */ @@ -517,7 +516,7 @@ typedef struct H5O_storage_virtual_srcdset_t { } H5O_storage_virtual_srcdset_t; typedef struct H5O_storage_virtual_name_seg_t { - char * name_segment; /* String for this name segment */ + char *name_segment; /* String for this name segment */ struct H5O_storage_virtual_name_seg_t *next; /* Next name segment */ } H5O_storage_virtual_name_seg_t; @@ -531,9 +530,9 @@ typedef enum H5O_virtual_space_status_t { typedef struct H5O_storage_virtual_ent_t { /* Stored */ H5O_storage_virtual_srcdset_t source_dset; /* Information about the source dataset */ - char * source_file_name; /* Original (unparsed) source file name */ - char * source_dset_name; /* Original (unparsed) source dataset name */ - struct H5S_t * source_select; /* Selection in the source dataset for mapping */ + char *source_file_name; /* Original (unparsed) source file name */ + char *source_dset_name; /* Original (unparsed) source dataset name */ + struct H5S_t *source_select; /* Selection in the source dataset for mapping */ /* Not stored */ H5O_storage_virtual_srcdset_t *sub_dset; /* Array of sub-source dataset info structs */ @@ -790,7 +789,7 @@ typedef struct H5O_drvinfo_t { H5AC_info_t cache_info; char name[9]; /* Driver name */ size_t len; /* Length of encoded buffer */ - uint8_t * buf; /* Buffer for encoded info */ + uint8_t *buf; /* Buffer for encoded info */ } H5O_drvinfo_t; /* @@ -892,8 +891,8 @@ typedef struct { /* Typedef for abstract object creation */ typedef struct { H5O_type_t obj_type; /* Type of object to create */ - void * crt_info; /* Information for object creation callback */ - void * new_obj; /* Pointer to new object created */ + void *crt_info; /* Information for object creation callback */ + void *new_obj; /* Pointer to new object created */ } H5O_obj_create_t; /* Forward declarations for prototype arguments */ @@ -907,7 +906,7 @@ H5_DLL H5O_t *H5O_create_ohdr(H5F_t *f, hid_t ocpl_id); H5_DLL herr_t H5O_apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t initial_rc, H5O_loc_t *loc_out); H5_DLL herr_t H5O_open(H5O_loc_t *loc); -H5_DLL void * H5O_open_by_loc(const H5G_loc_t *obj_loc, H5I_type_t *opened_type /*out*/); +H5_DLL void *H5O_open_by_loc(const H5G_loc_t *obj_loc, H5I_type_t *opened_type /*out*/); H5_DLL herr_t H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/); H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust); H5_DLL H5O_t *H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks); @@ -926,9 +925,9 @@ H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, H5O_info2_t *oinfo, unsigned H5_DLL herr_t H5O_get_native_info(const H5O_loc_t *oloc, H5O_native_info_t *oinfo, unsigned fields); H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type); H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, struct H5P_genplist_t *oc_plist); -H5_DLL void * H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type /*out*/); +H5_DLL void *H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type /*out*/); H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks); -H5_DLL void * H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc); +H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc); H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh); H5_DLL uint8_t H5O_get_oh_flags(const H5O_t *oh); H5_DLL time_t H5O_get_oh_mtime(const H5O_t *oh); @@ -946,12 +945,12 @@ H5_DLL herr_t H5O_msg_write(const H5O_loc_t *loc, unsigned type_id, unsigned mes H5_DLL herr_t H5O_msg_write_oh(H5F_t *f, H5O_t *oh, unsigned type_id, unsigned mesg_flags, unsigned update_flags, void *mesg); H5_DLL herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg); -H5_DLL void * H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg); -H5_DLL void * H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg); +H5_DLL void *H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg); +H5_DLL void *H5O_msg_read_oh(H5F_t *f, H5O_t *oh, unsigned type_id, void *mesg); H5_DLL herr_t H5O_msg_reset(unsigned type_id, void *native); -H5_DLL void * H5O_msg_free(unsigned type_id, void *mesg); -H5_DLL void * H5O_msg_free_real(const H5O_msg_class_t *type, void *mesg); -H5_DLL void * H5O_msg_copy(unsigned type_id, const void *mesg, void *dst); +H5_DLL void *H5O_msg_free(unsigned type_id, void *mesg); +H5_DLL void *H5O_msg_free_real(const H5O_msg_class_t *type, void *mesg); +H5_DLL void *H5O_msg_copy(unsigned type_id, const void *mesg, void *dst); H5_DLL int H5O_msg_count(const H5O_loc_t *loc, unsigned type_id); H5_DLL htri_t H5O_msg_exists(const H5O_loc_t *loc, unsigned type_id); H5_DLL htri_t H5O_msg_exists_oh(const H5O_t *oh, unsigned type_id); @@ -973,7 +972,7 @@ H5_DLL herr_t H5O_msg_reset_share(unsigned type_id, void *mesg); H5_DLL herr_t H5O_msg_get_crt_index(unsigned type_id, const void *mesg, H5O_msg_crt_idx_t *crt_idx); H5_DLL herr_t H5O_msg_encode(H5F_t *f, unsigned type_id, hbool_t disable_shared, unsigned char *buf, const void *obj); -H5_DLL void * H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, +H5_DLL void *H5O_msg_decode(H5F_t *f, H5O_t *open_oh, unsigned type_id, size_t buf_size, const unsigned char *buf); H5_DLL herr_t H5O_msg_delete(H5F_t *f, H5O_t *open_oh, unsigned type_id, void *mesg); H5_DLL herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t *flags); @@ -982,7 +981,7 @@ H5_DLL herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t H5_DLL herr_t H5O_flush(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc); -H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, +H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, hid_t apl_id, H5G_loc_t *obj_loc, H5VL_t *vol_driver, hbool_t start_swmr); /* Cache corking functions */ @@ -1003,12 +1002,12 @@ H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, const void *mesg, FILE *s H5_DLL herr_t H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth); /* These functions operate on object locations */ -H5_DLL herr_t H5O_loc_reset(H5O_loc_t *loc); -H5_DLL herr_t H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth); -H5_DLL herr_t H5O_loc_copy_shallow(H5O_loc_t *dst, H5O_loc_t *src); -H5_DLL herr_t H5O_loc_copy_deep(H5O_loc_t *dst, const H5O_loc_t *src); -H5_DLL herr_t H5O_loc_hold_file(H5O_loc_t *loc); -H5_DLL herr_t H5O_loc_free(H5O_loc_t *loc); +H5_DLL herr_t H5O_loc_reset(H5O_loc_t *loc); +H5_DLL herr_t H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth); +H5_DLL herr_t H5O_loc_copy_shallow(H5O_loc_t *dst, H5O_loc_t *src); +H5_DLL herr_t H5O_loc_copy_deep(H5O_loc_t *dst, const H5O_loc_t *src); +H5_DLL herr_t H5O_loc_hold_file(H5O_loc_t *loc); +H5_DLL herr_t H5O_loc_free(H5O_loc_t *loc); H5_DLL H5O_loc_t *H5O_get_loc(hid_t id); /* EFL operators */ diff --git a/src/H5Opublic.h b/src/H5Opublic.h index 3c444215456..e5a038bfe84 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -35,14 +34,14 @@ /*****************/ /* Flags for object copy (H5Ocopy) */ -#define H5O_COPY_SHALLOW_HIERARCHY_FLAG (0x0001u) /* Copy only immediate members */ -#define H5O_COPY_EXPAND_SOFT_LINK_FLAG (0x0002u) /* Expand soft links into new objects */ -#define H5O_COPY_EXPAND_EXT_LINK_FLAG (0x0004u) /* Expand external links into new objects */ -#define H5O_COPY_EXPAND_REFERENCE_FLAG (0x0008u) /* Copy objects that are pointed by references */ -#define H5O_COPY_WITHOUT_ATTR_FLAG (0x0010u) /* Copy object without copying attributes */ -#define H5O_COPY_PRESERVE_NULL_FLAG (0x0020u) /* Copy NULL messages (empty space) */ -#define H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG (0x0040u) /* Merge committed datatypes in dest file */ -#define H5O_COPY_ALL (0x007Fu) /* All object copying flags (for internal checking) */ +#define H5O_COPY_SHALLOW_HIERARCHY_FLAG (0x0001u) /**< Copy only immediate members */ +#define H5O_COPY_EXPAND_SOFT_LINK_FLAG (0x0002u) /**< Expand soft links into new objects */ +#define H5O_COPY_EXPAND_EXT_LINK_FLAG (0x0004u) /**< Expand external links into new objects */ +#define H5O_COPY_EXPAND_REFERENCE_FLAG (0x0008u) /**< Copy objects that are pointed by references */ +#define H5O_COPY_WITHOUT_ATTR_FLAG (0x0010u) /**< Copy object without copying attributes */ +#define H5O_COPY_PRESERVE_NULL_FLAG (0x0020u) /**< Copy NULL messages (empty space) */ +#define H5O_COPY_MERGE_COMMITTED_DTYPE_FLAG (0x0040u) /**< Merge committed datatypes in dest file */ +#define H5O_COPY_ALL (0x007Fu) /**< All object copying flags (for internal checking) */ /* Flags for shared message indexes. * Pass these flags in using the mesg_type_flags parameter in @@ -51,25 +50,27 @@ * but we need to assign each kind of message to a different bit so that * one index can hold multiple types.) */ -#define H5O_SHMESG_NONE_FLAG 0x0000 /* No shared messages */ -#define H5O_SHMESG_SDSPACE_FLAG ((unsigned)1 << 0x0001) /* Simple Dataspace Message. */ -#define H5O_SHMESG_DTYPE_FLAG ((unsigned)1 << 0x0003) /* Datatype Message. */ -#define H5O_SHMESG_FILL_FLAG ((unsigned)1 << 0x0005) /* Fill Value Message. */ -#define H5O_SHMESG_PLINE_FLAG ((unsigned)1 << 0x000b) /* Filter pipeline message. */ -#define H5O_SHMESG_ATTR_FLAG ((unsigned)1 << 0x000c) /* Attribute Message. */ +#define H5O_SHMESG_NONE_FLAG 0x0000 /**< No shared messages */ +#define H5O_SHMESG_SDSPACE_FLAG ((unsigned)1 << 0x0001) /**< Simple Dataspace Message. */ +#define H5O_SHMESG_DTYPE_FLAG ((unsigned)1 << 0x0003) /**< Datatype Message. */ +#define H5O_SHMESG_FILL_FLAG ((unsigned)1 << 0x0005) /**< Fill Value Message. */ +#define H5O_SHMESG_PLINE_FLAG ((unsigned)1 << 0x000b) /**< Filter pipeline message. */ +#define H5O_SHMESG_ATTR_FLAG ((unsigned)1 << 0x000c) /**< Attribute Message. */ #define H5O_SHMESG_ALL_FLAG \ (H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_FILL_FLAG | H5O_SHMESG_PLINE_FLAG | \ H5O_SHMESG_ATTR_FLAG) +/* clang-format off */ /* Object header status flag definitions */ -#define H5O_HDR_CHUNK0_SIZE 0x03 /* 2-bit field indicating # of bytes to store the size of chunk 0's data */ -#define H5O_HDR_ATTR_CRT_ORDER_TRACKED 0x04 /* Attribute creation order is tracked */ -#define H5O_HDR_ATTR_CRT_ORDER_INDEXED 0x08 /* Attribute creation order has index */ -#define H5O_HDR_ATTR_STORE_PHASE_CHANGE 0x10 /* Non-default attribute storage phase change values stored */ -#define H5O_HDR_STORE_TIMES 0x20 /* Store access, modification, change & birth times for object */ +#define H5O_HDR_CHUNK0_SIZE 0x03 /**< 2-bit field indicating # of bytes to store the size of chunk 0's data */ +#define H5O_HDR_ATTR_CRT_ORDER_TRACKED 0x04 /**< Attribute creation order is tracked */ +#define H5O_HDR_ATTR_CRT_ORDER_INDEXED 0x08 /**< Attribute creation order has index */ +#define H5O_HDR_ATTR_STORE_PHASE_CHANGE 0x10 /**< Non-default attribute storage phase change values stored */ +#define H5O_HDR_STORE_TIMES 0x20 /**< Store access, modification, change & birth times for object */ #define H5O_HDR_ALL_FLAGS \ (H5O_HDR_CHUNK0_SIZE | H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | \ H5O_HDR_ATTR_STORE_PHASE_CHANGE | H5O_HDR_STORE_TIMES) +/* clang-format on */ /* Maximum shared message values. Number of indexes is 8 to allow room to add * new types of messages. @@ -78,21 +79,21 @@ #define H5O_SHMESG_MAX_LIST_SIZE 5000 /* Flags for H5Oget_info. - * Theses flags determine which fields will be filled in in the H5O_info_t + * These flags determine which fields will be filled in the H5O_info_t * struct. */ -#define H5O_INFO_BASIC 0x0001u /* Fill in the fileno, addr, type, and rc fields */ -#define H5O_INFO_TIME 0x0002u /* Fill in the atime, mtime, ctime, and btime fields */ -#define H5O_INFO_NUM_ATTRS 0x0004u /* Fill in the num_attrs field */ +#define H5O_INFO_BASIC 0x0001u /**< Fill in the fileno, addr, type, and rc fields */ +#define H5O_INFO_TIME 0x0002u /**< Fill in the atime, mtime, ctime, and btime fields */ +#define H5O_INFO_NUM_ATTRS 0x0004u /**< Fill in the num_attrs field */ #define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS) //! /** - * Flags for H5Oget_native_info(). Theses flags determine which fields will be - * filled in in the \ref H5O_native_info_t struct. + * Flags for H5Oget_native_info(). These flags determine which fields will be + * filled in the \ref H5O_native_info_t struct. */ -#define H5O_NATIVE_INFO_HDR 0x0008u /* Fill in the hdr field */ -#define H5O_NATIVE_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ +#define H5O_NATIVE_INFO_HDR 0x0008u /**< Fill in the hdr field */ +#define H5O_NATIVE_INFO_META_SIZE 0x0010u /**< Fill in the meta_size field */ #define H5O_NATIVE_INFO_ALL (H5O_NATIVE_INFO_HDR | H5O_NATIVE_INFO_META_SIZE) //! @@ -146,15 +147,15 @@ typedef struct H5O_hdr_info_t { * (For H5Oget_info(), H5Oget_info_by_name(), H5Oget_info_by_idx() version 3) */ typedef struct H5O_info2_t { - unsigned long fileno; /* File number that object is located in */ - H5O_token_t token; /* Token representing the object */ - H5O_type_t type; /* Basic object type (group, dataset, etc.) */ - unsigned rc; /* Reference count of object */ - time_t atime; /* Access time */ - time_t mtime; /* Modification time */ - time_t ctime; /* Change time */ - time_t btime; /* Birth time */ - hsize_t num_attrs; /* # of attributes attached to object */ + unsigned long fileno; /**< File number that object is located in */ + H5O_token_t token; /**< Token representing the object */ + H5O_type_t type; /**< Basic object type (group, dataset, etc.) */ + unsigned rc; /**< Reference count of object */ + time_t atime; /**< Access time */ + time_t mtime; /**< Modification time */ + time_t ctime; /**< Change time */ + time_t btime; /**< Birth time */ + hsize_t num_attrs; /**< Number of attributes attached to object */ } H5O_info2_t; //! @@ -165,11 +166,10 @@ typedef struct H5O_info2_t { */ typedef struct H5O_native_info_t { H5O_hdr_info_t hdr; /**< Object header information */ - /* Extra metadata storage for obj & attributes */ struct { H5_ih_info_t obj; /**< v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ H5_ih_info_t attr; /**< v2 B-tree & heap for attributes */ - } meta_size; + } meta_size; /**< Extra metadata storage for obj & attributes */ } H5O_native_info_t; //! @@ -181,6 +181,17 @@ typedef uint32_t H5O_msg_crt_idx_t; //! /** * Prototype for H5Ovisit(), H5Ovisit_by_name() operator (version 3) + * + * \param[in] obj Object that serves as the root of the iteration; + * the same value as the H5Ovisit3() \c obj_id parameter + * \param[in] name Name of object, relative to \p obj, being examined at current + * step of the iteration + * \param[out] info Information about that object + * \param[in,out] op_data User-defined pointer to data required by the application + * in processing the object; a pass-through of the \c op_data + * pointer provided with the H5Ovisit3() function call + * \return \herr_t_iter + * */ typedef herr_t (*H5O_iterate2_t)(hid_t obj, const char *name, const H5O_info2_t *info, void *op_data); //! @@ -272,10 +283,6 @@ H5_DLL hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id); * \details H5Oopen_by_token() opens an object specified by the object * identifier, \p loc_id and object token, \p token. * - * \par Example - * An example snippet from examples/h5_extlink.c: - * \snippet h5_extlink.c H5Open_by_token_snip - * * \since 1.12.0 * */ @@ -296,7 +303,7 @@ H5_DLL hid_t H5Oopen_by_token(hid_t loc_id, H5O_token_t token); * * \return \hid_tv{object} * - * \details H5Open_by_idx() opens the nth object in the group specified by \p loc_id + * \details H5Oopen_by_idx() opens the nth object in the group specified by \p loc_id * and \p group_name. * * \p loc_id specifies a location identifier. @@ -445,28 +452,7 @@ H5_DLL htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id); * \return \herr_t * * \details H5Oget_info3() specifies an object by its identifier, \p loc_id , and - * retrieves the metadata describing that object in \p oinfo , an H5O_info2_t \c struct. - * - * The H5O_info2_t \c struct is defined in H5Opublic.h as follows : - * \snippet this H5O_info2_t_snip - * - * Note the following about H5O_info2_t : - * - Of the four time fields (\c atime, \c mtime, \c ctime, and \c btime) - * only \c ctime has been implemented. - * - The \c atime value is the last time the object was read or written. - * - The \c mtime value is the last time the raw data in the object was changed. - * - The \c ctime value is the last time the metadata for the object was changed. - * - The \c btime value is the time the object was created. - * - * The H5O_token_t is defined in H5public.h as follows: - * \snippet H5public.h H5O_token_t_snip - * - * The H5O_type_t \c enum indicates the object type and - * is defined in H5Opublic.h as follows: - * \snippet this H5O_type_t_snip - * - * Note that the object retrieved as indicated by \p loc_id - * refers only to the types specified by H5O_type_t. + * retrieves the metadata describing that object in \p oinfo. * * The \p fields parameter contains flags to determine which fields will be filled in * the H5O_info2_t \c struct returned in \p oinfo. @@ -504,7 +490,7 @@ H5_DLL herr_t H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields); * location and relative name * * \fgdta_loc_obj_id{loc_id} - * \param[in] name Name of group, relative to \p loc_id + * \param[in] name Name of object, relative to \p loc_id * \param[out] oinfo Buffer in which to return object information * \param[in] fields Flags specifying the fields to include in \p oinfo * \lapl_id @@ -515,29 +501,6 @@ H5_DLL herr_t H5Oget_info3(hid_t loc_id, H5O_info2_t *oinfo, unsigned fields); * \p loc_id and \p name, respectively, and retrieves the metadata * describing that object in \p oinfo, an H5O_info2_t struct. * - * \p oinfo, in which the object information is returned, is a \c struct of - * type H5O_info2_t, which is defined in H5Opublic.h in the HDF5 source code: - * - * \snippet this H5O_info2_t_snip - * - * Note the following about H5O_info2_t : - * - Of the four time fields (\c atime, \c mtime, \c ctime, and \c btime) - * only \c ctime has been implemented. - * - The \c atime value is the last time the object was read or written. - * - The \c mtime value is the last time the raw data in the object was changed. - * - The \c ctime value is the last time the metadata for the object was changed. - * - The \c btime value is the time the object was created. - * - * The H5O_token_t is defined in H5public.h as follows: - * \snippet H5public.h H5O_token_t_snip - * - * The H5O_type_t \c enum indicates the object type and - * is defined in H5Opublic.h as follows: - * \snippet this H5O_type_t_snip - * - * Note that the object retrieved as indicated by \p loc_id - * refers only to the types specified by H5O_type_t. - * * The \p fields parameter contains flags to determine which fields will be filled in * the H5O_info2_t \c struct returned in \p oinfo. * These flags are defined in the H5Opublic.h file: @@ -585,34 +548,6 @@ H5_DLL herr_t H5Oget_info_by_name3(hid_t loc_id, const char *name, H5O_info2_t * * If \p loc_id fully specifies the group in which the object resides, * \p group_name can be a dot (\c .). * - * \p idx_type is of type #H5_index_t, defined in H5public.h as: - * \snippet H5public.h H5_index_t_snip - * - * \p order is of type #H5_iter_order_t defined in H5public.h as: - * \snippet H5public.h H5_iter_order_t_snip - * - * \p oinfo, in which the object information is returned, is a \c struct of - * type H5O_info2_t, which is defined in H5Opublic.h in the HDF5 source code: - * \snippet this H5O_info2_t_snip - * - * Note the following about H5O_info2_t : - * - Of the four time fields (\c atime, \c mtime, \c ctime, and \c btime) - * only \c ctime has been implemented. - * - The \c atime value is the last time the object was read or written. - * - The \c mtime value is the last time the raw data in the object was changed. - * - The \c ctime value is the last time the metadata for the object was changed. - * - The \c btime value is the time the object was created. - * - * H5O_token_t is defined in H5public.h as follows: - * \snippet H5public.h H5O_token_t_snip - * - * The #H5O_type_t \c enum indicates the object type and - * is defined in H5Opublic.h as follows: - * \snippet this H5O_type_t_snip - * - * Note that the object retrieved as indicated by \p loc_id - * refers only to the types specified by #H5O_type_t. - * * The \p fields parameter contains flags to determine which fields will be filled in * the H5O_info2_t \c struct returned in \p oinfo. * These flags are defined in the H5Opublic.h file: @@ -645,11 +580,7 @@ H5_DLL herr_t H5Oget_info_by_idx3(hid_t loc_id, const char *group_name, H5_index * \return \herr_t * * \details H5Oget_native_info() retrieves the native file format information for an object - * specified by \p loc_id. The information is retrieved into the - * buffer specified by \p oinfo, which is defined as a \c struct of - * type H5O_native_info_t in H5Opublic.h: - * - * \snippet this H5O_native_info_t_snip + * specified by \p loc_id. * * The \p fields parameter indicates which fields to fill in * H5O_native_info_t. Possible values defined in H5Opublic.h are: @@ -680,12 +611,9 @@ H5_DLL herr_t H5Oget_native_info(hid_t loc_id, H5O_native_info_t *oinfo, unsigne * * \return \herr_t * - * \details H5Oget_native_info_by_name() retrieves the native file format information for an object - * specified by \p loc_id and the name \p name. The information is - * retrieved into the buffer specified by \p oinfo, which is defined - * as a \c struct of type H5O_native_info_t in H5Opublic.h: - * - * \snippet this H5O_native_info_t_snip + * \details H5Oget_native_info_by_name() retrieves the native file format + * information for an object specified by \p loc_id and the name \p + * name. * * The \p fields parameter which fields to fill in H5O_native_info_t. * Possible values defined in H5Opublic.h are: @@ -724,16 +652,7 @@ H5_DLL herr_t H5Oget_native_info_by_name(hid_t loc_id, const char *name, H5O_nat * specified by \p loc_id, group name, \p group_name, the index by which * objects in the group are tracked, \p idx_type, the order by which * the index is to be traversed, \p order , and an object's position - * \p n within that index. The information is retrieved into the - * buffer specified by \p oinfo, which is defined as a \c struct of - * type H5O_native_info_t in H5Opublic.h: - * \snippet this H5O_native_info_t_snip - * - * \p idx_type is of type #H5_index_t, defined in H5public.h as: - * \snippet H5public.h H5_index_t_snip - * - * \p order is of type #H5_iter_order_t defined in H5public.h as: - * \snippet H5public.h H5_iter_order_t_snip + * \p n within that index. * * The \p fields parameter indicates which fields to fill in H5O_native_info_t. * Possible values defined in H5Opublic.h are: @@ -835,7 +754,7 @@ H5_DLL herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_ * * An object’s reference count is the number of hard links in the * file that point to that object. See the “Programming Model†- * section of the HDF5 Groups chapter in the -- HDF5 User’s Guide + * section of the HDF5 Groups chapter in the -- \ref UG * for a more complete discussion of reference counts. * * If a user application needs to determine an object’s reference @@ -870,7 +789,7 @@ H5_DLL herr_t H5Oincr_refcount(hid_t object_id); * * An object’s reference count is the number of hard links in the * file that point to that object. See the “Programming Model†- * section of the HDF5 Groups chapter in the HDF5 User’s Guide + * section of the HDF5 Groups chapter in the \ref UG * for a more complete discussion of reference counts. * * If a user application needs to determine an object’s reference @@ -1205,76 +1124,18 @@ H5_DLL ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comm * a group have not been indexed by the index type, they will * first be sorted by that index then the iteration will begin; * if the links have been so indexed, the sorting step will be - * unnecessary, so the iteration may begin more quickly. Valid - * values include the following: - * - * \indexes - * + * unnecessary, so the iteration may begin more quickly. + * Note that the index type passed in \p idx_type is a * best effort setting. If the application passes in * a value indicating iteration in creation order and a group is * encountered that was not tracked in creation order, that group - * will be iterated over in alpha-numeric order by name, or + * will be iterated over in alphanumeric order by name, or * name order. (Name order is the native order * used by the HDF5 library and is always available.) * * \p order specifies the order in which objects are to be inspected - * along the index specified in \p idx_type. Valid values include - * the following: - * - * \orders - * - * The prototype of the callback function op is as follows (as - * defined in the source code file H5Opublic.h): - * - * \snippet this H5O_iterate2_t_snip - * - * The parameters of this callback function have the following values - * or meanings: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    \c objObject that serves as root of the iteration; - * same value as the H5Ovisit() \p obj_id parameter
    \c nameName of object, relative to \c obj, being examined at - * current step of the iteration
    \c infoH5O_info2_t \c struct containing information - * regarding that object
    \c op_dataUser-defined pointer to data required by the application in - * processing the object; a pass-through of the \c op_data pointer - * provided with the H5Ovisit() function call
    - * - * The H5O_info2_t \c struct is defined in H5Opublic.h as follows: - * \snippet this H5O_info2_t_snip - * - * H5O_token_t is defined in H5public.h as follows: - * \snippet H5public.h H5O_token_t_snip - * - * The #H5O_type_t enum indicates the object type and is - * defined in H5Opublic.h as follows: - * \snippet this H5O_type_t_snip - * - * Note that the object retrieved as indicated by \p obj_id - * refers only to the types specified by #H5O_type_t. - * - * The return values from an operator are: - * - Zero causes the visit iterator to continue, returning zero when all - * group members have been processed. - * - A positive value causes the visit iterator to immediately return that - * positive value, indicating short-circuit success. - * - A negative value causes the visit iterator to immediately return that - * value, indicating failure. + * along the index specified in \p idx_type. * * The H5Ovisit3() \p op_data parameter is a user-defined pointer to the data * required to process objects in the course of the iteration. This pointer @@ -1298,24 +1159,6 @@ H5_DLL ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comm * group change during the iteration, the resulting behavior * is undefined. * - * \note \Bold{Programming Note for C++ Developers Using C Functions:} - * \note If a C routine that takes a function pointer as an argument is - * called from within C++ code, the C routine should be returned - * from normally. - * - * \note Examples of this kind of routine include callbacks such as - * H5Pset_elink_cb() and H5Pset_type_conv_cb() and - * functions such as H5Tconvert() and H5Ewalk2(). - * - * \note Exiting the routine in its normal fashion allows the HDF5 - * C library to clean up its work properly. In other words, if - * the C++ application jumps out of the routine back to the C++ - * “catch†statement, the library is not given the opportunity - * to close any temporary data structures that were set up when - * the routine was called. The C++ application should save some - * state as the routine is started so that any problem that occurs - * might be diagnosed. - * * \par Example * An example snippet from test/links.c: * \snippet links.c H5Ovisit3_snip @@ -1380,63 +1223,18 @@ H5_DLL herr_t H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order * a group have not been indexed by the index type, they will * first be sorted by that index then the iteration will begin; * if the links have been so indexed, the sorting step will be - * unnecessary, so the iteration may begin more quickly. Valid - * values include the following: - * - * \indexes + * unnecessary, so the iteration may begin more quickly. * * Note that the index type passed in \p idx_type is a * best effort setting. If the application passes in a * value indicating iteration in creation order and a group is * encountered that was not tracked in creation order, that group - * will be iterated over in alpha-numeric order by name, or + * will be iterated over in alphanumeric order by name, or * name order. (Name order is the native order * used by the HDF5 library and is always available.) * * \p order specifies the order in which objects are to be inspected - * along the index specified in \p idx_type. Valid values include - * the following: - * - * \orders - * - * The prototype of the callback function op is as follows (as - * defined in the source code file H5Opublic.h): - * - * \snippet this H5O_iterate2_t_snip - * - * The parameters of this callback function have the following - * values or meanings: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    \c objObject that serves as root of the iteration
    \c nameName of object, relative to \c obj, being examined at - * current step of the iteration
    \c infoH5O_info2_t \c struct containing information - * regarding that object
    \c op_dataUser-defined pointer to data required by the application in - * processing the object
    - * - * The H5O_info2_t \c struct is defined in H5Opublic.h as follows: - * \snippet this H5O_info2_t_snip - * - * H5O_token_t is defined in H5public.h as follows: - * \snippet H5public.h H5O_token_t_snip - * - * The #H5O_type_t enum indicates the object type and is - * defined in H5Opublic.h as follows: - * \snippet this H5O_type_t_snip + * along the index specified in \p idx_type. * * The H5Ovisit_by_name3() \p op_data parameter is a user-defined * pointer to the data required to process objects in the course @@ -1464,24 +1262,6 @@ H5_DLL herr_t H5Ovisit3(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order * in the file has been presented to the application for whatever * processing the application requires. * - * \note \Bold{Programming Note for C++ Developers Using C Functions:} - * \note If a C routine that takes a function pointer as an argument is - * called from within C++ code, the C routine should be returned - * from normally. - * - * \note Examples of this kind of routine include callbacks such as - * H5Pset_elink_cb() and H5Pset_type_conv_cb() and - * functions such as H5Tconvert() and H5Ewalk2(). - * - * \note Exiting the routine in its normal fashion allows the HDF5 - * C library to clean up its work properly. In other words, if - * the C++ application jumps out of the routine back to the C++ - * “catch†statement, the library is not given the opportunity - * to close any temporary data structures that were set up when - * the routine was called. The C++ application should save some - * state as the routine is started so that any problem that occurs - * might be diagnosed. - * * \par Example * An example snippet from test/links.c: * \snippet links.c H5Ovisit_by_name3_snip @@ -1541,32 +1321,16 @@ H5_DLL herr_t H5Oclose(hid_t object_id); * files. After that, the OS is responsible for ensuring that * the data is actually flushed to disk. * - * \par See Also: - * - H5Dflush() - * - H5Drefresh() - * - H5Oflush() - * - H5Grefresh() - * - H5Oflush() - * - H5Orefresh() - * - H5Tflush() - * - H5Trefresh() - * \par - * - \c H5DOappend() - * - H5Fstart_swmr_write() - * - H5Pget_append_flush() - * - H5Pget_object_flush_cb() - * - H5Pset_append_flush() - * - H5Pset_object_flush_cb() - * \par - * - H5Oare_mdc_flushes_disabled() - * - H5Odisable_mdc_flushes() - * - H5Oenable_mdc_flushes() + * \see H5Dflush(), H5Drefresh(), H5Oflush(), H5Grefresh(), H5Oflush(), + * H5Orefresh(), H5Tflush(), H5Trefresh() + * \see H5DOappend(), H5Fstart_swmr_write(), H5Pget_append_flush(), + * H5Pget_object_flush_cb(), H5Pset_append_flush(), H5Pset_object_flush_cb() + * \see H5Oare_mdc_flushes_disabled(), H5Odisable_mdc_flushes(), H5Oenable_mdc_flushes() * * \since 1.10.0 * */ H5_DLL herr_t H5Oflush(hid_t obj_id); - /** *------------------------------------------------------------------------- * \ingroup H5O @@ -1619,21 +1383,17 @@ H5_DLL herr_t H5Orefresh(hid_t oid); * HDF5 object level (datasets, groups, committed datatypes) * and the entire metadata cache level. * - * \note HDF5 objects include datasets, groups, and committed datatypes. - * Only #hid_t identifiers that represent these objects can be passed to the function. - * \note Passing in a #hid_t identifier that represents any other HDF5 entity is - * considered an error. - * \note It is an error to pass an HDF5 file identifier - * (obtained from H5Fopen() or H5Fcreate()) - * to this function. - * \note Misuse of this function can cause the cache to exhaust - * available memory. - * \note Objects can be returned to the default automatic flush behavior - * with H5Oenable_mdc_flushes(). - * \note Flush prevention only pertains to new or dirty metadata entries. - * Clean entries can be evicted from the cache. - * \note Calling this function on an object that has already had flushes - * disabled will return an error. + * \note HDF5 objects include datasets, groups, and committed datatypes. Only + * #hid_t identifiers that represent these objects can be passed to the + * function. Passing in a #hid_t identifier that represents any other + * HDF5 entity is considered an error. It is an error to pass an HDF5 + * file identifier (obtained from H5Fopen() or H5Fcreate()) to this + * function. Misuse of this function can cause the cache to exhaust + * available memory. Objects can be returned to the default automatic + * flush behavior with H5Oenable_mdc_flushes(). Flush prevention only + * pertains to new or dirty metadata entries. Clean entries can be + * evicted from the cache. Calling this function on an object that has + * already had flushes disabled will return an error. * * \since 1.10.0 * @@ -1663,28 +1423,18 @@ H5_DLL herr_t H5Odisable_mdc_flushes(hid_t object_id); * metadata cache level. * * - * \note HDF5 objects include datasets, groups, and committed datatypes. - * Only #hid_t identifiers that represent these objects can be - * passed to the function. - * - * \note Passing in a #hid_t identifier that represents any other HDF5 entity - * is considered an error. - * - * \note It is an error to pass an HDF5 file identifier - * (obtained from H5Fopen() or H5Fcreate()) - * to this function. - * - * \note Using this function on an object that has not had flushes disabled - * is considered an error. The state of an object can be determined - * with H5Oare_mdc_flushes_disabled(). - * - * \note An object will be returned to the default flush algorithm when it is closed. - * - * \note All objects will be returned to the default flush algorithm when - * the file is closed. - * - * \note An object’s entries will not necessarily be flushed as a result of - * calling this function. + * \note HDF5 objects include datasets, groups, and committed datatypes. Only + * #hid_t identifiers that represent these objects can be passed to the + * function. Passing in a #hid_t identifier that represents any other + * HDF5 entity is considered an error. It is an error to pass an HDF5 + * file identifier (obtained from H5Fopen() or H5Fcreate()) to this + * function. Using this function on an object that has not had flushes + * disabled is considered an error. The state of an object can be + * determined with H5Oare_mdc_flushes_disabled(). An object will be + * returned to the default flush algorithm when it is closed. All objects + * will be returned to the default flush algorithm when the file is + * closed. An object’s entries will not necessarily be flushed as a + * result of calling this function. * * \since 1.10.0 * @@ -1833,8 +1583,8 @@ H5_DLLVAR const H5O_token_t H5O_TOKEN_UNDEF_g; /* Macros */ /* Deprecated flags for earlier versions of H5Oget_info* */ -#define H5O_INFO_HDR 0x0008u /* Fill in the hdr field */ -#define H5O_INFO_META_SIZE 0x0010u /* Fill in the meta_size field */ +#define H5O_INFO_HDR 0x0008u /**< Fill in the hdr field */ +#define H5O_INFO_META_SIZE 0x0010u /**< Fill in the meta_size field */ #undef H5O_INFO_ALL #define H5O_INFO_ALL (H5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE) @@ -1867,7 +1617,7 @@ typedef struct H5O_info1_t { time_t mtime; /**< Modification time */ time_t ctime; /**< Change time */ time_t btime; /**< Birth time */ - hsize_t num_attrs; /**< # of attributes attached to object */ + hsize_t num_attrs; /**< Number of attributes attached to object */ H5O_hdr_info_t hdr; /**< Object header information */ /* Extra metadata storage for obj & attributes */ struct { @@ -1880,6 +1630,16 @@ typedef struct H5O_info1_t { //! /** * Prototype for H5Ovisit(), H5Ovisit_by_name() operator (versions 1 & 2) + * + * \param[in] obj Object that serves as the root of the iteration; + * the same value as the H5Ovisit1() \c obj_id parameter + * \param[in] name Name of object, relative to \p obj, being examined at current + * step of the iteration + * \param[out] info Information about that object + * \param[in,out] op_data User-defined pointer to data required by the application + * in processing the object + * \return \herr_t_iter + * */ typedef herr_t (*H5O_iterate1_t)(hid_t obj, const char *name, const H5O_info1_t *info, void *op_data); //! @@ -1952,36 +1712,7 @@ H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); * the function H5Oget_info3() or the macro #H5Oget_info. * * \details H5Oget_info1() specifies an object by its identifier, \p loc_id , and - * retrieves the metadata describing that object in \p oinfo , - * defined as a \c struct of type H5O_info1_t : - * - * \snippet this H5O_info1_t_snip - * - * Note the following about H5O_info1_t : - * - Of the four time fields (\c atime, \c mtime, \c ctime, and \c btime) - * only \c ctime has been implemented. - * - The \c atime value is the last time the object was read or written. - * - The \c mtime value is the last time the raw data in the object was changed. - * - The \c ctime value is the last time the metadata for the object was changed. - * - The \c btime value is the time the object was created. - * - The fields nested in the \c meta_size field are for internal library use only. - * - * The #H5O_type_t \c enum indicates the object type and - * is defined in H5Opublic.h as follows: - * \snippet this H5O_type_t_snip - * - * Note that the object retrieved as indicated by \p loc_id - * refers only to the types specified by #H5O_type_t. - * - * An H5O_hdr_info_t \c struct holds object header metadata and is - * defined in H5Opublic.h as follows: - * \snippet this H5O_hdr_info_t_snip - * - * Valid values for the \c version field are \c H5O_VERSION_1 and \c H5O_VERSION_2. - * Version 2 of the object header is smaller and more efficient than version 1. - * - * Please be aware that the information held by H5O_hdr_info_t may only be useful to - * developers with extensive HDF5 experience. + * retrieves the metadata describing that object in \p oinfo. * * \note If you are iterating through a lot of different objects to * retrieve information via the H5Oget_info() family of routines, @@ -2020,7 +1751,7 @@ H5_DLL herr_t H5Oget_info1(hid_t loc_id, H5O_info1_t *oinfo); * by location and relative name * * \fgdta_loc_obj_id{loc_id} - * \param[in] name Name of group, relative to \p loc_id + * \param[in] name Name of object, relative to \p loc_id * \param[out] oinfo Buffer in which to return object information * \lapl_id * @@ -2081,16 +1812,6 @@ H5_DLL herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info1_t * * If \p loc_id fully specifies the group in which the object resides, * \p group_name can be a dot (\c .). * - * \p idx_type is of type #H5_index_t, defined in H5public.h as: - * \snippet H5public.h H5_index_t_snip - * - * \p order is of type #H5_iter_order_t defined in H5public.h as: - * \snippet H5public.h H5_iter_order_t_snip - * - * \p oinfo, in which the object information is returned, is a \c struct of - * type H5O_info1_t . - * \snippet this H5O_info1_t_snip - * * The link access property list, \c lapl_id, is not currently used; * it should be passed in as #H5P_DEFAULT. * @@ -2156,7 +1877,7 @@ H5_DLL herr_t H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields); * by location and relative name * * \fgdta_loc_obj_id{loc_id} - * \param[in] name Name of group, relative to \p loc_id + * \param[in] name Name of object, relative to \p loc_id * \param[out] oinfo Buffer in which to return object information * \param[in] fields Flags specifying the fields to include in \p oinfo * \lapl_id @@ -2174,7 +1895,7 @@ H5_DLL herr_t H5Oget_info2(hid_t loc_id, H5O_info1_t *oinfo, unsigned fields); * in the H5Oget_info1() function entry. * * The \p fields parameter contains flags to determine which fields - * will be filled in in the H5O_info1_t \c struct returned in + * will be filled in the H5O_info1_t \c struct returned in * \p oinfo. These flags are defined in the H5Opublic.h file: * * \obj_info_fields @@ -2286,70 +2007,18 @@ H5_DLL herr_t H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index * a group have not been indexed by the index type, they will * first be sorted by that index then the iteration will begin; * if the links have been so indexed, the sorting step will be - * unnecessary, so the iteration may begin more quickly. Valid - * values include the following: - * - * \indexes + * unnecessary, so the iteration may begin more quickly. * * Note that the index type passed in \p idx_type is a * best effort setting. If the application passes in * a value indicating iteration in creation order and a group is * encountered that was not tracked in creation order, that group - * will be iterated over in alpha-numeric order by name, or + * will be iterated over in alphanumeric order by name, or * name order. (Name order is the native order * used by the HDF5 library and is always available.) * * \p order specifies the order in which objects are to be inspected - * along the index specified in \p idx_type. Valid values include - * the following: - * - * \orders - * - * The prototype of the callback function op is as follows (as - * defined in the source code file H5Opublic.h): - * - * \snippet this H5O_iterate1_t_snip - * - * The parameters of this callback function have the following values - * or meanings: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    \c objObject that serves as root of the iteration; - * same value as the H5Ovisit1() \p obj_id parameter
    \c nameName of object, relative to \c obj, being examined at - * current step of the iteration
    \c infoH5O_info1_t \c struct containing information - * regarding that object
    \c op_dataUser-defined pointer to data required by the application in - * processing the object
    - * - * The H5O_info1_t \c struct is defined in H5Opublic.h: - * \snippet this H5O_info1_t_snip - * - * The return values from an operator are: - * - Zero causes the visit iterator to continue, returning zero when all - * group members have been processed. - * - A positive value causes the visit iterator to immediately return that - * positive value, indicating short-circuit success. - * - A negative value causes the visit iterator to immediately return that - * value, indicating failure. - * - * The H5Ovisit1() \p op_data parameter is a user-defined pointer to the data - * required to process objects in the course of the iteration. This pointer - * is passed back to each step of the iteration in the callback - * function’s \p op_data parameter. + * along the index specified in \p idx_type. * * H5Lvisit1() and H5Ovisit1() are companion functions: one for * examining and operating on links; the other for examining @@ -2363,24 +2032,6 @@ H5_DLL herr_t H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index * group change during the iteration, the resulting behavior * is undefined. * - * \note \Bold{Programming Note for C++ Developers Using C Functions:} - * \note If a C routine that takes a function pointer as an argument is - * called from within C++ code, the C routine should be returned - * from normally. - * - * \note Examples of this kind of routine include callbacks such as - * H5Pset_elink_cb() and H5Pset_type_conv_cb() and - * functions such as H5Tconvert() and H5Ewalk2(). - * - * \note Exiting the routine in its normal fashion allows the HDF5 - * C library to clean up its work properly. In other words, if - * the C++ application jumps out of the routine back to the C++ - * “catch†statement, the library is not given the opportunity - * to close any temporary data structures that were set up when - * the routine was called. The C++ application should save some - * state as the routine is started so that any problem that occurs - * might be diagnosed. - * * \version 1.10.5 The macro #H5Ovisit was removed and the function * H5Ovisit1() was copied to H5Ovisit(). * \version 1.10.3 Function H5Ovisit() was copied to H5Ovisit1(), @@ -2448,24 +2099,18 @@ H5_DLL herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order * a group have not been indexed by the index type, they will * first be sorted by that index then the iteration will begin; * if the links have been so indexed, the sorting step will be - * unnecessary, so the iteration may begin more quickly. Valid - * values include the following: - * - * \indexes + * unnecessary, so the iteration may begin more quickly. * * Note that the index type passed in \p idx_type is a * best effort setting. If the application passes in a * value indicating iteration in creation order and a group is * encountered that was not tracked in creation order, that group - * will be iterated over in alpha-numeric order by name, or + * will be iterated over in alphanumeric order by name, or * name order. (Name order is the native order * used by the HDF5 library and is always available.) * * \p order specifies the order in which objects are to be inspected - * along the index specified in \p idx_type. Valid values include - * the following: - * - * \orders + * along the index specified in \p idx_type. * * The \p op callback function and the effect of the callback * function’s return value on the application are described @@ -2495,24 +2140,6 @@ H5_DLL herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order * in the file has been presented to the application for whatever * processing the application requires. * - * \note \Bold{Programming Note for C++ Developers Using C Functions:} - * \note If a C routine that takes a function pointer as an argument is - * called from within C++ code, the C routine should be returned - * from normally. - * - * \note Examples of this kind of routine include callbacks such as - * H5Pset_elink_cb() and H5Pset_type_conv_cb() and - * functions such as H5Tconvert() and H5Ewalk2(). - * - * \note Exiting the routine in its normal fashion allows the HDF5 - * C library to clean up its work properly. In other words, if - * the C++ application jumps out of the routine back to the C++ - * “catch†statement, the library is not given the opportunity - * to close any temporary data structures that were set up when - * the routine was called. The C++ application should save some - * state as the routine is started so that any problem that occurs - * might be diagnosed. - * * \version 1.10.5 The macro #H5Ovisit_by_name was removed and the function * H5Ovisit_by_name1() was copied to #H5Ovisit_by_name. * \version 1.10.3 The H5Ovisit_by_name() function was renamed to H5Ovisit_by_name1(), @@ -2575,71 +2202,18 @@ H5_DLL herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t i * a group have not been indexed by the index type, they will * first be sorted by that index then the iteration will begin; * if the links have been so indexed, the sorting step will be - * unnecessary, so the iteration may begin more quickly. Valid - * values include the following: - * - * \indexes + * unnecessary, so the iteration may begin more quickly. * * Note that the index type passed in \p idx_type is a * best effort setting. If the application passes in * a value indicating iteration in creation order and a group is * encountered that was not tracked in creation order, that group - * will be iterated over in alpha-numeric order by name, or + * will be iterated over in alphanumeric order by name, or * name order. (Name order is the native order * used by the HDF5 library and is always available.) * * \p order specifies the order in which objects are to be inspected - * along the index specified in \p idx_type. Valid values include - * the following: - * - * \orders - * - * The prototype of the callback function op is as follows (as - * defined in the source code file H5Opublic.h): - * - * \snippet this H5O_iterate1_t_snip - * - * The parameters of this callback function have the following values - * or meanings: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    \c objObject that serves as root of the iteration; - * same value as the H5Ovisit1() \p obj_id parameter
    \c nameName of object, relative to \c obj, being examined at - * current step of the iteration
    \c infoH5O_info1_t \c struct containing information - * regarding that object
    \c op_dataUser-defined pointer to data required by the application in - * processing the object; a pass-through of the \c op_data pointer - * provided with the H5Ovisit() function call
    - * - * The H5O_info1_t \c struct is defined in H5Opublic.h and - * described in the H5Oget_info1() function entry. - * - * The return values from an operator are: - * - Zero causes the visit iterator to continue, returning zero when all - * group members have been processed. - * - A positive value causes the visit iterator to immediately return that - * positive value, indicating short-circuit success. - * - A negative value causes the visit iterator to immediately return that - * value, indicating failure. - * - * The H5Ovisit2() \p op_data parameter is a user-defined pointer to the data - * required to process objects in the course of the iteration. This pointer - * is passed back to each step of the iteration in the callback - * function’s \p op_data parameter. + * along the index specified in \p idx_type. * * The \p fields parameter contains flags to determine which fields will * be retrieved by the \p op callback function. These flags are defined @@ -2658,23 +2232,6 @@ H5_DLL herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t i * group change during the iteration, the resulting behavior * is undefined. * - * \note \Bold{Programming Note for C++ Developers Using C Functions:} - * \note If a C routine that takes a function pointer as an argument is - * called from within C++ code, the C routine should be returned - * from normally. - * - * \note Examples of this kind of routine include callbacks such as - * H5Pset_elink_cb() and H5Pset_type_conv_cb() and - * functions such as H5Tconvert() and H5Ewalk2(). - * - * \note Exiting the routine in its normal fashion allows the HDF5 - * C library to clean up its work properly. In other words, if - * the C++ application jumps out of the routine back to the C++ - * “catch†statement, the library is not given the opportunity - * to close any temporary data structures that were set up when - * the routine was called. The C++ application should save some - * state as the routine is started so that any problem that occurs - * might be diagnosed. * * \since 1.10.3 * @@ -2739,24 +2296,18 @@ H5_DLL herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order * a group have not been indexed by the index type, they will * first be sorted by that index then the iteration will begin; * if the links have been so indexed, the sorting step will be - * unnecessary, so the iteration may begin more quickly. Valid - * values include the following: - * - * \indexes + * unnecessary, so the iteration may begin more quickly. * * Note that the index type passed in \p idx_type is a * best effort setting. If the application passes in a * value indicating iteration in creation order and a group is * encountered that was not tracked in creation order, that group - * will be iterated over in alpha-numeric order by name, or + * will be iterated over in alphanumeric order by name, or * name order. (Name order is the native order * used by the HDF5 library and is always available.) * * \p order specifies the order in which objects are to be inspected - * along the index specified in \p idx_type. Valid values include - * the following: - * - * \orders + * along the index specified in \p idx_type. * * The \p op callback function and the effect of the callback * function’s return value on the application are described @@ -2791,24 +2342,6 @@ H5_DLL herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order * in the file has been presented to the application for whatever * processing the application requires. * - * \note \Bold{Programming Note for C++ Developers Using C Functions:} - * \note If a C routine that takes a function pointer as an argument is - * called from within C++ code, the C routine should be returned - * from normally. - * - * \note Examples of this kind of routine include callbacks such as - * H5Pset_elink_cb() and H5Pset_type_conv_cb() and - * functions such as H5Tconvert() and H5Ewalk2(). - * - * \note Exiting the routine in its normal fashion allows the HDF5 - * C library to clean up its work properly. In other words, if - * the C++ application jumps out of the routine back to the C++ - * “catch†statement, the library is not given the opportunity - * to close any temporary data structures that were set up when - * the routine was called. The C++ application should save some - * state as the routine is started so that any problem that occurs - * might be diagnosed. - * * \since 1.10.3 * */ diff --git a/src/H5Orefcount.c b/src/H5Orefcount.c index 52eee1415a2..8f4c9abbf77 100644 --- a/src/H5Orefcount.c +++ b/src/H5Orefcount.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -30,10 +29,10 @@ #include "H5Opkg.h" /* Object headers */ /* PRIVATE PROTOTYPES */ -static void * H5O__refcount_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__refcount_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__refcount_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__refcount_copy(const void *_mesg, void *_dest); +static void *H5O__refcount_copy(const void *_mesg, void *_dest); static size_t H5O__refcount_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__refcount_free(void *_mesg); static herr_t H5O__refcount_pre_copy_file(H5F_t *file_src, const void *mesg_src, hbool_t *deleted, @@ -45,7 +44,7 @@ const H5O_msg_class_t H5O_MSG_REFCOUNT[1] = {{ H5O_REFCOUNT_ID, /*message id number */ "refcount", /*message name for debugging */ sizeof(H5O_refcount_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__refcount_decode, /*decode message */ H5O__refcount_encode, /*encode message */ H5O__refcount_copy, /*copy the native value */ @@ -89,7 +88,7 @@ H5O__refcount_decode(H5F_t H5_ATTR_UNUSED *f, H5O_t H5_ATTR_UNUSED *open_oh, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_refcount_t *refcount = NULL; /* Reference count */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -170,8 +169,8 @@ static void * H5O__refcount_copy(const void *_mesg, void *_dest) { const H5O_refcount_t *refcount = (const H5O_refcount_t *)_mesg; - H5O_refcount_t * dest = (H5O_refcount_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_refcount_t *dest = (H5O_refcount_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index dab989f4d87..79e4e586733 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -24,10 +23,10 @@ #include "H5Spkg.h" /* Dataspaces */ /* PRIVATE PROTOTYPES */ -static void * H5O__sdspace_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__sdspace_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg); -static void * H5O__sdspace_copy(const void *_mesg, void *_dest); +static void *H5O__sdspace_copy(const void *_mesg, void *_dest); static size_t H5O__sdspace_size(const H5F_t *f, const void *_mesg); static herr_t H5O__sdspace_reset(void *_mesg); static herr_t H5O__sdspace_free(void *_mesg); @@ -61,7 +60,7 @@ const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{ H5O_SDSPACE_ID, /* message id number */ "dataspace", /* message name for debugging */ sizeof(H5S_extent_t), /* native message size */ - H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are sharable? */ + H5O_SHARE_IS_SHARABLE | H5O_SHARE_IN_OHDR, /* messages are shareable? */ H5O__sdspace_shared_decode, /* decode message */ H5O__sdspace_shared_encode, /* encode message */ H5O__sdspace_copy, /* copy the native value */ @@ -108,11 +107,11 @@ static void * H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t p_size, const uint8_t *p) { - H5S_extent_t * sdim = NULL; /* New extent dimensionality structure */ + const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ + H5S_extent_t *sdim = NULL; /* New extent dimensionality structure */ unsigned flags, version; - unsigned i; /* Local counting variable */ - const uint8_t *p_end = p + p_size - 1; /* End of the p buffer */ - void * ret_value = NULL; /* Return value */ + unsigned i; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -122,25 +121,37 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UN /* decode */ if (NULL == (sdim = H5FL_CALLOC(H5S_extent_t))) - HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, NULL, "dataspace structure allocation failed") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "dataspace structure allocation failed") + sdim->type = H5S_NO_CLASS; /* Check version */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") version = *p++; + if (version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in dataspace message") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "wrong version number in dataspace message") sdim->version = version; /* Get rank */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") sdim->rank = *p++; + if (sdim->rank > H5S_MAX_RANK) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "simple dataspace dimensionality is too large") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "simple dataspace dimensionality is too large") /* Get dataspace flags for later */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") flags = *p++; /* Get or determine the type of the extent */ if (version >= H5O_SDSPACE_VERSION_2) { + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") sdim->type = (H5S_class_t)*p++; + if (sdim->type != H5S_SIMPLE && sdim->rank > 0) HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid rank for scalar or NULL dataspace") } /* end if */ @@ -152,36 +163,48 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UN sdim->type = H5S_SCALAR; /* Increment past reserved byte */ + if (H5_IS_BUFFER_OVERFLOW(p, 1, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") p++; } /* end else */ HDassert(sdim->type != H5S_NULL || sdim->version >= H5O_SDSPACE_VERSION_2); /* Only Version 1 has these reserved bytes */ - if (version == H5O_SDSPACE_VERSION_1) + if (version == H5O_SDSPACE_VERSION_1) { + if (H5_IS_BUFFER_OVERFLOW(p, 4, p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") p += 4; /*reserved*/ + } /* Decode dimension sizes */ if (sdim->rank > 0) { - /* Ensure that rank doesn't cause reading passed buffer's end, - due to possible data corruption */ uint8_t sizeof_size = H5F_SIZEOF_SIZE(f); - if (p + (sizeof_size * sdim->rank - 1) > p_end) { - HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "rank might cause reading passed buffer's end") - } + + /* + * Ensure that decoding doesn't cause reading past buffer's end, + * due to possible data corruption - check that we have space to + * decode a "sdim->rank" number of hsize_t values + */ + if (H5_IS_BUFFER_OVERFLOW(p, (sizeof_size * sdim->rank), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") if (NULL == (sdim->size = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed") for (i = 0; i < sdim->rank; i++) H5F_DECODE_LENGTH(f, p, sdim->size[i]); if (flags & H5S_VALID_MAX) { if (NULL == (sdim->max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)sdim->rank))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed") - /* Ensure that rank doesn't cause reading passed buffer's end */ - if (p + (sizeof_size * sdim->rank - 1) > p_end) - HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "rank might cause reading passed buffer's end") + /* + * Ensure that decoding doesn't cause reading past buffer's end, + * due to possible data corruption - check that we have space to + * decode a "sdim->rank" number of hsize_t values + */ + if (H5_IS_BUFFER_OVERFLOW(p, (sizeof_size * sdim->rank), p_end)) + HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding") for (i = 0; i < sdim->rank; i++) H5F_DECODE_LENGTH(f, p, sdim->max[i]); @@ -298,8 +321,8 @@ static void * H5O__sdspace_copy(const void *_mesg, void *_dest) { const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg; - H5S_extent_t * dest = (H5S_extent_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5S_extent_t *dest = (H5S_extent_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Oshared.c b/src/H5Oshared.c index 51ea145d1f9..4e36da6b531 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -67,7 +66,7 @@ /********************/ /* Local Prototypes */ /********************/ -static void * H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t *shared, +static void *H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t *shared, const H5O_msg_class_t *type); static herr_t H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, H5O_shared_t *shared, int adjust); @@ -106,7 +105,7 @@ H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t H5HF_t *fheap = NULL; H5WB_t *wb = NULL; /* Wrapped buffer for attribute data */ uint8_t mesg_buf[H5O_MESG_BUF_SIZE]; /* Buffer for deserializing messages */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -176,7 +175,7 @@ H5O__shared_read(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const H5O_shared_t else /* The shared message is in another object header */ if (NULL == (ret_value = H5O_msg_read(&oloc, type->id, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read message") + HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read message") } /* end else */ /* Mark the message as shared */ @@ -265,7 +264,7 @@ H5O__shared_link_adj(H5F_t *f, H5O_t *open_oh, const H5O_msg_class_t *type, H5O_ else /* The shared message is in another object header */ if (H5O_link(&oloc, adjust) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared object link count") } /* end if */ else { HDassert(shared->type == H5O_SHARE_TYPE_SOHM || shared->type == H5O_SHARE_TYPE_HERE); @@ -305,7 +304,7 @@ H5O__shared_decode(H5F_t *f, H5O_t *open_oh, unsigned *ioflags, const uint8_t *b { H5O_shared_t sh_mesg; /* Shared message info */ unsigned version; /* Shared message version */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -671,7 +670,7 @@ H5O__shared_post_copy_file(H5F_t *f, const H5O_msg_class_t *mesg_type, const H5O else /* Share the message */ if (H5SM_try_share(f, NULL, H5SM_WAS_DEFERRED, mesg_type->id, shared_dst, mesg_flags) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't share message") + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't share message") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Oshared.h b/src/H5Oshared.h index f164db3ff44..4443b26ac5a 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Oshmesg.c b/src/H5Oshmesg.c index 1c894a54d3c..005a9ea0b50 100644 --- a/src/H5Oshmesg.c +++ b/src/H5Oshmesg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -25,10 +24,10 @@ #include "H5Opkg.h" /* Object headers */ #include "H5MMprivate.h" /* Memory management */ -static void * H5O__shmesg_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, +static void *H5O__shmesg_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__shmesg_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__shmesg_copy(const void *_mesg, void *_dest); +static void *H5O__shmesg_copy(const void *_mesg, void *_dest); static size_t H5O__shmesg_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__shmesg_debug(H5F_t *f, const void *_mesg, FILE *stream, int indent, int fwidth); @@ -37,7 +36,7 @@ const H5O_msg_class_t H5O_MSG_SHMESG[1] = {{ H5O_SHMESG_ID, /*message id number */ "shared message table", /*message name for debugging */ sizeof(H5O_shmesg_table_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__shmesg_decode, /*decode message */ H5O__shmesg_encode, /*encode message */ H5O__shmesg_copy, /*copy the native value */ @@ -75,7 +74,7 @@ H5O__shmesg_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNU unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_shmesg_table_t *mesg; /* Native message */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -149,8 +148,8 @@ static void * H5O__shmesg_copy(const void *_mesg, void *_dest) { const H5O_shmesg_table_t *mesg = (const H5O_shmesg_table_t *)_mesg; - H5O_shmesg_table_t * dest = (H5O_shmesg_table_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_shmesg_table_t *dest = (H5O_shmesg_table_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Ostab.c b/src/H5Ostab.c index fa030bd193e..58990622fff 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -36,11 +35,11 @@ static void *H5O__stab_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p); static herr_t H5O__stab_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg); -static void * H5O__stab_copy(const void *_mesg, void *_dest); +static void *H5O__stab_copy(const void *_mesg, void *_dest); static size_t H5O__stab_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg); static herr_t H5O__stab_free(void *_mesg); static herr_t H5O__stab_delete(H5F_t *f, H5O_t *open_oh, void *_mesg); -static void * H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, +static void *H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *_udata); static herr_t H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_loc_t *dst_oloc, void *mesg_dst, unsigned *mesg_flags, H5O_copy_t *cpy_info); @@ -51,7 +50,7 @@ const H5O_msg_class_t H5O_MSG_STAB[1] = {{ H5O_STAB_ID, /*message id number */ "stab", /*message name for debugging */ sizeof(H5O_stab_t), /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ H5O__stab_decode, /*decode message */ H5O__stab_encode, /*encode message */ H5O__stab_copy, /*copy the native value */ @@ -93,7 +92,7 @@ H5O__stab_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, unsigned H5_ATTR_UNUSE unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { H5O_stab_t *stab = NULL; - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -168,8 +167,8 @@ static void * H5O__stab_copy(const void *_mesg, void *_dest) { const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; - H5O_stab_t * dest = (H5O_stab_t *)_dest; - void * ret_value = NULL; /* Return value */ + H5O_stab_t *dest = (H5O_stab_t *)_dest; + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -291,11 +290,11 @@ H5O__stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t H5_ATTR_UNUSED *cpy_info, void *_udata) { - H5O_stab_t * stab_src = (H5O_stab_t *)native_src; - H5O_stab_t * stab_dst = NULL; + H5O_stab_t *stab_src = (H5O_stab_t *)native_src; + H5O_stab_t *stab_dst = NULL; H5G_copy_file_ud_t *udata = (H5G_copy_file_ud_t *)_udata; size_t size_hint; /* Local heap initial size */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -354,7 +353,7 @@ H5O__stab_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_lo unsigned H5_ATTR_UNUSED *mesg_flags, H5O_copy_t *cpy_info) { const H5O_stab_t *stab_src = (const H5O_stab_t *)mesg_src; - H5O_stab_t * stab_dst = (H5O_stab_t *)mesg_dst; + H5O_stab_t *stab_dst = (H5O_stab_t *)mesg_dst; H5G_bt_it_cpy_t udata; /* B-tree user data */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Otest.c b/src/H5Otest.c index cdbc5eebeba..a46dee53118 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -86,9 +85,9 @@ htri_t H5O__is_attr_dense_test(hid_t oid) { - H5O_t * oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t * loc; /* Pointer to object's location */ + H5O_loc_t *loc; /* Pointer to object's location */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ htri_t ret_value = FAIL; /* Return value */ @@ -155,11 +154,11 @@ H5O__is_attr_dense_test(hid_t oid) htri_t H5O__is_attr_empty_test(hid_t oid) { - H5O_t * oh = NULL; /* Object header */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5O_t *oh = NULL; /* Object header */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ H5O_ainfo_t ainfo; /* Attribute information for object */ htri_t ainfo_exists = FALSE; /* Whether the attribute info exists in the file */ - H5O_loc_t * loc; /* Pointer to object's location */ + H5O_loc_t *loc; /* Pointer to object's location */ hsize_t nattrs; /* Number of attributes */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ htri_t ret_value = FAIL; /* Return value */ @@ -258,10 +257,10 @@ H5O__is_attr_empty_test(hid_t oid) herr_t H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) { - H5O_t * oh = NULL; /* Object header */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + H5O_t *oh = NULL; /* Object header */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t * loc; /* Pointer to object's location */ + H5O_loc_t *loc; /* Pointer to object's location */ hsize_t obj_nattrs; /* Number of attributes */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ @@ -357,11 +356,11 @@ H5O__num_attrs_test(hid_t oid, hsize_t *nattrs) herr_t H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) { - H5O_t * oh = NULL; /* Object header */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - H5B2_t * bt2_corder = NULL; /* v2 B-tree handle for creation order index */ + H5O_t *oh = NULL; /* Object header */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + H5B2_t *bt2_corder = NULL; /* v2 B-tree handle for creation order index */ H5O_ainfo_t ainfo; /* Attribute information for object */ - H5O_loc_t * loc; /* Pointer to object's location */ + H5O_loc_t *loc; /* Pointer to object's location */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ @@ -461,8 +460,8 @@ H5O__attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) herr_t H5O__check_msg_marked_test(hid_t oid, hbool_t flag_val) { - H5O_t * oh = NULL; /* Object header */ - H5O_loc_t * loc; /* Pointer to object's location */ + H5O_t *oh = NULL; /* Object header */ + H5O_loc_t *loc; /* Pointer to object's location */ H5O_mesg_t *idx_msg; /* Pointer to message */ unsigned idx; /* Index of message */ herr_t ret_value = SUCCEED; /* Return value */ @@ -522,7 +521,7 @@ H5O__check_msg_marked_test(hid_t oid, hbool_t flag_val) herr_t H5O__expunge_chunks_test(const H5O_loc_t *loc) { - H5O_t * oh = NULL; /* Object header */ + H5O_t *oh = NULL; /* Object header */ haddr_t chk_addr[16]; /* Array of chunk addresses */ size_t nchunks; /* Number of chunks in object header */ size_t u; /* Local index variable */ @@ -628,8 +627,8 @@ H5O__get_rc_test(const H5O_loc_t *loc, unsigned *rc) herr_t H5O__msg_get_chunkno_test(hid_t oid, unsigned msg_type, unsigned *chunk_num) { - H5O_t * oh = NULL; /* Object header */ - H5O_loc_t * loc; /* Pointer to object's location */ + H5O_t *oh = NULL; /* Object header */ + H5O_loc_t *loc; /* Pointer to object's location */ H5O_mesg_t *idx_msg; /* Pointer to message */ unsigned idx; /* Index of message */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ @@ -695,8 +694,8 @@ H5O__msg_get_chunkno_test(hid_t oid, unsigned msg_type, unsigned *chunk_num) herr_t H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type) { - H5O_t * oh = NULL; /* Object header */ - H5O_loc_t * loc; /* Pointer to object's location */ + H5O_t *oh = NULL; /* Object header */ + H5O_loc_t *loc; /* Pointer to object's location */ H5O_mesg_t *curr_msg; /* Pointer to current message */ unsigned idx; /* Index of message */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ @@ -722,7 +721,7 @@ H5O__msg_move_to_new_chunk_test(hid_t oid, unsigned msg_type) if (curr_msg->type->id == msg_type) { H5O_msg_alloc_info_t found_msg; /* Information about message to move */ unsigned msg_chunkno = curr_msg->chunkno; /* Chunk that the message is in */ - uint8_t * end_chunk_data = + uint8_t *end_chunk_data = (oh->chunk[msg_chunkno].image + oh->chunk[msg_chunkno].size) - (H5O_SIZEOF_CHKSUM_OH(oh) + oh->chunk[msg_chunkno].gap); /* End of message data in chunk */ uint8_t *end_msg = curr_msg->raw + curr_msg->raw_size; /* End of current message */ diff --git a/src/H5Ounknown.c b/src/H5Ounknown.c index 2b8a7bbcd92..e13650cb352 100644 --- a/src/H5Ounknown.c +++ b/src/H5Ounknown.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -37,7 +36,7 @@ const H5O_msg_class_t H5O_MSG_UNKNOWN[1] = {{ H5O_UNKNOWN_ID, /*message id number */ "unknown", /*message name for debugging */ 0, /*native message size */ - 0, /* messages are sharable? */ + 0, /* messages are shareable? */ NULL, /*decode message */ NULL, /*encode message */ NULL, /*copy the native value */ diff --git a/src/H5P.c b/src/H5P.c index 45a9267471e..54d2720983b 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -43,7 +42,7 @@ typedef struct { H5P_iterate_t iter_func; /* Iterator callback */ hid_t id; /* Property list or class ID */ - void * iter_data; /* Iterator callback pointer */ + void *iter_data; /* Iterator callback pointer */ } H5P_iter_ud_t; /********************/ @@ -664,7 +663,7 @@ H5Pset(hid_t plist_id, const char *name, const void *value) if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); if (value == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalied property value"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property value"); /* Go set the value */ if (H5P_set(plist, name, value) < 0) @@ -678,7 +677,7 @@ H5Pset(hid_t plist_id, const char *name, const void *value) NAME H5Pexist PURPOSE - Routine to query the existance of a property in a property object. + Routine to query the existence of a property in a property object. USAGE htri_t H5P_exist(id, name) hid_t id; IN: Property object ID to check @@ -712,7 +711,7 @@ H5Pexist(hid_t id, const char *name) if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); - /* Check for the existance of the property in the list or class */ + /* Check for the existence of the property in the list or class */ if (H5I_GENPROP_LST == H5I_get_type(id)) { if (NULL == (plist = (H5P_genplist_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); @@ -858,7 +857,7 @@ H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id) Failure: H5I_INVALID_HID (negative) DESCRIPTION Decodes a property list from a binary buffer. The contents of the buffer - contain the values for the correponding properties of the plist. The decode + contain the values for the corresponding properties of the plist. The decode callback of a certain property decodes its value from the buffer and sets it in the property list. GLOBAL VARIABLES @@ -1018,7 +1017,7 @@ H5Pget_nprops(hid_t id, size_t *nprops) htri_t H5Pequal(hid_t id1, hid_t id2) { - void * obj1, *obj2; /* Property objects to compare */ + void *obj1, *obj2; /* Property objects to compare */ htri_t ret_value = FALSE; /* return value */ FUNC_ENTER_API(FAIL) @@ -1195,7 +1194,7 @@ H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) { H5P_iter_ud_t udata; /* User data for internal iterator callback */ int fake_idx = 0; /* Index when user doesn't provide one */ - void * obj; /* Property object to copy */ + void *obj; /* Property object to copy */ int ret_value; /* return value */ FUNC_ENTER_API(FAIL) @@ -1276,7 +1275,7 @@ H5Pget(hid_t plist_id, const char *name, void *value) if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); if (value == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalied property value"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property value"); /* Go get the value */ if (H5P_get(plist, name, value) < 0) @@ -1299,7 +1298,7 @@ H5Pget(hid_t plist_id, const char *name, void *value) Returns non-negative on success, negative on failure. DESCRIPTION Removes a property from a property list. Both properties which were - in existance when the property list was created (i.e. properties registered + in existence when the property list was created (i.e. properties registered with H5Pregister2) and properties added to the list after it was created (i.e. added with H5Pinsert2) may be removed from a property list. Properties do not need to be removed a property list before the list itself @@ -1522,7 +1521,7 @@ char * H5Pget_class_name(hid_t pclass_id) { H5P_genclass_t *pclass; /* Property class to query */ - char * ret_value; /* return value */ + char *ret_value; /* return value */ FUNC_ENTER_API(NULL) H5TRACE1("*s", "i", pclass_id); diff --git a/src/H5PB.c b/src/H5PB.c index efaf1f9806b..1859055f87a 100644 --- a/src/H5PB.c +++ b/src/H5PB.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -429,7 +428,7 @@ static herr_t H5PB__dest_cb(void *item, void H5_ATTR_UNUSED *key, void *_op_data) { H5PB_entry_t *page_entry = (H5PB_entry_t *)item; /* Pointer to page entry node */ - H5PB_ud1_t * op_data = (H5PB_ud1_t *)_op_data; + H5PB_ud1_t *op_data = (H5PB_ud1_t *)_op_data; FUNC_ENTER_STATIC_NOERR @@ -473,7 +472,7 @@ H5PB_dest(H5F_shared_t *f_sh) /* flush and destroy the page buffer, if it exists */ if (f_sh->page_buf) { - H5PB_t * page_buf = f_sh->page_buf; + H5PB_t *page_buf = f_sh->page_buf; H5PB_ud1_t op_data; /* Iteration context */ if (H5PB_flush(f_sh) < 0) @@ -520,7 +519,7 @@ H5PB_dest(H5F_shared_t *f_sh) herr_t H5PB_add_new_page(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t page_addr) { - H5PB_t * page_buf; /* Page buffer to operate on */ + H5PB_t *page_buf; /* Page buffer to operate on */ H5PB_entry_t *page_entry = NULL; /* Pointer to the corresponding page entry */ herr_t ret_value = SUCCEED; /* Return value */ @@ -626,7 +625,7 @@ H5PB_update_entry(H5PB_t *page_buf, haddr_t addr, size_t size, const void *buf) herr_t H5PB_remove_entry(const H5F_shared_t *f_sh, haddr_t addr) { - H5PB_t * page_buf; /* Page buffer to operate on */ + H5PB_t *page_buf; /* Page buffer to operate on */ H5PB_entry_t *page_entry = NULL; /* Pointer to the page entry being searched */ herr_t ret_value = SUCCEED; /* Return value */ @@ -675,9 +674,9 @@ H5PB_remove_entry(const H5F_shared_t *f_sh, haddr_t addr) herr_t H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/) { - H5PB_t * page_buf; /* Page buffering info for this file */ + H5PB_t *page_buf; /* Page buffering info for this file */ H5PB_entry_t *page_entry; /* Pointer to the corresponding page entry */ - H5FD_t * file; /* File driver pointer */ + H5FD_t *file; /* File driver pointer */ haddr_t first_page_addr, last_page_addr; /* Addresses of the first and last pages covered by I/O */ haddr_t offset; haddr_t search_addr; /* Address of current page */ @@ -877,7 +876,7 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * } /* end if */ /* if not found */ else { - void * new_page_buf = NULL; + void *new_page_buf = NULL; size_t page_size = page_buf->page_size; haddr_t eoa; @@ -976,9 +975,9 @@ H5PB_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, void * herr_t H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf) { - H5PB_t * page_buf; /* Page buffering info for this file */ + H5PB_t *page_buf; /* Page buffering info for this file */ H5PB_entry_t *page_entry; /* Pointer to the corresponding page entry */ - H5FD_t * file; /* File driver pointer */ + H5FD_t *file; /* File driver pointer */ haddr_t first_page_addr, last_page_addr; /* Addresses of the first and last pages covered by I/O */ haddr_t offset; haddr_t search_addr; /* Address of current page */ @@ -1183,7 +1182,7 @@ H5PB_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size, const } /* end if */ /* If not found */ else { - void * new_page_buf; + void *new_page_buf; size_t page_size = page_buf->page_size; /* Make space for new entry */ diff --git a/src/H5PBpkg.h b/src/H5PBpkg.h index 2656588f32a..603f5652d1a 100644 --- a/src/H5PBpkg.h +++ b/src/H5PBpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -32,7 +31,7 @@ /****************************/ typedef struct H5PB_entry_t { - void * page_buf_ptr; /* Pointer to the buffer containing the data */ + void *page_buf_ptr; /* Pointer to the buffer containing the data */ haddr_t addr; /* Address of the page in the file */ H5F_mem_page_t type; /* Type of the page entry (H5F_MEM_PAGE_RAW/META) */ hbool_t is_dirty; /* Flag indicating whether the page has dirty data or not */ diff --git a/src/H5PBprivate.h b/src/H5PBprivate.h index e0197bfed27..0ac5a1a66bb 100644 --- a/src/H5PBprivate.h +++ b/src/H5PBprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -23,11 +22,6 @@ #ifndef H5PBprivate_H #define H5PBprivate_H -/* Include package's public header */ -#ifdef NOT_YET -#include "H5PBpublic.h" -#endif /* NOT_YET */ - /* Private headers needed by this header */ #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* File access */ diff --git a/src/H5PL.c b/src/H5PL.c index 4556885c250..bbdef22fc6e 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -67,7 +67,7 @@ * the special "::" string. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -99,7 +99,7 @@ H5PLset_loading_state(unsigned int plugin_control_mask) * Positive if one or more of the plugin types are enabled * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -128,7 +128,7 @@ H5PLget_loading_state(unsigned int *plugin_control_mask) * Purpose: Insert a plugin search path at the end of the list. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -160,7 +160,7 @@ H5PLappend(const char *search_path) * Purpose: Insert a plugin search path at the beginning of the list. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -234,7 +234,7 @@ H5PLreplace(const char *search_path, unsigned int idx) * other paths after the index. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -270,11 +270,11 @@ H5PLinsert(const char *search_path, unsigned int idx) /*------------------------------------------------------------------------- * Function: H5PLremove * - * Purpose: Remove the plugin path at the specifed index and compact + * Purpose: Remove the plugin path at the specified index and compact * the list. * * Return: Success: Non-negative - * Failture: Negative + * Failure: Negative * * Return: Non-negative or success. * @@ -359,7 +359,7 @@ H5PLget(unsigned int idx, char *path_buf, size_t buf_size) /* If the path buffer is not NULL, copy the path to the buffer */ if (path_buf) { - HDstrncpy(path_buf, path, MIN((size_t)(path_len + 1), buf_size)); + HDstrncpy(path_buf, path, buf_size); if ((size_t)path_len >= buf_size) path_buf[buf_size - 1] = '\0'; } /* end if */ diff --git a/src/H5PLextern.h b/src/H5PLextern.h index 7f3df5e2f92..d136051beda 100644 --- a/src/H5PLextern.h +++ b/src/H5PLextern.h @@ -2,7 +2,7 @@ * Copyright by The HDF Group. * * All rights reserved. * * * - * This file is part of HDF5. The full HDF5 copyright notice, including * + * 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. * diff --git a/src/H5PLint.c b/src/H5PLint.c index cf6135da9fe..1b58be150ac 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -135,7 +135,7 @@ H5PL__set_plugin_control_mask(unsigned int mask) herr_t H5PL__init_package(void) { - char * env_var = NULL; + char *env_var = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -225,8 +225,8 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) { H5PL_search_params_t search_params; /* Plugin search parameters */ hbool_t found = FALSE; /* Whether the plugin was found */ - const void * plugin_info = NULL; /* Information from the plugin */ - const void * ret_value = NULL; + const void *plugin_info = NULL; /* Information from the plugin */ + const void *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -258,11 +258,17 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) /* If not found, try iterating through the path table to find an appropriate plugin */ if (!found) if (H5PL__find_plugin_in_path_table(&search_params, &found, &plugin_info) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in path table failed") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, + "can't find plugin in the paths either set by HDF5_PLUGIN_PATH, or default location, " + "or set by H5PLxxx functions") /* Set the return value we found the plugin */ if (found) ret_value = plugin_info; + else + HGOTO_ERROR(H5E_PLUGIN, H5E_NOTFOUND, NULL, + "can't find plugin. Check either HDF5_PLUGIN_PATH, default location, " + "or path set by H5PLxxx functions") done: FUNC_LEAVE_NOAPI(ret_value) @@ -273,9 +279,31 @@ H5PL_load(H5PL_type_t type, const H5PL_key_t *key) * * Purpose: Opens a plugin. * - * The success parameter will be set to TRUE and the plugin_info - * parameter will be filled in on success. Otherwise, they - * will be FALSE and NULL, respectively. + * `path` specifies the path to the plugin library file. + * + * `type` specifies the type of plugin being searched for and + * will be used to verify that a loaded plugin matches the + * type requested. H5PL_TYPE_NONE may be passed, in which case + * no plugin type verification is performed. This is most + * useful when iterating over available plugins without regard + * to their types. + * + * `key` specifies the information that will be used to find a + * specific plugin. For filter plugins, this is typically an + * integer identifier. For VOL connectors, this + * is typically either an integer identifier or a name string. + * After a plugin has been opened, this information will be + * compared against the relevant information provided by the + * plugin to ensure that the plugin is a match. If + * H5PL_TYPE_NONE is provided for `type`, then `key` should be + * NULL. + * + * On successful open of a plugin, the `success` parameter + * will be set to TRUE and the `plugin_type` and `plugin_info` + * parameters will be filled appropriately. On failure, the + * `success` parameter will be set to FALSE, the `plugin_type` + * parameter will be set to H5PL_TYPE_ERROR and the + * `plugin_info` parameter will be set to NULL. * * Return: SUCCEED/FAIL * diff --git a/src/H5PLmodule.h b/src/H5PLmodule.h index ab9f1d5ff89..fff1e95e682 100644 --- a/src/H5PLmodule.h +++ b/src/H5PLmodule.h @@ -27,9 +27,40 @@ #define H5_MY_PKG_ERR H5E_PLUGIN #define H5_MY_PKG_INIT YES -/**\defgroup H5PL H5PL - * \brief Plugins - * \todo Describe what programmatically controlling dynamically loaded plugins (H5PL) is all about +/** \page H5PL_UG The HDF5 Plugins + * @todo Under Construction + */ + +/** + * \defgroup H5PL Dynamically-loaded Plugins (H5PL) + * + * Use the functions in this module to manage the loading behavior of HDF5 + * plugins. + * + * + * + * + * + * + * + * + * + * + * + *
    CreateRead
    + * \snippet H5PL_examples.c create + * + * \snippet H5PL_examples.c read + *
    UpdateDelete
    + * \snippet H5PL_examples.c update + * + * \snippet H5PL_examples.c delete + *
    + * + * \attention The loading behavior of HDF5 plugins can be controlled via the + * functions described below and certain environment variables, such + * as \c HDF5_PLUGIN_PRELOAD and \c HDF5_PLUGIN_PATH. + * */ #endif /* H5PLmodule_H */ diff --git a/src/H5PLpath.c b/src/H5PLpath.c index 39a7d0dc11d..10a668cf7e2 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -102,7 +102,7 @@ static unsigned H5PL_path_capacity_g = H5PL_INITIAL_PATH_CAPACITY; static herr_t H5PL__insert_at(const char *path, unsigned int idx) { - char * path_copy = NULL; /* copy of path string (for storing) */ + char *path_copy = NULL; /* copy of path string (for storing) */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -183,7 +183,7 @@ H5PL__make_space_at(unsigned int idx) static herr_t H5PL__replace_at(const char *path, unsigned int idx) { - char * path_copy = NULL; /* copy of path string (for storing) */ + char *path_copy = NULL; /* copy of path string (for storing) */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -233,8 +233,8 @@ H5PL__create_path_table(void) char *paths = NULL; /* Delimited paths string. Either from the * environment variable or the default. */ - char * next_path = NULL; /* A path tokenized from the paths string */ - char * lasts = NULL; /* Context pointer for strtok_r() call */ + char *next_path = NULL; /* A path tokenized from the paths string */ + char *lasts = NULL; /* Context pointer for strtok_r() call */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -322,7 +322,7 @@ H5PL__close_path_table(void) * Purpose: Gets the number of plugin paths that have been stored. * * Return: Success: The number of paths - * Failture: Can't fail + * Failure: Can't fail *------------------------------------------------------------------------- */ unsigned @@ -603,10 +603,10 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type H5PL_iterate_t iter_op, void *op_data) { H5PL_type_t plugin_type; - const void * plugin_info = NULL; + const void *plugin_info = NULL; hbool_t plugin_loaded; - char * path = NULL; - DIR * dirp = NULL; /* Directory stream */ + char *path = NULL; + DIR *dirp = NULL; /* Directory stream */ struct dirent *dp = NULL; /* Directory entry */ herr_t ret_value = H5_ITER_CONT; @@ -615,9 +615,9 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type HDassert(plugin_path); HDassert(iter_op); - /* Open the directory */ + /* Open the directory - skip the path if the directory can't be opened */ if (!(dirp = HDopendir(plugin_path))) - HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, H5_ITER_ERROR, "can't open directory: %s", plugin_path) + HGOTO_DONE(H5_ITER_CONT); /* Iterate through all entries in the directory */ while (NULL != (dp = HDreaddir(dirp))) { @@ -694,9 +694,9 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type WIN32_FIND_DATAA fdFile; HANDLE hFind = INVALID_HANDLE_VALUE; H5PL_type_t plugin_type; - const void * plugin_info = NULL; + const void *plugin_info = NULL; hbool_t plugin_loaded; - char * path = NULL; + char *path = NULL; char service[2048]; herr_t ret_value = H5_ITER_CONT; @@ -706,10 +706,11 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type HDassert(plugin_path); HDassert(iter_op); - /* Specify a file mask. *.* = We want everything! */ - HDsprintf(service, "%s\\*.dll", plugin_path); + /* Specify a file mask. *.* = We want everything! - + * skip the path if the directory can't be opened */ + HDsnprintf(service, sizeof(service), "%s\\*.dll", plugin_path); if ((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE) - HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, H5_ITER_ERROR, "can't open directory") + HGOTO_DONE(H5_ITER_CONT); /* Loop over all the files */ do { @@ -798,8 +799,7 @@ H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool /* Search for the plugin in this path */ if (H5PL__find_plugin_in_path(search_params, found, H5PL_paths_g[u], plugin_info) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in path %s encountered an error", - H5PL_paths_g[u]) + HERROR(H5E_PLUGIN, H5E_CANTGET, "search in path %s encountered an error", H5PL_paths_g[u]); /* Break out if found */ if (*found) { @@ -816,7 +816,7 @@ H5PL__find_plugin_in_path_table(const H5PL_search_params_t *search_params, hbool /*------------------------------------------------------------------------- * Function: H5PL__find_plugin_in_path * - * Purpose: Given a path, this function opens the directory and envokes + * Purpose: Given a path, this function opens the directory and invokes * another function to go through all files to find the right * plugin library. Two function definitions are for Unix and * Windows. @@ -833,8 +833,8 @@ static herr_t H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *found, const char *dir, const void **plugin_info) { - char * path = NULL; - DIR * dirp = NULL; /* Directory stream */ + char *path = NULL; + DIR *dirp = NULL; /* Directory stream */ struct dirent *dp = NULL; /* Directory entry */ herr_t ret_value = SUCCEED; @@ -851,7 +851,8 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo /* Open the directory */ if (!(dirp = HDopendir(dir))) - HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory: %s", dir) + HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory (%s). Please verify its existence", + dir) /* Iterate through all entries in the directory */ while (NULL != (dp = HDreaddir(dirp))) { @@ -915,7 +916,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo { WIN32_FIND_DATAA fdFile; HANDLE hFind = INVALID_HANDLE_VALUE; - char * path = NULL; + char *path = NULL; char service[2048]; herr_t ret_value = SUCCEED; @@ -931,7 +932,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo *found = FALSE; /* Specify a file mask. *.* = We want everything! */ - HDsprintf(service, "%s\\*.dll", dir); + HDsnprintf(service, sizeof(service), "%s\\*.dll", dir); if ((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE) HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory") diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h index cffc358ae0e..9adbefa6e90 100644 --- a/src/H5PLpkg.h +++ b/src/H5PLpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index 2ec08450012..b74f6a1944e 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -269,11 +269,11 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f (search_params->key->id == (H5PL_cache_g[u]).key.id)) { H5PL_get_plugin_info_t get_plugin_info_function; - const void * info; + const void *info; /* Get the "get plugin info" function from the plugin. */ if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC( - (H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) + H5PL_cache_g[u].handle, "H5PLget_plugin_info"))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") /* Call the "get plugin info" function */ @@ -286,9 +286,7 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f /* No need to continue processing */ break; - - } /* end if */ - + } } /* end for */ done: diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index 7eae513d36f..8e50577ba30 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -39,7 +39,7 @@ typedef union H5PL_key_t { H5VL_get_connector_kind_t kind; /* Kind of VOL lookup to do */ union { H5VL_class_value_t value; /* VOL connector value */ - const char * name; /* VOL connector name */ + const char *name; /* VOL connector name */ } u; } vol; } H5PL_key_t; diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h index 55ff59485f1..8ef1c3ef134 100644 --- a/src/H5PLpublic.h +++ b/src/H5PLpublic.h @@ -2,7 +2,7 @@ * Copyright by The HDF Group. * * All rights reserved. * * * - * This file is part of HDF5. The full HDF5 copyright notice, including * + * 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. * @@ -17,8 +17,7 @@ #ifndef H5PLpublic_H #define H5PLpublic_H -/* Public headers needed by this file */ -#include "H5public.h" /* Generic Functions */ +#include "H5public.h" /* Generic Functions */ /*******************/ /* Public Typedefs */ @@ -93,9 +92,9 @@ H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_control_mask); * \brief Queries the loadability of dynamic plugin types * * \param[out] plugin_control_mask List of dynamic plugin types that are enabled or disabled.\n - * A plugin bit set to 0 (zero) indicates that that the dynamic plugin type is + * A plugin bit set to 0 (zero) indicates that the dynamic plugin type is * disabled.\n - * A plugin bit set to 1 (one) indicates that that the dynamic plugin type is + * A plugin bit set to 1 (one) indicates that the dynamic plugin type is * enabled.\n * If the value of \p plugin_control_mask is negative, all dynamic plugin * types are enabled.\n @@ -103,7 +102,7 @@ H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_control_mask); * are disabled. * \return \herr_t * - * \details H5PLget_loading_state() retrieves the bitmask that controls whether a certain type of plugins + * \details H5PLget_loading_state() retrieves the bitmask that controls whether a certain type of plugin * (e.g.: filters, VOL drivers) will be loaded by the HDF5 library. * * Bit positions allocated to date are specified in \ref H5PL_type_t as follows: diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index 65fd54ace77..b4dd90b8dfc 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 3b14959aded..86a2d43580b 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -315,7 +314,7 @@ static herr_t H5P__dapl_vds_file_pref_enc(const void *value, void **_pp, size_t *size) { const char *vds_file_pref = *(const char *const *)value; - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; size_t len = 0; uint64_t enc_value; unsigned enc_size; @@ -364,7 +363,7 @@ H5P__dapl_vds_file_pref_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dapl_vds_file_pref_dec(const void **_pp, void *_value) { - char ** vds_file_pref = (char **)_value; + char **vds_file_pref = (char **)_value; const uint8_t **pp = (const uint8_t **)_pp; size_t len; uint64_t enc_value; /* Decoded property value */ @@ -555,7 +554,7 @@ static herr_t H5P__dapl_efile_pref_enc(const void *value, void **_pp, size_t *size) { const char *efile_pref = *(const char *const *)value; - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; size_t len = 0; uint64_t enc_value; unsigned enc_size; @@ -604,7 +603,7 @@ H5P__dapl_efile_pref_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dapl_efile_pref_dec(const void **_pp, void *_value) { - char ** efile_pref = (char **)_value; + char **efile_pref = (char **)_value; const uint8_t **pp = (const uint8_t **)_pp; size_t len; uint64_t enc_value; /* Decoded property value */ @@ -739,7 +738,7 @@ H5P__dapl_efile_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE * Purpose: Set the number of objects in the meta data cache and the * maximum number of chunks and bytes in the raw data chunk cache. * Once set, these values will override the values in the file access - * property list. Each of thhese values can be individually unset + * property list. Each of these values can be individually unset * (or not set at all) by passing the macros: * H5D_CHUNK_CACHE_NCHUNKS_DEFAULT, * H5D_CHUNK_CACHE_NSLOTS_DEFAULT, and/or @@ -919,7 +918,7 @@ H5P__encode_chunk_cache_nslots(const void *value, void **_pp, size_t *size) static herr_t H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) { - size_t * value = (size_t *)_value; /* Property value to return */ + size_t *value = (size_t *)_value; /* Property value to return */ const uint8_t **pp = (const uint8_t **)_pp; uint64_t enc_value; /* Decoded property value */ unsigned enc_size; /* Size of encoded property */ @@ -1019,7 +1018,7 @@ H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, size_t *size) static herr_t H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) { - size_t * value = (size_t *)_value; /* Property value to return */ + size_t *value = (size_t *)_value; /* Property value to return */ const uint8_t **pp = (const uint8_t **)_pp; uint64_t enc_value; /* Decoded property value */ unsigned enc_size; /* Size of encoded property */ @@ -1138,7 +1137,7 @@ static herr_t H5P__dacc_vds_view_enc(const void *value, void **_pp, size_t *size) { const H5D_vds_view_t *view = (const H5D_vds_view_t *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1286,7 +1285,7 @@ herr_t H5Pset_append_flush(hid_t plist_id, unsigned ndims, const hsize_t *boundary, H5D_append_cb_t func, void *udata) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5D_append_flush_t info; /* Property for append flush parameters */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1347,7 +1346,7 @@ H5Pset_append_flush(hid_t plist_id, unsigned ndims, const hsize_t *boundary, H5D herr_t H5Pget_append_flush(hid_t plist_id, unsigned ndims, hsize_t boundary[], H5D_append_cb_t *func, void **udata) { - H5P_genplist_t * plist; /* property list pointer */ + H5P_genplist_t *plist; /* property list pointer */ H5D_append_flush_t info; unsigned u; /* local index variable */ herr_t ret_value = SUCCEED; /* return value */ @@ -1431,7 +1430,7 @@ ssize_t H5Pget_efile_prefix(hid_t plist_id, char *prefix, size_t size) { H5P_genplist_t *plist; /* Property list pointer */ - char * my_prefix; /* Library's copy of the prefix */ + char *my_prefix; /* Library's copy of the prefix */ size_t len; /* Length of prefix string */ ssize_t ret_value; /* Return value */ @@ -1451,7 +1450,7 @@ H5Pget_efile_prefix(hid_t plist_id, char *prefix, size_t size) /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); if (prefix) { - HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); + HDstrncpy(prefix, my_prefix, size); if (len >= size) prefix[size - 1] = '\0'; } /* end if */ @@ -1521,7 +1520,7 @@ ssize_t H5Pget_virtual_prefix(hid_t plist_id, char *prefix, size_t size) { H5P_genplist_t *plist; /* Property list pointer */ - char * my_prefix; /* Library's copy of the prefix */ + char *my_prefix; /* Library's copy of the prefix */ size_t len; /* Length of prefix string */ ssize_t ret_value; /* Return value */ @@ -1541,7 +1540,7 @@ H5Pget_virtual_prefix(hid_t plist_id, char *prefix, size_t size) /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); if (prefix) { - HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); + HDstrncpy(prefix, my_prefix, size); if (len >= size) prefix[size - 1] = '\0'; } /* end if */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 59a41ed6d02..df29fce4cf1 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -482,8 +481,8 @@ static herr_t H5P__dcrt_layout_enc(const void *value, void **_pp, size_t *size) { const H5O_layout_t *layout = (const H5O_layout_t *)value; /* Create local aliases for values */ - uint8_t ** pp = (uint8_t **)_pp; - uint8_t * tmp_p; + uint8_t **pp = (uint8_t **)_pp; + uint8_t *tmp_p; size_t tmp_size; size_t u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -619,7 +618,7 @@ H5P__dcrt_layout_dec(const void **_pp, void *value) const H5O_layout_t *layout; /* Storage layout */ H5O_layout_t tmp_layout; /* Temporary local layout structure */ H5D_layout_t type; /* Layout type */ - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1123,7 +1122,7 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) const H5O_fill_t *fill = (const H5O_fill_t *)value; /* Create local aliases for values */ size_t dt_size = 0; /* Size of encoded datatype */ herr_t ret_value = SUCCEED; /* Return value */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; uint64_t enc_value; unsigned enc_size = 0; @@ -1214,7 +1213,7 @@ H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dcrt_fill_value_dec(const void **_pp, void *_value) { - H5O_fill_t * fill = (H5O_fill_t *)_value; /* Fill value */ + H5O_fill_t *fill = (H5O_fill_t *)_value; /* Fill value */ const uint8_t **pp = (const uint8_t **)_pp; herr_t ret_value = SUCCEED; /* Return value */ @@ -1525,7 +1524,7 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) const H5O_efl_t *efl = (const H5O_efl_t *)value; /* Create local aliases for values */ size_t len = 0; /* String length of slot name */ size_t u; /* Local index variable */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; unsigned enc_size; uint64_t enc_value; @@ -1607,7 +1606,7 @@ H5P__dcrt_ext_file_list_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dcrt_ext_file_list_dec(const void **_pp, void *_value) { - H5O_efl_t * efl = (H5O_efl_t *)_value; /* External file list */ + H5O_efl_t *efl = (H5O_efl_t *)_value; /* External file list */ const uint8_t **pp = (const uint8_t **)_pp; size_t u, nused; unsigned enc_size; @@ -1717,7 +1716,7 @@ H5P__dcrt_ext_file_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNU * Failure: Negative * * Programmer: Neil Fortner - * Thurday, Feb 26, 2015 + * Thursday, Feb 26, 2015 * *-------------------------------------------------------------------------- */ @@ -1982,7 +1981,7 @@ H5P__init_def_layout(void) herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ const H5O_layout_t *layout; /* Pointer to default layout information for type specified */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2227,10 +2226,10 @@ herr_t H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, const char *src_dset_name, hid_t src_space_id) { - H5P_genplist_t * plist = NULL; /* Property list pointer */ + H5P_genplist_t *plist = NULL; /* Property list pointer */ H5O_layout_t virtual_layout; /* Layout information for setting virtual info */ - H5S_t * vspace; /* Virtual dataset space selection */ - H5S_t * src_space; /* Source dataset space selection */ + H5S_t *vspace; /* Virtual dataset space selection */ + H5S_t *src_space; /* Source dataset space selection */ H5O_storage_virtual_ent_t *old_list = NULL; /* List pointer previously on property list */ H5O_storage_virtual_ent_t *ent = NULL; /* Convenience pointer to new VDS entry */ hbool_t retrieved_layout = FALSE; /* Whether the layout has been retrieved */ @@ -2456,7 +2455,7 @@ H5Pget_virtual_vspace(hid_t dcpl_id, size_t idx) { H5P_genplist_t *plist; /* Property list pointer */ H5O_layout_t layout; /* Layout information */ - H5S_t * space = NULL; /* Dataspace pointer */ + H5S_t *space = NULL; /* Dataspace pointer */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -2513,7 +2512,7 @@ H5Pget_virtual_srcspace(hid_t dcpl_id, size_t idx) { H5P_genplist_t *plist; /* Property list pointer */ H5O_layout_t layout; /* Layout information */ - H5S_t * space = NULL; /* Dataspace pointer */ + H5S_t *space = NULL; /* Dataspace pointer */ hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) @@ -3275,7 +3274,7 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) H5O_fill_reset_dyn(&fill); if (value) { - H5T_t * type; /* Datatype for fill value */ + H5T_t *type; /* Datatype for fill value */ H5T_path_t *tpath; /* Conversion information */ /* Retrieve pointer to datatype */ @@ -3348,8 +3347,8 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value /*out*/ { H5O_fill_t fill; /* Fill value to retrieve */ H5T_path_t *tpath; /*type conversion info */ - void * buf = NULL; /*conversion buffer */ - void * bkg = NULL; /*conversion buffer */ + void *buf = NULL; /*conversion buffer */ + void *bkg = NULL; /*conversion buffer */ hid_t src_id = -1; /*source datatype id */ hid_t dst_id = -1; /*destination datatype id */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3440,7 +3439,7 @@ herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value /*out*/) { H5P_genplist_t *plist; /* Property list pointer */ - H5T_t * type; /* Datatype */ + H5T_t *type; /* Datatype */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) diff --git a/src/H5Pdeprec.c b/src/H5Pdeprec.c index bb705e2e605..d67b0c529c5 100644 --- a/src/H5Pdeprec.c +++ b/src/H5Pdeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index 2d6b313b1f2..b5d7d43c564 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -233,7 +232,7 @@ static const size_t H5D_def_max_temp_buf_g = H5D_XFER_MAX_TEMP_BUF_DEF; /* Default value for maximum temp buffer size */ static const void *H5D_def_tconv_buf_g = H5D_XFER_TCONV_BUF_DEF; /* Default value for type conversion buffer */ -static const void * H5D_def_bkgr_buf_g = H5D_XFER_BKGR_BUF_DEF; /* Default value for background buffer */ +static const void *H5D_def_bkgr_buf_g = H5D_XFER_BKGR_BUF_DEF; /* Default value for background buffer */ static const H5T_bkg_t H5D_def_bkgr_buf_type_g = H5D_XFER_BKGR_BUF_TYPE_DEF; static const double H5D_def_btree_split_ratio_g[3] = H5D_XFER_BTREE_SPLIT_RATIO_DEF; /* Default value for B-tree node split ratios */ @@ -443,7 +442,7 @@ static herr_t H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size) { const H5T_bkg_t *bkgr_buf_type = (const H5T_bkg_t *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -479,7 +478,7 @@ H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_bkgr_buf_type_dec(const void **_pp, void *_value) { - H5T_bkg_t * bkgr_buf_type = (H5T_bkg_t *)_value; /* Background buffer type */ + H5T_bkg_t *bkgr_buf_type = (H5T_bkg_t *)_value; /* Background buffer type */ const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -514,7 +513,7 @@ static herr_t H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) { const double *btree_split_ratio = (const double *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -562,7 +561,7 @@ H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value) { - double * btree_split_ratio = (double *)_value; /* B-tree split ratio */ + double *btree_split_ratio = (double *)_value; /* B-tree split ratio */ unsigned enc_size; /* Size of encoded property */ const uint8_t **pp = (const uint8_t **)_pp; herr_t ret_value = SUCCEED; /* Return value */ @@ -674,7 +673,7 @@ H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size) *(const H5Z_data_xform_t *const *)value; /* Create local alias for values */ const char *pexp = NULL; /* Pointer to transform expression */ size_t len = 0; /* Length of transform expression */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -744,7 +743,7 @@ H5P__dxfr_xform_dec(const void **_pp, void *_value) { H5Z_data_xform_t **data_xform_prop = (H5Z_data_xform_t **)_value; /* New data xform property */ size_t len; /* Length of encoded string */ - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; unsigned enc_size; uint64_t enc_value; herr_t ret_value = SUCCEED; /* Return value */ @@ -940,7 +939,7 @@ H5P__dxfr_xform_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED siz herr_t H5Pset_data_transform(hid_t plist_id, const char *expression) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */ herr_t ret_value = SUCCEED; /* return value */ @@ -1004,10 +1003,10 @@ H5Pset_data_transform(hid_t plist_id, const char *expression) ssize_t H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */ size_t len; - const char * pexp; + const char *pexp; ssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) @@ -1030,7 +1029,7 @@ H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size) /* Copy into application buffer */ len = HDstrlen(pexp); if (expression) { - HDstrncpy(expression, pexp, MIN(len + 1, size)); + HDstrncpy(expression, pexp, size); if (len >= size) expression[size - 1] = '\0'; } /* end if */ @@ -1732,7 +1731,7 @@ static herr_t H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size) { const H5FD_mpio_xfer_t *xfer_mode = (const H5FD_mpio_xfer_t *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1769,7 +1768,7 @@ static herr_t H5P__dxfr_io_xfer_mode_dec(const void **_pp, void *_value) { H5FD_mpio_xfer_t *xfer_mode = (H5FD_mpio_xfer_t *)_value; /* I/O transfer mode */ - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1914,7 +1913,7 @@ static herr_t H5P__dxfr_mpio_chunk_opt_hard_dec(const void **_pp, void *_value) { H5FD_mpio_chunk_opt_t *chunk_opt = (H5FD_mpio_chunk_opt_t *)_value; /* MPI-I/O chunk optimization mode */ - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1968,7 +1967,7 @@ H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode /*------------------------------------------------------------------------- * Function: H5Pget_mpio_actual_io_mode * - * Purpose: Retrieves the type of I/O actually preformed when collective I/O + * Purpose: Retrieves the type of I/O actually performed when collective I/O * is requested. * * Return: Non-negative on success/Negative on failure @@ -2057,7 +2056,7 @@ static herr_t H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size) { const H5Z_EDC_t *check = (const H5Z_EDC_t *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -2093,7 +2092,7 @@ H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__dxfr_edc_dec(const void **_pp, void *_value) { - H5Z_EDC_t * check = (H5Z_EDC_t *)_value; /* EDC property */ + H5Z_EDC_t *check = (H5Z_EDC_t *)_value; /* EDC property */ const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index 5b0ecb6f8aa..1ec662a879a 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -48,7 +47,7 @@ typedef struct { hbool_t encode; /* Whether the property list should be encoded */ size_t *enc_size_ptr; /* Pointer to size of encoded buffer */ - void ** pp; /* Pointer to encoding buffer pointer */ + void **pp; /* Pointer to encoding buffer pointer */ } H5P_enc_iter_ud_t; /********************/ @@ -333,7 +332,7 @@ H5P__encode_cb(H5P_genprop_t *prop, void *_udata) /* Encode (or not, if the 'encode' flag is off) the property's name */ prop_name_len = HDstrlen(prop->name) + 1; if (udata->encode) { - HDstrncpy((char *)*(udata->pp), prop->name, prop_name_len); + HDstrcpy((char *)*(udata->pp), prop->name); *(uint8_t **)(udata->pp) += prop_name_len; } /* end if */ *(udata->enc_size_ptr) += prop_name_len; @@ -376,7 +375,7 @@ herr_t H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, size_t *nalloc) { H5P_enc_iter_ud_t udata; /* User data for property iteration callback */ - uint8_t * p = (uint8_t *)buf; /* Temporary pointer to encoding buffer */ + uint8_t *p = (uint8_t *)buf; /* Temporary pointer to encoding buffer */ int idx; /* Index of property to start at */ size_t encode_size = 0; /* Size of buffer needed to encode properties */ hbool_t encode = TRUE; /* Whether the property list should be encoded */ @@ -442,7 +441,7 @@ H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, size_t herr_t H5P__decode_size_t(const void **_pp, void *_value) { - size_t * value = (size_t *)_value; /* Property value to return */ + size_t *value = (size_t *)_value; /* Property value to return */ const uint8_t **pp = (const uint8_t **)_pp; uint64_t enc_value; /* Decoded property value */ unsigned enc_size; /* Size of encoded property */ @@ -482,7 +481,7 @@ H5P__decode_size_t(const void **_pp, void *_value) herr_t H5P__decode_hsize_t(const void **_pp, void *_value) { - hsize_t * value = (hsize_t *)_value; /* Property value to return */ + hsize_t *value = (hsize_t *)_value; /* Property value to return */ const uint8_t **pp = (const uint8_t **)_pp; uint64_t enc_value; /* Decoded property value */ unsigned enc_size; /* Size of encoded property */ @@ -522,7 +521,7 @@ H5P__decode_hsize_t(const void **_pp, void *_value) herr_t H5P__decode_unsigned(const void **_pp, void *_value) { - unsigned * value = (unsigned *)_value; /* Property value to return */ + unsigned *value = (unsigned *)_value; /* Property value to return */ const uint8_t **pp = (const uint8_t **)_pp; unsigned enc_size; /* Size of encoded property */ herr_t ret_value = SUCCEED; /* Return value */ @@ -561,7 +560,7 @@ H5P__decode_unsigned(const void **_pp, void *_value) herr_t H5P__decode_uint8_t(const void **_pp, void *_value) { - uint8_t * value = (uint8_t *)_value; /* Property value to return */ + uint8_t *value = (uint8_t *)_value; /* Property value to return */ const uint8_t **pp = (const uint8_t **)_pp; herr_t ret_value = SUCCEED; /* Return value */ @@ -594,7 +593,7 @@ H5P__decode_uint8_t(const void **_pp, void *_value) herr_t H5P__decode_hbool_t(const void **_pp, void *_value) { - hbool_t * value = (hbool_t *)_value; /* Property value to return */ + hbool_t *value = (hbool_t *)_value; /* Property value to return */ const uint8_t **pp = (const uint8_t **)_pp; herr_t ret_value = SUCCEED; /* Return value */ @@ -627,7 +626,7 @@ H5P__decode_hbool_t(const void **_pp, void *_value) herr_t H5P__decode_double(const void **_pp, void *_value) { - double * value = (double *)_value; /* Property value to return */ + double *value = (double *)_value; /* Property value to return */ const uint8_t **pp = (const uint8_t **)_pp; unsigned enc_size; /* Size of encoded property */ herr_t ret_value = SUCCEED; /* Return value */ @@ -663,7 +662,7 @@ H5P__decode_double(const void **_pp, void *_value) on failure. DESCRIPTION Decodes a property list from a binary buffer. The contents of the buffer - contain the values for the correponding properties of the plist. The decode + contain the values for the corresponding properties of the plist. The decode callback of a certain property decodes its value from the buffer and sets it in the property list. GLOBAL VARIABLES @@ -676,9 +675,9 @@ H5P__decode_double(const void **_pp, void *_value) hid_t H5P__decode(const void *buf) { - H5P_genplist_t * plist; /* Property list to decode into */ - void * value_buf = NULL; /* Pointer to buffer to use when decoding values */ - const uint8_t * p = (const uint8_t *)buf; /* Current pointer into buffer */ + H5P_genplist_t *plist; /* Property list to decode into */ + void *value_buf = NULL; /* Pointer to buffer to use when decoding values */ + const uint8_t *p = (const uint8_t *)buf; /* Current pointer into buffer */ H5P_plist_type_t type; /* Type of encoded property list */ hid_t plist_id = -1; /* ID of new property list */ size_t value_buf_size = 0; /* Size of current value buffer */ @@ -713,7 +712,7 @@ H5P__decode(const void *buf) /* Loop over encoded properties, deserializing their values */ while (p) { H5P_genprop_t *prop; /* Pointer to property with same name */ - const char * name; /* Pointer to property list name */ + const char *name; /* Pointer to property list name */ /* Check for end of serialized list of properties */ if (0 == *p) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index a7f84fbe1fb..655eb470f73 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -481,7 +480,7 @@ static const hbool_t H5F_def_null_fsm_addr_g = static const hbool_t H5F_def_use_mdc_logging_g = H5F_ACS_USE_MDC_LOGGING_DEF; /* Default metadata cache logging flag */ -static const char * H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */ +static const char *H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */ static const hbool_t H5F_def_start_mdc_log_on_access_g = H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF; /* Default mdc log start on access flag */ static const hbool_t H5F_def_evict_on_close_flag_g = @@ -500,7 +499,7 @@ static const size_t H5F_def_page_buf_size_g = H5F_ACS_PAGE_BUFFER_SIZE_DEF; /* static const unsigned H5F_def_page_buf_min_meta_perc_g = H5F_ACS_PAGE_BUFFER_MIN_META_PERC_DEF; /* Default page buffer minimum metadata size */ static const unsigned H5F_def_page_buf_min_raw_perc_g = - H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer mininum raw data size */ + H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF; /* Default page buffer minimum raw data size */ static const hbool_t H5F_def_use_file_locking_g = H5F_ACS_USE_FILE_LOCKING_DEF; /* Default use file locking flag */ static const hbool_t H5F_def_ignore_disabled_file_locks_g = @@ -903,7 +902,7 @@ H5Pget_alignment(hid_t fapl_id, hsize_t *threshold /*out*/, hsize_t *alignment / * * Purpose: Set the file driver (DRIVER_ID) for a file access * property list (PLIST_ID) and supply an optional - * struct containing the driver-specific properites + * struct containing the driver-specific properties * (DRIVER_INFO). The driver properties will be copied into the * property list and the reference count on the driver will be * incremented, allowing the caller to close the driver ID but @@ -950,7 +949,7 @@ H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_drive * * Purpose: Set the file driver (DRIVER_ID) for a file access * property list (PLIST_ID) and supply an optional - * struct containing the driver-specific properites + * struct containing the driver-specific properties * (DRIVER_INFO). The driver properties will be copied into the * property list and the reference count on the driver will be * incremented, allowing the caller to close the driver ID but @@ -1134,7 +1133,7 @@ const void * H5Pget_driver_info(hid_t plist_id) { H5P_genplist_t *plist = NULL; /* Property list pointer */ - const void * ret_value = NULL; /* Return value */ + const void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE1("*x", "i", plist_id); @@ -1186,7 +1185,7 @@ H5P__file_driver_copy(void *value) /* Copy driver info, if it exists */ if (info->driver_info) { H5FD_class_t *driver; /* Pointer to driver */ - void * new_pl; /* Copy of driver info */ + void *new_pl; /* Copy of driver info */ /* Retrieve the driver for the ID */ if (NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) @@ -2166,7 +2165,7 @@ H5Pget_meta_block_size(hid_t plist_id, hsize_t *size /*out*/) /*------------------------------------------------------------------------- * Function: H5Pset_sieve_buf_size * - * Purpose: Sets the maximum size of the data seive buffer used for file + * Purpose: Sets the maximum size of the data sieve buffer used for file * drivers which are capable of using data sieving. The data sieve * buffer is used when performing I/O on datasets in the file. Using a * buffer which is large anough to hold several pieces of the dataset @@ -2347,7 +2346,7 @@ H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size /*out*/) * * Currently, the only two valid combinations for this routine are: * LOW = H5F_FORMAT_EARLIEST and HIGH = H5F_FORMAT_LATEST (the default - * setting, which creates objects with the ealiest version possible for + * setting, which creates objects with the earliest version possible for * each object, but no upper limit on the version allowed to be created if * a newer version of an object's format is required to support a feature * requested with an HDF5 library API routine), and LOW = H5F_FORMAT_LATEST @@ -2363,7 +2362,7 @@ H5Pget_small_data_block_size(hid_t plist_id, hsize_t *size /*out*/) * Note: Eventually we want to add more values to the H5F_libver_t * enumerated type that indicate library release values where the file * format was changed (like "H5F_FORMAT_1_2_0" for the file format changes - * in the 1.2.x release branch and possily even "H5F_FORMAT_1_4_2" for + * in the 1.2.x release branch and possibly even "H5F_FORMAT_1_4_2" for * a change mid-way through the 1.4.x release branch, etc). * * Adding more values will allow applications to make settings like the @@ -2583,14 +2582,14 @@ H5Pget_elink_file_cache_size(hid_t plist_id, unsigned *efc_size) * Return: Non-negative on success/Negative on failure * * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Thursday, August 11, 2011 * *------------------------------------------------------------------------- */ herr_t H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) { - H5P_genplist_t * fapl; /* Property list pointer */ + H5P_genplist_t *fapl; /* Property list pointer */ H5FD_file_image_info_t image_info; /* File image info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2680,14 +2679,14 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) * Return: Non-negative on success/Negative on failure * * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Thursday, August 11, 2011 * *------------------------------------------------------------------------- */ herr_t H5Pget_file_image(hid_t fapl_id, void **buf, size_t *buf_len) { - H5P_genplist_t * fapl; /* Property list pointer */ + H5P_genplist_t *fapl; /* Property list pointer */ H5FD_file_image_info_t image_info; /* File image info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2755,14 +2754,14 @@ H5Pget_file_image(hid_t fapl_id, void **buf, size_t *buf_len) * Return: Non-negative on success/Negative on failure * * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Thursday, August 11, 2011 * *------------------------------------------------------------------------- */ herr_t H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks_ptr) { - H5P_genplist_t * fapl; /* Property list pointer */ + H5P_genplist_t *fapl; /* Property list pointer */ H5FD_file_image_info_t info; /* File image info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2809,7 +2808,7 @@ H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callback HDassert(callbacks_ptr->udata_copy); HDassert(callbacks_ptr->udata_free); if ((info.callbacks.udata = callbacks_ptr->udata_copy(callbacks_ptr->udata)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy the suppplied udata") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't copy the supplied udata") } /* end if */ /* Set values */ @@ -2831,14 +2830,14 @@ H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callback * Return: Non-negative on success/Negative on failure * * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Thursday, August 11, 2011 * *------------------------------------------------------------------------- */ herr_t H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callbacks) { - H5P_genplist_t * fapl; /* Property list pointer */ + H5P_genplist_t *fapl; /* Property list pointer */ H5FD_file_image_info_t info; /* File image info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3126,7 +3125,7 @@ static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value) { H5AC_cache_image_config_t *config = (H5AC_cache_image_config_t *)_value; - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; unsigned enc_size; herr_t ret_value = SUCCEED; /* Return value */ @@ -3233,7 +3232,7 @@ H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U * Return: Non-negative on success/Negative on failure * * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Thursday, August 11, 2011 * *------------------------------------------------------------------------- */ @@ -3263,7 +3262,7 @@ H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_U * Return: Non-negative on success/Negative on failure * * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Thursday, August 11, 2011 * *------------------------------------------------------------------------- */ @@ -3362,7 +3361,7 @@ H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, size_t H5_ * Return: Non-negative on success/Negative on failure * * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Thursday, August 11, 2011 * *------------------------------------------------------------------------- */ @@ -3714,7 +3713,7 @@ static herr_t H5P__facc_cache_config_dec(const void **_pp, void *_value) { H5AC_cache_config_t *config = (H5AC_cache_config_t *)_value; - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; unsigned enc_size; uint64_t enc_value; herr_t ret_value = SUCCEED; /* Return value */ @@ -3886,7 +3885,7 @@ static herr_t H5P__facc_fclose_degree_dec(const void **_pp, void *_value) { H5F_close_degree_t *fclose_degree = (H5F_close_degree_t *)_value; /* File close degree */ - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3920,7 +3919,7 @@ static herr_t H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size) { const H5FD_mem_t *type = (const H5FD_mem_t *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3956,7 +3955,7 @@ H5P__facc_multi_type_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__facc_multi_type_dec(const void **_pp, void *_value) { - H5FD_mem_t * type = (H5FD_mem_t *)_value; /* File close degree */ + H5FD_mem_t *type = (H5FD_mem_t *)_value; /* File close degree */ const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -3990,7 +3989,7 @@ static herr_t H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) { const H5F_libver_t *type = (const H5F_libver_t *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -4025,7 +4024,7 @@ H5P__facc_libver_type_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__facc_libver_type_dec(const void **_pp, void *_value) { - H5F_libver_t * type = (H5F_libver_t *)_value; + H5F_libver_t *type = (H5F_libver_t *)_value; const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -4139,7 +4138,7 @@ H5Pget_metadata_read_attempts(hid_t plist_id, unsigned *attempts /*out*/) herr_t H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5F_object_flush_t flush_info; herr_t ret_value = SUCCEED; /* return value */ @@ -4182,7 +4181,7 @@ H5Pset_object_flush_cb(hid_t plist_id, H5F_flush_cb_t func, void *udata) herr_t H5Pget_object_flush_cb(hid_t plist_id, H5F_flush_cb_t *func, void **udata) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5F_object_flush_t flush_info; herr_t ret_value = SUCCEED; /* return value */ @@ -4220,7 +4219,7 @@ herr_t H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, hbool_t start_on_access) { H5P_genplist_t *plist; /* Property list pointer */ - char * new_location; /* Working location pointer */ + char *new_location; /* Working location pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -4266,7 +4265,7 @@ H5Pget_mdc_log_options(hid_t plist_id, hbool_t *is_enabled, char *location, size hbool_t *start_on_access) { H5P_genplist_t *plist; /* Property list pointer */ - char * location_ptr = NULL; /* Pointer to location string */ + char *location_ptr = NULL; /* Pointer to location string */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -4321,7 +4320,7 @@ static herr_t H5P__facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size) { const char *log_location = *(const char *const *)value; - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; size_t len = 0; uint64_t enc_value; unsigned enc_size; @@ -4372,7 +4371,7 @@ H5P__facc_mdc_log_location_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__facc_mdc_log_location_dec(const void **_pp, void *_value) { - char ** log_location = (char **)_value; + char **log_location = (char **)_value; const uint8_t **pp = (const uint8_t **)_pp; size_t len; uint64_t enc_value; /* Decoded property value */ @@ -4705,7 +4704,7 @@ herr_t H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size) { const H5P_coll_md_read_flag_t *coll_md_read_flag = (const H5P_coll_md_read_flag_t *)value; - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_PACKAGE_NOERR @@ -4742,7 +4741,7 @@ herr_t H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value) { H5P_coll_md_read_flag_t *coll_md_read_flag = (H5P_coll_md_read_flag_t *)_value; /* File close degree */ - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -4762,15 +4761,14 @@ H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value) * Function: H5Pset_all_coll_metadata_ops * * Purpose: Tell the library whether the metadata read operations will - * be done collectively (1) or not (0). Default is independent. - * With collective mode, the library will optimize access to - * metadata operations on the file. + * be done collectively (1) or not (0). Default is independent. + * With collective mode, the library will optimize access to + * metadata operations on the file. * * Note: This routine accepts file access property lists, link - * access property lists, attribute access property lists, - * dataset access property lists, group access property lists, - * named datatype access property lists, - * and dataset transfer property lists. + * access property lists, attribute access property lists, + * dataset access property lists, group access property lists + * and named datatype access property lists. * * Return: Non-negative on success/Negative on failure * @@ -4782,7 +4780,7 @@ H5P__decode_coll_md_read_flag_t(const void **_pp, void *_value) herr_t H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5P_coll_md_read_flag_t coll_meta_read; /* Property value */ herr_t ret_value = SUCCEED; /* return value */ @@ -4790,11 +4788,10 @@ H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) H5TRACE2("e", "ib", plist_id, is_collective); /* Compare the property list's class against the other class */ - /* (Dataset, group, attribute, and named datype access property lists + /* (Dataset, group, attribute, and named datatype 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 */ @@ -4821,10 +4818,9 @@ H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective) * Purpose: Gets information about collective metadata read mode. * * Note: This routine accepts file access property lists, link - * access property lists, attribute access property lists, - * dataset access property lists, group access property lists, - * named datatype access property lists, - * and dataset transfer property lists. + * access property lists, attribute access property lists, + * dataset access property lists, group access property lists, + * and named datatype access property lists. * * Return: Non-negative on success/Negative on failure * @@ -4842,11 +4838,10 @@ H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective) H5TRACE2("e", "i*b", plist_id, is_collective); /* Compare the property list's class against the other class */ - /* (Dataset, group, attribute, and named datype access property lists + /* (Dataset, group, attribute, and named datatype 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 */ @@ -5670,7 +5665,7 @@ H5Pget_vol_info(hid_t plist_id, void **vol_info) /* Get the current VOL info */ if (TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - void * new_connector_info = NULL; /* Copy of connector info */ + void *new_connector_info = NULL; /* Copy of connector info */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ /* Get the connector property */ @@ -5853,7 +5848,7 @@ H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED const H5VL_connector_prop_t *info1 = (const H5VL_connector_prop_t *)_info1; /* Create local aliases for values */ const H5VL_connector_prop_t *info2 = (const H5VL_connector_prop_t *)_info2; - H5VL_class_t * cls1, *cls2; /* connector class for each property */ + H5VL_class_t *cls1, *cls2; /* connector class for each property */ int cmp_value = 0; /* Value from comparison */ herr_t H5_ATTR_NDEBUG_UNUSED status; /* Status from info comparison */ int ret_value = 0; /* Return value */ diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index 5006b9abd40..e990e2db415 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -696,7 +695,7 @@ static herr_t H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) { const unsigned *btree_k = (const unsigned *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -741,7 +740,7 @@ H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__fcrt_btree_rank_dec(const void **_pp, void *_value) { - unsigned * btree_k = (unsigned *)_value; + unsigned *btree_k = (unsigned *)_value; const uint8_t **pp = (const uint8_t **)_pp; unsigned enc_size; /* Size of encoded property */ unsigned u; /* Local index variable */ @@ -983,7 +982,7 @@ static herr_t H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) { const unsigned *type_flags = (const unsigned *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1029,7 +1028,7 @@ H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__fcrt_shmsg_index_types_dec(const void **_pp, void *_value) { - unsigned * type_flags = (unsigned *)_value; + unsigned *type_flags = (unsigned *)_value; const uint8_t **pp = (const uint8_t **)_pp; unsigned enc_size; /* Size of encoded property */ unsigned u; /* Local index variable */ @@ -1074,7 +1073,7 @@ static herr_t H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) { const unsigned *minsizes = (const unsigned *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -1120,7 +1119,7 @@ H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *_value) { - unsigned * minsizes = (unsigned *)_value; + unsigned *minsizes = (unsigned *)_value; const uint8_t **pp = (const uint8_t **)_pp; unsigned enc_size; /* Size of encoded property */ unsigned u; /* Local index variable */ @@ -1389,7 +1388,7 @@ static herr_t H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value) { H5F_fspace_strategy_t *strategy = (H5F_fspace_strategy_t *)_value; /* Free-space strategy */ - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Pfmpl.c b/src/H5Pfmpl.c index b8dab907bc6..c2523c28ebb 100644 --- a/src/H5Pfmpl.c +++ b/src/H5Pfmpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 5df73a146c0..564afcc3f77 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -530,7 +529,7 @@ static herr_t H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size) { const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)value; /* Create local aliases for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -565,7 +564,7 @@ H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__gcrt_group_info_dec(const void **_pp, void *_value) { - H5O_ginfo_t * ginfo = (H5O_ginfo_t *)_value; /* Group info settings */ + H5O_ginfo_t *ginfo = (H5O_ginfo_t *)_value; /* Group info settings */ const uint8_t **pp = (const uint8_t **)_pp; herr_t ret_value = SUCCEED; /* Return value */ @@ -615,7 +614,7 @@ static herr_t H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size) { const H5O_linfo_t *linfo = (const H5O_linfo_t *)value; /* Create local aliases for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -655,7 +654,7 @@ H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__gcrt_link_info_dec(const void **_pp, void *_value) { - H5O_linfo_t * linfo = (H5O_linfo_t *)_value; /* Link info settings */ + H5O_linfo_t *linfo = (H5O_linfo_t *)_value; /* Link info settings */ const uint8_t **pp = (const uint8_t **)_pp; unsigned crt_order_flags; unsigned enc_size; diff --git a/src/H5Pint.c b/src/H5Pint.c index f66e2b99ec4..e04f065ea83 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -47,25 +46,25 @@ /* Typedef for checking for duplicate class names in parent class */ typedef struct { const H5P_genclass_t *parent; /* Pointer to parent class */ - const char * name; /* Pointer to name to check */ - H5P_genclass_t * new_class; /* Pointer to class during path traversal */ + const char *name; /* Pointer to name to check */ + H5P_genclass_t *new_class; /* Pointer to class during path traversal */ } H5P_check_class_t; /* Typedef for property list iterator callback */ typedef struct { H5P_iterate_int_t cb_func; /* Iterator callback */ - void * udata; /* Iterator callback pointer */ + void *udata; /* Iterator callback pointer */ const H5P_genplist_t *plist; /* Property list pointer */ - H5SL_t * seen; /* Skip list to hold names of properties already seen */ - int * curr_idx_ptr; /* Pointer to current iteration index */ + H5SL_t *seen; /* Skip list to hold names of properties already seen */ + int *curr_idx_ptr; /* Pointer to current iteration index */ int prev_idx; /* Previous iteration index */ } H5P_iter_plist_ud_t; /* Typedef for property list class iterator callback */ typedef struct { H5P_iterate_int_t cb_func; /* Iterator callback */ - void * udata; /* Iterator callback pointer */ - int * curr_idx_ptr; /* Pointer to current iteration index */ + void *udata; /* Iterator callback pointer */ + int *curr_idx_ptr; /* Pointer to current iteration index */ int prev_idx; /* Previous iteration index */ } H5P_iter_pclass_ud_t; @@ -97,19 +96,19 @@ typedef herr_t (*H5P_do_pclass_op_t)(H5P_genplist_t *plist, const char *name, H5 /* General helper routines */ static H5P_genplist_t *H5P__create(H5P_genclass_t *pclass); -static H5P_genprop_t * H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, +static H5P_genprop_t *H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, const void *value, H5P_prp_create_func_t prp_create, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); -static H5P_genprop_t * H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type); +static H5P_genprop_t *H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type); static herr_t H5P__free_prop(H5P_genprop_t *prop); static int H5P__cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2); static herr_t H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op, H5P_do_pclass_op_t pclass_op, void *udata); static int H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key); -static H5P_genprop_t * H5P__find_prop_pclass(H5P_genclass_t *pclass, const char *name); +static H5P_genprop_t *H5P__find_prop_pclass(H5P_genclass_t *pclass, const char *name); static herr_t H5P__free_prop_cb(void *item, void H5_ATTR_UNUSED *key, void *op_data); static herr_t H5P__free_del_name_cb(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op_data); @@ -646,7 +645,7 @@ H5P_term_package(void) static herr_t H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) { - void * tmp_value = NULL; /* Temporary value buffer */ + void *tmp_value = NULL; /* Temporary value buffer */ H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ herr_t ret_value = SUCCEED; /* Return value */ @@ -715,7 +714,7 @@ H5P_genclass_t * H5P__copy_pclass(H5P_genclass_t *pclass) { H5P_genclass_t *new_pclass = NULL; /* Property list class copied */ - H5P_genprop_t * pcopy; /* Copy of property to insert into class */ + H5P_genprop_t *pcopy; /* Copy of property to insert into class */ H5P_genclass_t *ret_value = NULL; /* return value */ FUNC_ENTER_PACKAGE @@ -791,11 +790,11 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *new_plist = NULL; /* New property list generated from copy */ - H5P_genprop_t * tmp; /* Temporary pointer to properties */ - H5P_genprop_t * new_prop; /* New property created for copy */ + H5P_genprop_t *tmp; /* Temporary pointer to properties */ + H5P_genprop_t *new_prop; /* New property created for copy */ hid_t new_plist_id; /* Property list ID of new list created */ - H5SL_node_t * curr_node; /* Current node in skip list */ - H5SL_t * seen = NULL; /* Skip list containing properties already seen */ + H5SL_node_t *curr_node; /* Current node in skip list */ + H5SL_t *seen = NULL; /* Skip list containing properties already seen */ size_t nseen; /* Number of items 'seen' */ hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ hid_t ret_value = H5I_INVALID_HID; /* return value */ @@ -1548,7 +1547,7 @@ H5P__access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod) static int H5P__open_class_path_cb(void *_obj, hid_t H5_ATTR_UNUSED id, void *_key) { - H5P_genclass_t * obj = (H5P_genclass_t *)_obj; /* Pointer to the class for this ID */ + H5P_genclass_t *obj = (H5P_genclass_t *)_obj; /* Pointer to the class for this ID */ H5P_check_class_t *key = (H5P_check_class_t *)_key; /* Pointer to key information for comparison */ int ret_value = 0; /* Return value */ @@ -1703,8 +1702,8 @@ H5P__create(H5P_genclass_t *pclass) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *plist = NULL; /* New property list created */ - H5P_genprop_t * tmp; /* Temporary pointer to parent class properties */ - H5SL_t * seen = NULL; /* Skip list to hold names of properties already seen */ + H5P_genprop_t *tmp; /* Temporary pointer to parent class properties */ + H5SL_t *seen = NULL; /* Skip list to hold names of properties already seen */ H5P_genplist_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -2645,7 +2644,7 @@ H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op H5P_do_pclass_op_t pclass_op, void *udata) { H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genprop_t * prop; /* Temporary property pointer */ + H5P_genprop_t *prop; /* Temporary property pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2772,7 +2771,7 @@ H5P__poke_pclass_cb(H5P_genplist_t *plist, const char H5_ATTR_NDEBUG_UNUSED *nam void *_udata) { H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ - H5P_genprop_t * pcopy = NULL; /* Copy of property to insert into skip list */ + H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2877,8 +2876,8 @@ static herr_t H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void *_udata) { H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ - void * tmp_value = NULL; /* Temporary value for property */ - const void * prp_value = NULL; /* Property value */ + void *tmp_value = NULL; /* Temporary value for property */ + const void *prp_value = NULL; /* Property value */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2953,9 +2952,9 @@ static herr_t H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void *_udata) { H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ - H5P_genprop_t * pcopy = NULL; /* Copy of property to insert into skip list */ - void * tmp_value = NULL; /* Temporary value for property */ - const void * prp_value = NULL; /* Property value */ + H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ + void *tmp_value = NULL; /* Temporary value for property */ + const void *prp_value = NULL; /* Property value */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -3176,7 +3175,7 @@ H5P__class_set(const H5P_genclass_t *pclass, const char *name, const void *value NAME H5P_exist_plist PURPOSE - Internal routine to query the existance of a property in a property list. + Internal routine to query the existence of a property in a property list. USAGE htri_t H5P_exist_plist(plist, name) const H5P_genplist_t *plist; IN: Property list to check @@ -3235,7 +3234,7 @@ H5P_exist_plist(const H5P_genplist_t *plist, const char *name) NAME H5P__exist_pclass PURPOSE - Internal routine to query the existance of a property in a property class. + Internal routine to query the existence of a property in a property class. USAGE herr_t H5P__exist_pclass(pclass, name) H5P_genclass_t *pclass; IN: Property class to check @@ -3751,7 +3750,7 @@ H5P__cmp_plist_cb(H5P_genprop_t *prop, void *_udata) /* Check if the property exists in the second property list */ if ((prop2_exist = H5P_exist_plist(udata->plist2, prop->name)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5_ITER_ERROR, "can't lookup existance of property?") + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5_ITER_ERROR, "can't lookup existence of property?") if (prop2_exist) { const H5P_genprop_t *prop2; /* Pointer to property in second plist */ @@ -4020,8 +4019,8 @@ property list. static int H5P__iterate_plist_cb(void *_item, void *_key, void *_udata) { - H5P_genprop_t * item = (H5P_genprop_t *)_item; /* Pointer to the property */ - char * key = (char *)_key; /* Pointer to the property's name */ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char *key = (char *)_key; /* Pointer to the property's name */ H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ int ret_value = H5_ITER_CONT; /* Return value */ @@ -4073,8 +4072,8 @@ deleted, and then chains to the property list callback. static int H5P__iterate_plist_pclass_cb(void *_item, void *_key, void *_udata) { - H5P_genprop_t * item = (H5P_genprop_t *)_item; /* Pointer to the property */ - char * key = (char *)_key; /* Pointer to the property's name */ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char *key = (char *)_key; /* Pointer to the property's name */ H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ int ret_value = H5_ITER_CONT; /* Return value */ @@ -4151,9 +4150,9 @@ int H5P__iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop, int *idx, H5P_iterate_int_t cb_func, void *udata) { - H5P_genclass_t * tclass; /* Temporary class pointer */ + H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_iter_plist_ud_t udata_int; /* User data for skip list iterator */ - H5SL_t * seen = NULL; /* Skip list to hold names of properties already seen */ + H5SL_t *seen = NULL; /* Skip list to hold names of properties already seen */ int curr_idx = 0; /* Current iteration index */ int ret_value = 0; /* Return value */ @@ -4232,7 +4231,7 @@ property list class. static int H5P__iterate_pclass_cb(void *_item, void H5_ATTR_NDEBUG_UNUSED *_key, void *_udata) { - H5P_genprop_t * item = (H5P_genprop_t *)_item; /* Pointer to the property */ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ H5P_iter_pclass_ud_t *udata = (H5P_iter_pclass_ud_t *)_udata; /* Pointer to user data */ int ret_value = 0; /* Return value */ @@ -4459,7 +4458,7 @@ static herr_t H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void *_udata) { H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ - void * tmp_value = NULL; /* Temporary value for property */ + void *tmp_value = NULL; /* Temporary value for property */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4573,7 +4572,7 @@ H5P_get(H5P_genplist_t *plist, const char *name, void *value) static herr_t H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void H5_ATTR_UNUSED *_udata) { - char * del_name = NULL; /* Pointer to deleted name */ + char *del_name = NULL; /* Pointer to deleted name */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4641,8 +4640,8 @@ H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, static herr_t H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, void H5_ATTR_UNUSED *_udata) { - char * del_name = NULL; /* Pointer to deleted name */ - void * tmp_value = NULL; /* Temporary value for property */ + char *del_name = NULL; /* Pointer to deleted name */ + void *tmp_value = NULL; /* Temporary value for property */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -4702,7 +4701,7 @@ H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, Returns non-negative on success, negative on failure. DESCRIPTION Removes a property from a property list. Both properties which were - in existance when the property list was created (i.e. properties registered + in existence when the property list was created (i.e. properties registered with H5Pregister2) and properties added to the list after it was created (i.e. added with H5Pinsert2) may be removed from a property list. Properties do not need to be removed a property list before the list itself @@ -4770,8 +4769,8 @@ H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) { H5P_genplist_t *dst_plist; /* Pointer to destination property list */ H5P_genplist_t *src_plist; /* Pointer to source property list */ - H5P_genprop_t * prop; /* Temporary property pointer */ - H5P_genprop_t * new_prop = NULL; /* Pointer to new property */ + H5P_genprop_t *prop; /* Temporary property pointer */ + H5P_genprop_t *new_prop = NULL; /* Pointer to new property */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -4783,7 +4782,7 @@ H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_id))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist") - /* If the property exists in the destination alread */ + /* If the property exists in the destination already */ if (NULL != H5P__find_prop_plist(dst_plist, name)) { /* Delete the property from the destination list, calling the 'close' callback if necessary */ if (H5P_remove(dst_plist, name) < 0) @@ -4880,7 +4879,7 @@ H5P__copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name) H5P_genclass_t *src_pclass; /* Source property class, containing property to copy */ H5P_genclass_t *dst_pclass; /* Destination property class */ H5P_genclass_t *orig_dst_pclass; /* Original destination property class */ - H5P_genprop_t * prop; /* Temporary property pointer */ + H5P_genprop_t *prop; /* Temporary property pointer */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_PACKAGE @@ -5014,12 +5013,12 @@ H5P_close(void *_plist) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *plist = (H5P_genplist_t *)_plist; - H5SL_t * seen = NULL; /* Skip list to hold names of properties already seen */ + H5SL_t *seen = NULL; /* Skip list to hold names of properties already seen */ size_t nseen; /* Number of items 'seen' */ hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ size_t ndel; /* Number of items deleted */ - H5SL_node_t * curr_node; /* Current node in skip list */ - H5P_genprop_t * tmp; /* Temporary pointer to properties */ + H5SL_node_t *curr_node; /* Current node in skip list */ + H5P_genprop_t *tmp; /* Temporary pointer to properties */ unsigned make_cb = 0; /* Operator data for property free callback */ herr_t ret_value = SUCCEED; /* return value */ @@ -5279,12 +5278,12 @@ H5P__get_class_path(H5P_genclass_t *pclass) H5P_genclass_t * H5P__open_class_path(const char *path) { - char * tmp_path = NULL; /* Temporary copy of the path */ - char * curr_name; /* Pointer to current component of path name */ - char * delimit; /* Pointer to path delimiter during traversal */ - H5P_genclass_t * curr_class; /* Pointer to class during path traversal */ + char *tmp_path = NULL; /* Temporary copy of the path */ + char *curr_name; /* Pointer to current component of path name */ + char *delimit; /* Pointer to path delimiter during traversal */ + H5P_genclass_t *curr_class; /* Pointer to class during path traversal */ H5P_check_class_t check_info; /* Structure to hold the information for checking duplicate names */ - H5P_genclass_t * ret_value = NULL; /* Return value */ + H5P_genclass_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 75fea42787a..4a90223ac2a 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -160,7 +159,7 @@ const H5P_libclass_t H5P_CLS_LACC[1] = {{ /* Property value defaults */ static const size_t H5L_def_nlinks_g = H5L_ACS_NLINKS_DEF; /* Default number of soft links to traverse */ -static const char * H5L_def_elink_prefix_g = +static const char *H5L_def_elink_prefix_g = H5L_ACS_ELINK_PREFIX_DEF; /* Default external link prefix string */ static const hid_t H5L_def_fapl_id_g = H5L_ACS_ELINK_FAPL_DEF; /* Default fapl for external link access */ static const unsigned H5L_def_elink_flags_g = @@ -337,8 +336,8 @@ H5P__lacc_elink_fapl_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED static herr_t H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) { - const hid_t * elink_fapl = (const hid_t *)value; /* Property to encode */ - uint8_t ** pp = (uint8_t **)_pp; + const hid_t *elink_fapl = (const hid_t *)value; /* Property to encode */ + uint8_t **pp = (uint8_t **)_pp; H5P_genplist_t *fapl_plist; /* Pointer to property list */ hbool_t non_default_fapl = FALSE; /* Whether the FAPL is non-default */ size_t fapl_size = 0; /* FAPL's encoded size */ @@ -408,7 +407,7 @@ H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) { - hid_t * elink_fapl = (hid_t *)_value; /* The elink FAPL value */ + hid_t *elink_fapl = (hid_t *)_value; /* The elink FAPL value */ const uint8_t **pp = (const uint8_t **)_pp; hbool_t non_default_fapl; /* Whether the FAPL is non-default */ herr_t ret_value = SUCCEED; /* Return value */ @@ -542,8 +541,8 @@ H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED static int H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { - const hid_t * fapl1 = (const hid_t *)value1; - const hid_t * fapl2 = (const hid_t *)value2; + const hid_t *fapl1 = (const hid_t *)value1; + const hid_t *fapl2 = (const hid_t *)value2; H5P_genplist_t *obj1, *obj2; /* Property lists to compare */ int ret_value = 0; @@ -685,7 +684,7 @@ static herr_t H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) { const char *elink_pref = *(const char *const *)value; - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; size_t len = 0; uint64_t enc_value; unsigned enc_size; @@ -739,7 +738,7 @@ H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__lacc_elink_pref_dec(const void **_pp, void *_value) { - char ** elink_pref = (char **)_value; + char **elink_pref = (char **)_value; const uint8_t **pp = (const uint8_t **)_pp; size_t len; uint64_t enc_value; /* Decoded property value */ @@ -1024,7 +1023,7 @@ ssize_t H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size) { H5P_genplist_t *plist; /* Property list pointer */ - char * my_prefix; /* Library's copy of the prefix */ + char *my_prefix; /* Library's copy of the prefix */ size_t len; /* Length of prefix string */ ssize_t ret_value; /* Return value */ @@ -1044,7 +1043,7 @@ H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size) /* Copy to user's buffer, if given */ len = HDstrlen(my_prefix); if (prefix) { - HDstrncpy(prefix, my_prefix, MIN(len + 1, size)); + HDstrncpy(prefix, my_prefix, size); if (len >= size) prefix[size - 1] = '\0'; } /* end if */ diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index 2d7d5f5200b..d711945a10a 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Pmapl.c b/src/H5Pmapl.c index 8fdf610eb52..0697b5c0dc7 100644 --- a/src/H5Pmapl.c +++ b/src/H5Pmapl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Pmcpl.c b/src/H5Pmcpl.c index c88d0bb59b5..24cbb2346bb 100644 --- a/src/H5Pmcpl.c +++ b/src/H5Pmcpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Pmodule.h b/src/H5Pmodule.h index 18f30c682ed..04eb1246bb9 100644 --- a/src/H5Pmodule.h +++ b/src/H5Pmodule.h @@ -29,50 +29,1054 @@ #define H5_MY_PKG_ERR H5E_PLIST #define H5_MY_PKG_INIT YES -/**\defgroup H5P H5P - * \brief Property List Interface +/** \page H5P_UG Properties and Property Lists in HDF5 * - * \details The HDF5 Property List Interface provides a mechanism to take - * advantage of more powerful or unusual features in HDF5. + * \section sec_plist Properties and Property Lists in HDF5 * - * HDF5 objects have properties or characteristics associated with - * them, and there are default properties that handle the most - * common needs. These default properties can be modified using the - * HDF5 Property List Interface. For example, the data storage - * layout property of a dataset is contiguous by default. For better - * performance, the layout can be modified to be chunked or chunked - * and compressed. + * HDF5 property lists are the main vehicle to configure the + * behavior of HDF5 API functions. * - * \todo Describe concisely what the functions in this module are about. + * Typically, property lists are created by instantiating one of the built-in + * or user-defined property list classes. After adding suitable properties, + * property lists are used when opening or creating HDF5 items, or when reading + * or writing data. Property lists can be modified by adding or changing + * properties. Property lists are deleted by closing the associated handles. * - * \defgroup GPLO General Property List Operations + * \subsection subsec_plist_intro Introduction + * + * HDF5 properties and property lists make it possible to shape or modify an HDF5 file, group, + * dataset, attribute, committed datatype, or even an I/O stream, in a number of ways. For example, + * you can do any of the following: + * \li Customize the storage layout of a file to suit a project or task. + * \li Create a chunked dataset. + * \li Apply compression or filters to raw data. + * \li Use either ASCII or UTF-8 character encodings. + * \li Create missing groups on the fly. + * \li Switch between serial and parallel I/O. + * \li Create consistency within a single file or across an international project. + * + * Some properties enable an HDF5 application to take advantage of the capabilities of a specific + * computing environment while others make a file more compact; some speed the reading or + * writing of data while others enable more record-keeping at a per-object level. HDF5 offers + * nearly one hundred specific properties that can be used in literally thousands of combinations to + * maximize the usability of HDF5-stored data. + * + * At the most basic level, a property list is a collection of properties, represented by name/value + * pairs that can be passed to various HDF5 functions, usually modifying default settings. A + * property list inherits a set of properties and values from a property list class. But that statement + * hardly provides a complete picture; in the rest of this section and in the next section, + * \ref subsec_plist_class , we will discuss these things in much more detail. + * After reading that material, the reader should have a reasonably complete understanding of how + * properties and property lists can be used in HDF5 applications. + * + * + * + * + * + *
    + * \image html PropListEcosystem.gif "The HDF5 property environment" + *
    + * + * The remaining sections in this chapter discuss the following topics: + * \li What are properties, property lists, and property list classes? + * \li Property list programming model + * \li Generic property functions + * \li Summary listings of property list functions + * \li Additional resources + * + * The discussions and function listings in this chapter focus on general property operations, object + * and link properties, and related functions. + * + * File, group, dataset, datatype, and attribute properties are discussed in the chapters devoted to + * those features, where that information will be most convenient to users. For example, \ref sec_dataset + * discusses dataset creation property lists and functions, dataset access property lists and + * functions, and dataset transfer property lists and functions. This chapter does not duplicate those + * discussions. + * + * Generic property operations are an advanced feature and are beyond the scope of this guide. + * + * This chapter assumes an understanding of the following chapters of this \ref UG + * \li \ref sec_data_model + * \li \ref sec_program + * + * \subsection subsec_plist_class Property List Classes, Property Lists, and Properties + * + * HDF5 property lists and the property list interface \ref H5P provide a mechanism for storing + * characteristics of objects in an HDF5 file and economically passing them around in an HDF5 + * application. In this capacity, property lists significantly reduce the burden of additional function + * parameters throughout the HDF5 API. Another advantage of property lists is that features can + * often be added to HDF5 by adding only property list functions to the API; this is particularly true + * when all other requirements of the feature can be accomplished internally to the library. + * + * For instance, a file creation operation needs to know several things about a file, such as the size + * of the userblock or the sizes of various file data structures. Bundling this information as a + * property list simplifies the interface by reducing the number of parameters to the function + * \ref H5Fcreate. + * + * As illustrated in the figure above ("The HDF5 property environment"), the HDF5 property + * environment is a three-level hierarchy: + * \li Property list classes + * \li Property lists + * \li Properties + * + * The following subsections discuss property list classes, property lists, and properties in more detail. + * + * \subsubsection subsubsec_plist_class Property List Classes + * + * A property list class defines the roles that property lists of that class can play. Each class includes + * all properties that are valid for that class with each property set to its default value. HDF5 offers + * a property lists class for each of the following situations. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Property list classes in HDF5
    Property List ClassFor further discussion
    + * File creation (FCPL) + * + * \ref H5P_FILE_CREATE + * + * See various sections of \ref sec_file + *
    + * File access (FAPL) + * + * \ref H5P_FILE_ACCESS + * + * Used only as \ref H5P_DEFAULT. + *
    + * File mount (FMPL) + * + * \ref H5P_FILE_MOUNT + * + * For more information, see \ref FileMountProps "File Mount Properties" + *
    + * Object creation (OCPL) + * + * \ref H5P_OBJECT_CREATE + * + * See \ref OCPL + *
    + * Object copy (OCPYPL) + * + * \ref H5P_OBJECT_COPY + * + * + *
    + * Group creation (GCPL) + * + * \ref H5P_GROUP_CREATE + * + * See \ref subsec_group_program + *
    + * Group access (GAPL) + * + * \ref H5P_GROUP_ACCESS + * + * + *
    + * Link creation (LCPL) + * + * \ref H5P_LINK_CREATE + * + * See examples in \ref subsec_plist_program and \ref LCPL + *
    + * Link access (LAPL) + * + * \ref H5P_LINK_ACCESS + * + * + *
    + * Dataset creation (DCPL) + * + * \ref H5P_DATASET_CREATE + * + * See \ref subsec_dataset_program + *
    + * Dataset access (DAPL) + * + * \ref H5P_DATASET_ACCESS + * + * + *
    + * Dataset transfer (DXPL) + * + * \ref H5P_DATASET_XFER + * + * + *
    + * Datatype creation (TCPL) + * + * \ref H5P_DATATYPE_CREATE + * + * See various sections of \ref sec_datatype + *
    + * String creation (STRCPL) + * + * \ref H5P_STRING_CREATE + * + * See \ref subsec_dataset_program and \ref subsec_datatype_program + *
    + * Attribute creation (ACPL) + * + * \ref H5P_ATTRIBUTE_CREATE + * + * See \ref subsec_attribute_work. + *
    + * + * Note: In the table above, the abbreviations to the right of each property list class name in this + * table are widely used in both HDF5 programmer documentation and HDF5 source code. For + * example, \ref FCPL (FCPL) is the file creation property list, \ref OCPL (OCPL) is the object creation + * property list, \ref OCPYPL (OCPYPL) is object copy property list, and \ref STRCPL (STRCPL) is the string + * creation property list. These abbreviations may appear in either uppercase or lowercase. + * + * The “HDF5 property list class inheritance hierarchy†figure, immediately following, illustrates + * the inheritance hierarchy of HDF5’s property list classes. Properties are defined at the root of the + * HDF5 property environment (\ref PLCR in the figure below). Property list + * classes then inherit properties from that root, either directly or indirectly through a parent class. + * In every case, a property list class inherits only the properties relevant to its role. For example, + * the \ref OCPL (OCPL) inherits all properties that are relevant to the + * creation of any object while the \ref GCPL (GCPL) inherits only those + * properties that are relevant to group creation. + * + * + * + * + * + *
    + * \image html PropListClassInheritance.gif "HDF5 property list class inheritance hierarchy" + *
    + * Note: In the figure above, property list classes displayed in black are directly accessible through + * the programming interface; the root of the property environment and the \ref STRCPL and \ref OCPL + * property list classes, in gray above, are not user-accessible. The red empty set symbol indicates + * that the \ref FMPL (FMPL) is an empty class; that is, it has no set table + * properties. For more information, see \ref FileMountProps "File Mount Properties". Abbreviations + * used in this figure are defined in the preceding table, \ref table_plist "Property list classes in HDF5". + * + * \subsubsection subsubsec_plist_lists Property Lists + * + * A property list is a collection of related properties that are used together in specific + * circumstances. A new property list created from a property list class inherits the properties of the + * property list class and each property’s default value. A fresh dataset creation property list, for + * example, includes all of the HDF5 properties relevant to the creation of a new dataset. + * + * Property lists are implemented as containers holding a collection of name/value pairs. Each pair + * specifies a property name and a value for the property. A property list usually contains + * information for one to many properties. + * + * HDF5’s default property values are designed to be reasonable for general use cases. Therefore, + * an application can often use a property list without modification. On the other hand, adjusting + * property list settings is a routine action and there are many reasons for an application to do so. + * + * A new property list may either be derived from a property list class or copied from an existing + * property list. When a property list is created from a property list class, it contains all the + * properties that are relevant to the class, with each property set to its default value. A new + * property list created by copying an existing property list will contain the same properties and + * property values as the original property list. In either case, the property values can be changed as + * needed through the HDF5 API. + * + * Property lists can be freely reused to create consistency. For example, a single set of file, group, + * and dataset creation property lists might be created at the beginning of a project and used to + * create hundreds, thousands, even millions, of consistent files, file structures, and datasets over + * the project’s life. When such consistency is important to a project, this is an economical means + * of providing it. + * + * \subsubsection subsubsec_plist_props Properties + * + * A property is the basic element of the property list hierarchy. HDF5 offers nearly one hundred + * properties controlling things ranging from file access rights, to the storage layout of a dataset, + * through optimizing the use of a parallel computing environment. + * + * Further examples include the following: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    PurposeExamplesProperty List
    + * Specify the driver to be used to open a file + * + * A POSIX driver or an MPI IO driver + * + * \ref FAPL + *
    + * Specify filters to be applied to a dataset + * + * Gzip compression or checksum evaluation + * + * \ref DCPL + *
    + * Specify whether to record key times associated with an object + * + * Creation time and/or last-modified time + * + * \ref OCPL + *
    + * Specify the access mode for a file opened via an external link + * + * Read-only or read-write + * + * \ref LAPL + *
    + * + * Each property is initialized with a default value. For each property, there are one or more + * dedicated H5Pset_*calls that can be used to change that value. + * + *

    Creation, access, and transfer properties:

    + * + * Properties fall into one of several major categories: creation properties, access properties, and + * transfer properties. + * + * Creation properties control permanent object characteristics. These characteristics must be + * established when an object is created, cannot change through the life of the object (they are + * immutable), and the property setting usually has a permanent presence in the file. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Examples of creation properties include:
    + *

    + * Whether a dataset is stored in a compact, contiguous, or chunked layout
    + *
    + * The default for this dataset creation property (\ref H5Pset_layout) is that a dataset is + * stored in a contiguous block. This works well for datasets with a known size limit that + * will fit easily in system memory.
    + *
    + * A chunked layout is important if a dataset is to be compressed, to enable extending + * the dataset’s size, or to enable caching during I/O.
    + *
    + * A compact layout is suitable only for very small datasets because the raw data is + * stored in the object header. + *

    + *
    + *

    + * Creation of intermediate groups when adding an object to an HDF5 file
    + *
    + * This link creation property, \ref H5Pset_create_intermediate_group, enables an + * application to add an object in a file without having to know that the group or group + * hierarchy containing that object already exists. With this property set, HDF5 + * automatically creates missing groups. If this property is not set, an application must + * verify that each group in the path exists, and create those that do not, before creating + * the new object; if any group is missing, the create operation will fail. + *

    + *
    + *

    + * Whether an HDF5 file is a single file or a set of tightly related files that form a virtual + * HDF5 file
    + *
    + * Certain file creation properties enable the application to select one of several file + * layouts. Examples of the available layouts include a standard POSIX-compliant + * layout (\ref H5Pset_fapl_sec2), a family of files (\ref H5Pset_fapl_family), and a split file + * layout that separates raw data and metadata into separate files (\ref H5Pset_fapl_split). + * These and other file layout options are discussed in \ref subsec_file_alternate_drivers. + *

    + *
    + *

    + * To enable error detection when creating a dataset
    + *
    + * In settings where data integrity is vulnerable, it may be desirable to set + * checksumming when datasets are created (\ref H5Pset_fletcher32). A subsequent + * application will then have a means to verify data integrity when reading the dataset. + *

    + *
    + * + * Access properties control transient object characteristics. These characteristics may change with + * the circumstances under which an object is accessed. + * + * + * + * + * + * + * + * + * + *
    Examples of access properties include:
    + *

    + * The driver used to open a file
    + *
    + * For example, a file might be created with the MPI I/O driver (\ref H5Pset_fapl_mpio) + * during high-speed data acquisition in a parallel computing environment. The same + * file might later be analyzed in a serial computing environment with I/O access + * handled through the serial POSIX driver (\ref H5Pset_fapl_sec2). + *

    + *
    + *

    + * Optimization settings in specialized environments
    + *
    + * Optimizations differ across computing environments and according to the needs of + * the task being performed, so are transient by nature. + *

    + *
    + * + * Transfer properties apply only to datasets and control transient aspects of data I/O. These + * characteristics may change with the circumstances under which data is accessed. + * + * + * + * + * + * + * + * + * + *
    Examples of dataset transfer properties include:
    + *

    + * To enable error detection when reading a dataset
    + *
    + * If checksumming has been set on a dataset (with \ref H5Pset_fletcher32, in the dataset + * creation property list), an application reading that dataset can choose whether to check + * for data integrity (\ref H5Pset_edc_check). + *

    + *
    + *

    + * Various properties to optimize chunked data I/O on parallel computing systems
    + *
    + * HDF5 provides several properties for tuning I/O of chunked datasets in a parallel + * computing environment (\ref H5Pset_dxpl_mpio_chunk_opt, \ref H5Pset_dxpl_mpio_chunk_opt_num, + * \ref H5Pset_dxpl_mpio_chunk_opt_ratio, and \ref H5Pget_mpio_actual_chunk_opt_mode).
    + *
    + * Optimal settings differ due to the characteristics of a computing environment and due + * to an application’s data access patterns; even when working with the same file, these + * settings might change for every application and every platform. + *

    + *
    + * + * \subsection subsec_plist_program Programming Model for Properties and Property Lists + * + * The programming model for HDF5 property lists is actually quite simple: + * \li Create a property list. + * \li Modify the property list, if required. + * \li Use the property list. + * \li Close the property list. + * + * There are nuances, of course, but that is the basic process. + * + * In some cases, you will not have to define property lists at all. If the default property settings are + * sufficient for your application, you can tell HDF5 to use the default property list. + * + * The following sections first discuss the use of default property lists, then each step of the + * programming model, and finally a few less frequently used property list operations. + * + * \subsubsection subsubsec_plist_default Using Default Property Lists + * + * Default property lists can simplify many routine HDF5 tasks because you do not always have to + * create every property list you use. + * + * An application that would be well-served by HDF5’s default property settings can use the default + * property lists simply by substituting the value \ref H5P_DEFAULT for a property list identifier. + * HDF5 will then apply the default property list for the appropriate property list class. + * + * For example, the function \ref H5Dcreate2 calls for a link creation property list, a dataset creation + * property list, and a dataset access property list. If the default properties are suitable for a dataset, + * this call can be made as + * \code + * dset_id = H5Dcreate2( loc_id, name, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); + * \endcode + * HDF5 will then apply the default link creation, dataset creation, and dataset access property lists + * correctly. + * + * Of course, you would not want to do this without considering where it is appropriate, as there + * may be unforeseen consequences. Consider, for example, the use of chunked datasets. Optimal + * chunking is quite dependent on the makeup of the dataset and the most common access patterns, + * both of which must be taken into account in setting up the size and shape of chunks. + * + * \subsubsection subsubsec_plist_basic Basic Steps of the Programming Model + * + * The steps of the property list programming model are described in the sub-sections below. + * + *

    Create a Property List

    + * + * A new property list can be created either as an instance of a property list class or by copying an + * existing property list. Consider the following examples. A new dataset creation property list is + * first created "from scratch" with \ref H5Pcreate. A second dataset creation property list is then + * created by copying the first one with \ref H5Pcopy. + * + * \code + * dcplA_id = H5Pcreate (H5P_DATASET_CREATE); + * \endcode + * + * The new dataset creation property list is created as an instance of the property list class + * \ref H5P_DATASET_CREATE. + * + * The new dataset creation property list’s identifier is returned in dcplA_id and the property list is + * initialized with default dataset creation property values. + * + * A list of valid classes appears in the table \ref table_plist "Property list classes in HDF5". + * + * \code + * dcplB_id = H5Pcopy (dcplA_id); + * \endcode + * + * A new dataset creation property list, dcplB_id, is created as a copy of dcplA_id and is initialized + * with dataset creation property values currently in dcplA_id. + * + * At this point, dcplA_id and dcplB_id are identical; they will both contain any modified property + * values that were changed in dcplA_id before dcplB_id was created. They may, however, diverge + * as additional property values are reset in each. + * + * While we are creating property lists, let’s create a link creation property list; we will need this + * property list when the new dataset is linked into the file below: + * \code + * lcplAB_id = H5Pcreate (H5P_LINK_CREATE); + * \endcode + * + *

    Change Property Values

    + * + * This section describes how to set property values. + * + * Later in this section, the dataset creation property lists dcplA_id and dcplB_id created in the + * section above will be used respectively to create chunked and contiguous datasets. To set this up, + * we must set the layout property in each property list. The following example sets dcplA_id for + * chunked datasets and dcplB_id for contiguous datasets: + * \code + * error = H5Pset_layout (dcplA_id, H5D_CHUNKED); + * error = H5Pset_layout (dcplB_id, H5D_CONTIGUOUS); + * \endcode + * + * Since dcplA_id specifies a chunked layout, we must also set the number of dimensions and the + * size of the chunks. The example below specifies that datasets created with dcplA_id will be + * 3-dimensional and that the chunk size will be 100 in each dimension: + * \code + * error = H5Pset_chunk (dcplA_id, 3, [100,100,100]); + * \endcode + * + * These datasets will be created with UTF-8 encoded names. To accomplish that, the following + * example sets the character encoding property in the link creation property list to create link + * names with UTF-8 encoding: + * \code + * error = H5Pset_char_encoding (lcplAB_id, H5T_CSET_UTF8); + * \endcode + * + * dcplA_id can now be used to create chunked datasets and dcplB_id to create contiguous datasets. + * And with the use of lcplAB_id, they will be created with UTF-8 encoded names. + * + *

    Use the Property List

    + * + * Once the required property lists have been created, they can be used to control various HDF5 + * processes. For illustration, consider dataset creation. + * + * Assume that the datatype dtypeAB and the dataspaces dspaceA and dspaceB have been defined + * and that the location identifier locAB_id specifies the group AB in the current HDF5 file. We + * have already created the required link creation and dataset creation property lists. + * For the sake of illustration, we assume that the default dataset access property list meets our application + * requirements. The following calls would create the datasets dsetA and dsetB in the group AB. + * The raw data in dsetA will be contiguous while dsetB raw data will be chunked; both datasets + * will have UTF-8 encoded link names: + * + * \code + * dsetA_id = H5Dcreate2( locAB_id, dsetA, dtypeAB, dspaceA_id, + * lcplAB_id, dcplA_id, H5P_DEFAULT ); + * dsetB_id = H5Dcreate2( locAB_id, dsetB, dtypeAB, dspaceB_id, + * lcplAB_id, dcplB_id, H5P_DEFAULT ); + * \endcode + * + *

    Close the Property List

    + * + * Generally, creating or opening anything in an HDF5 file results in an HDF5 identifier. These + * identifiers are of HDF5 type hid_t and include things like file identifiers, often expressed as + * file_id; dataset identifiers, dset_id; and property list identifiers, plist_id. To reduce the risk of + * memory leaks, all of these identifiers must be closed once they are no longer needed. + * + * Property list identifiers are no exception to this rule, and \ref H5Pclose is used for this purpose. The + * calls immediately following would close the property lists created and used in the examples above. + * + * \code + * error = H5Pclose (dcplA_id); + * error = H5Pclose (dcplB_id); + * error = H5Pclose (lcplAB_id); + * \endcode + * + * \subsubsection subsubsec_plist_additional Additional Property List Operations + * + * A few property list operations fall outside of the programming model described above. This + * section describes those operations. + * + *

    Query the Class of an Existing Property List

    + * + * Occasionally an application will have a property list but not know the corresponding property list + * class. A call such as in the following example will retrieve the unknown class of a known property list: + * \code + * PList_Class = H5Pget_class (dcplA_id); + * \endcode + * + * Upon this function’s return, PList_Class will contain the value \ref H5P_DATASET_CREATE indicating that + * dcplA_id is a dataset creation property list. + + *

    Determine Current Creation Property List Settings in an Existing Object

    + * + * After a file has been created, another application may work on the file without knowing how the + * creation properties for the file were set up. Retrieving these property values is often unnecessary; + * HDF5 can read the data and knows how to deal with any properties it encounters. + * + * But sometimes an application must do something that requires knowing the creation property + * settings. HDF5 makes the acquisition of this information fairly straight-forward; for each + * property setting call, H5Pset_*, there is a corresponding H5Pget_*call to retrieve the property’s + * current setting. + * + * Consider the following examples which illustrate the determination of dataset layout and chunking settings: + * + * The application must first identify the creation property list with the appropriate get creation property + * list call. There is one such call for each kind of object. + * + * \ref H5Dget_create_plist will return a property list identifier for the creation property list that was + * used to create the dataset. Call it DCPL1_id. + * + * \ref H5Pset_layout sets a dataset’s layout to be compact, contiguous, or chunked. + * + * \ref H5Pget_layout called with DCPL1_id will return the dataset’s layout, + * either \ref H5D_COMPACT, \ref H5D_CONTIGUOUS, or \ref H5D_CHUNKED. + * + * \ref H5Pset_chunk sets the rank of a dataset, that is the number of dimensions it will have, and the + * maximum size of each dimension. + * + * \ref H5Pget_chunk, also called with DCPL1_id, will return the rank of the dataset and the maximum + * size of each dimension. + * + * If a creation property value has not been explicitly set, these H5Pget_calls will return the + * property’s default value. + * + *

    Determine Access Property Settings

    + * + * Access property settings are quite different from creation properties. Since access property + * settings are not retained in an HDF5 file or object, there is normally no knowledge of the settings + * that were used in the past. On the other hand, since access properties do not affect characteristics + * of the file or object, this is not normally an issue. For more information, see "Access and + * Creation Property Exceptions." + * + * One circumstance under which an application might need to determine access property settings + * might be when a file or object is already open but the application does not know the property list + * settings. In that case, the application can use the appropriate get access property list + * call to retrieve a property list identifier. For example, if the dataset dsetA + * from the earlier examples is still open, the following call would return an identifier for the dataset + * access property list in use: + * \code + * dsetA_dacpl_id = H5Dget_access_plist( dsetA_id ); + * \endcode + * + * The application could then use the returned property list identifier to analyze the property settings + * + * \subsection subsec_plist_generic Generic Properties Interface and User-defined Properties + * + * HDF5’s generic property interface provides tools for managing the entire property hierarchy and + * for the creation and management of user-defined property lists and properties. This interface also + * makes it possible for an application or a driver to create, modify, and manage custom properties, + * property lists, and property list classes. A comprehensive list of functions for this interface + * appears under "Generic Property Operations (Advanced)" in the "H5P: Property List Interface" + * section of the \ref RM. + * + * Further discussion of HDF5’s generic property interface and user-defined properties and + * property lists is beyond the scope of this document. + * + * \subsection subsec_plist_H5P Property List Function Summaries + * + * General property functions, generic property functions and macros, property functions that are + * used with multiple types of objects, and object and link property functions are listed below. + * + * Property list functions that apply to a specific type of object are listed in the chapter that + * discusses that object. For example, the \ref sec_dataset chapter has two property list function listings: + * one for dataset creation property list functions and one for dataset access property list functions. + * As has been stated, this chapter is not intended to describe every property list function. + * + * \ref H5P reference manual + * + * \subsection subsec_plist_resources Additional Property List Resources + * Property lists are ubiquitous in an HDF5 environment and are therefore discussed in many places + * in HDF5 documentation. The following sections and listings in the \ref UG are of + * particular interest: + * \li In the \ref sec_data_model chapter, see \ref subsubsec_data_model_abstract_plist. + * \li In the \ref sec_file chapter, see the following sections and listings: + *
    • \ref subsec_file_creation_access
    • + *
    • \ref subsec_file_property_lists
    • + *
    • \ref subsubsec_file_examples_props
    • + *
    • \ref subsubsec_file_examples_access
    • + *
    • \ref dcpl_table_tag "Dataset creation property list functions (H5P)"
    • + *
    • \ref fapl_table_tag "File access property list functions (H5P)"
    • + *
    • \ref fd_pl_table_tag "File driver property list functions (H5P)"
    + * \li In the \ref sec_attribute chapter, see "Attribute creation property list functions (H5P)". + * \li In the \ref sec_group chapter, see "Group creation property list functions (H5P)". + * \li Property lists are discussed throughout \ref sec_dataset. + * + * All property list functions are described in the \ref H5P section of the + * \ref RM. The function index at the top of the page provides a categorized listing + * grouped by property list class. Those classes are listed below: + * \li \ref FCPL + * \li \ref FAPL + * \li \ref GCPL + * \li \ref DCPL + * \li \ref DAPL + * \li \ref DXPL + * \li \ref LCPL + * \li \ref LAPL + * \li \ref OCPL + * \li \ref OCPYPL + * + * Additional categories not related to the class structure are as follows: + * \li General property list operations + * \li Generic property list functions + * + * The general property functions can be used with any property list; the generic property functions + * constitute an advanced feature. + * + * The in-memory file image feature of HDF5 uses property lists in a manner that differs + * substantially from their use elsewhere in HDF5. Those who plan to use in-memory file images + * must study "File Image Operations" (PDF) in the Advanced Topics in HDF5collection. + * + * \subsection subsec_plist_notes Notes + * + * \anchor FileMountProps

    File Mount Properties

    + * + * While the file mount property list class \ref H5P_FILE_MOUNT is a valid HDF5 property list class, + * no file mount properties are defined by the HDF5 Library. References to a file mount property + * list should always be expressed as \ref H5P_DEFAULT, meaning the default file mount property list. + * + *

    Access and Creation Property Exceptions

    + * + * There are a small number of exceptions to the rule that creation properties are always retained in + * a file or object and access properties are never retained. + * + * The following properties are file access properties but they are not transient; they have + * permanent and different effects on a file. They could be validly classified as file creation + * properties as they must be set at creation time to properly create the file. But they are access + * properties because they must also be set when a file is reopened to properly access the file. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    PropertyRelated function
    + * Family file driver + * + * \ref H5Pset_fapl_family + *
    + * Split file driver + * + * \ref H5Pset_fapl_split + *
    + * Core file driver + * + * \ref H5Pset_fapl_core + *
    + * + * The following is a link creation property, but it is not relevant after an object has been created + * and is not retained in the file or object. + * + * + * + * + * + * + *
    PropertyRelated function
    + * Create missing intermediate groups + * + * \ref H5Pset_create_intermediate_group + *
    + * + * Previous Chapter \ref sec_error - Next Chapter \ref sec_vol + * + * \defgroup H5P Property Lists (H5P) + * + * Use the functions in this module to manage HDF5 property lists and property + * list classes. HDF5 property lists are the main vehicle to configure the + * behavior of HDF5 API functions. + * + * Typically, property lists are created by instantiating one of the built-in + * or user-defined property list classes. After adding suitable properties, + * property lists are used when opening or creating HDF5 items, or when reading + * or writing data. Property lists can be modified by adding or changing + * properties. Property lists are deleted by closing the associated handles. + * + * \ref PLCR + * \snippet{doc} tables/propertyLists.dox plcr_table + * + * \ref PLCR + * \snippet{doc} tables/propertyLists.dox plcra_table + * + * \ref PLCR / \ref OCPL / \ref GCPL + * \snippet{doc} tables/propertyLists.dox fcpl_table + * + * \ref PLCR + * \snippet{doc} tables/propertyLists.dox fapl_table + * \snippet{doc} tables/propertyLists.dox fd_pl_table + * + * \ref PLCR + * \snippet{doc} tables/propertyLists.dox lapl_table + * + * \ref PLCR / \ref OCPL + * \snippet{doc} tables/propertyLists.dox dcpl_table + * + * \ref PLCR / \ref LAPL + * \snippet{doc} tables/propertyLists.dox dapl_table + * + * \ref PLCR / \ref OCPL + * \snippet{doc} tables/propertyLists.dox gcpl_table + * + * \ref PLCR / \ref LAPL + * \snippet{doc} tables/propertyLists.dox gapl_table + * + * \ref PLCR + * \snippet{doc} tables/propertyLists.dox ocpl_table + * + * \ref PLCR + * \snippet{doc} tables/propertyLists.dox ocpypl_table + * + * \ref PLCR + * \snippet{doc} tables/propertyLists.dox strcpl_table + * + * \ref PLCR / \ref STRCPL + * \snippet{doc} tables/propertyLists.dox lcpl_table + * + * \ref PLCR / \ref STRCPL + * \snippet{doc} tables/propertyLists.dox acpl_table + * + * + * \defgroup STRCPL String Creation Properties * \ingroup H5P - * \defgroup GPLOA General Property List Operations (Advanced) + * Currently, there are only two creation properties that you can use to control + * the creation of HDF5 attributes and links. The first creation property, the + * choice of a character encoding, applies to both attributes and links. + * The second creation property applies to links only, and advises the library + * to automatically create missing intermediate groups when creating new objects. + * + * \snippet{doc} tables/propertyLists.dox strcpl_table + * + * \defgroup LCPL Link Creation Properties + * \ingroup STRCPL + * This creation property applies to links only, and advises the library + * to automatically create missing intermediate groups when creating new objects. + * + * \snippet{doc} tables/propertyLists.dox lcpl_table + * + * @see STRCPL + * + * \defgroup ACPL Attribute Creation Properties + * \ingroup STRCPL + * The creation property, the choice of a character encoding, applies to attributes. + * + * \snippet{doc} tables/propertyLists.dox acpl_table + * + * @see STRCPL + * + * \defgroup LAPL Link Access Properties * \ingroup H5P - * \defgroup FCPL File Creation Properties + * + * \snippet{doc} tables/propertyLists.dox lapl_table + * + * \defgroup DAPL Dataset Access Properties + * \ingroup LAPL + * Use dataset access properties to modify the default behavior of the HDF5 + * library when accessing datasets. The properties include adjusting the size + * of the chunk cache, providing prefixes for external content and virtual + * dataset file paths, and controlling flush behavior, etc. These properties + * are \Emph{not} persisted with datasets, and can be adjusted at runtime before + * a dataset is created or opened. + * + * \snippet{doc} tables/propertyLists.dox dapl_table + * + * \defgroup DCPL Dataset Creation Properties + * \ingroup OCPL + * Use dataset creation properties to control aspects of dataset creation such + * as fill time, storage layout, compression methods, etc. + * Unlike dataset access and transfer properties, creation properties \Emph{are} + * stored with the dataset, and cannot be changed once a dataset has been + * created. + * + * \snippet{doc} tables/propertyLists.dox dcpl_table + * + * \defgroup DXPL Dataset Transfer Properties * \ingroup H5P + * Use dataset transfer properties to customize certain aspects of reading + * and writing datasets such as transformations, MPI-IO I/O mode, error + * detection, etc. These properties are \Emph{not} persisted with datasets, + * and can be adjusted at runtime before a dataset is read or written. + * + * \snippet{doc} tables/propertyLists.dox dxpl_table + * * \defgroup FAPL File Access Properties * \ingroup H5P + * Use file access properties to modify the default behavior of the HDF5 + * library when accessing files. The properties include selecting a virtual + * file driver (VFD), configuring the metadata cache (MDC), control + * file locking, etc. These properties are \Emph{not} persisted with files, and + * can be adjusted at runtime before a file is created or opened. + * + * \snippet{doc} tables/propertyLists.dox fapl_table + * \snippet{doc} tables/propertyLists.dox fd_pl_table + * + * \defgroup FCPL File Creation Properties + * \ingroup GCPL + * Use file creation properties to control aspects of file creation such + * as setting a file space management strategy or creating a user block. + * Unlike file access properties, creation properties \Emph{are} + * stored with the file, and cannot be changed once a file has been + * created. + * + * \snippet{doc} tables/propertyLists.dox fcpl_table + * + * \defgroup GAPL Group Access Properties + * \ingroup LAPL + * The functions in this section can be applied to group property lists. + * + * \snippet{doc} tables/propertyLists.dox gapl_table + * * \defgroup GCPL Group Creation Properties + * \ingroup OCPL + * Use group creation properties to control aspects of group creation such + * as storage layout, compression, and link creation order tracking. + * Unlike file access properties, creation properties \Emph{are} + * stored with the group, and cannot be changed once a group has been + * created. + * + * \snippet{doc} tables/propertyLists.dox gcpl_table + * + * \defgroup PLCR Property List Class Root * \ingroup H5P - * \defgroup ALCAPL Attribute and Link Creation Properties - * \ingroup H5P - * \defgroup LAPL Link Access Properties - * \ingroup H5P - * \defgroup DCPL Dataset Creation Properties - * \ingroup H5P - * \defgroup DAPL Dataset Access Properties - * \ingroup H5P - * \defgroup DXPL Dataset Transfer Properties + * Use the functions in this module to manage HDF5 property lists. + * + * \snippet{doc} tables/propertyLists.dox plcr_table + * + * \defgroup PLCRA Property List Class Root (Advanced) * \ingroup H5P + * You can create and customize user-defined property list classes using the + * functions described below. Arbitrary user-defined properties can also + * be inserted into existing property lists as so-called temporary properties. + * + * \snippet{doc} tables/propertyLists.dox plcra_table + * * \defgroup OCPL Object Creation Properties * \ingroup H5P - * \defgroup OCPPL Object Copy Properties - * \ingroup H5P - * \defgroup GACPL General Access Properties + * + * \snippet{doc} tables/propertyLists.dox ocpl_table + * + * \defgroup OCPYPL Object Copy Properties * \ingroup H5P - * \defgroup MAPL Map Access Properties + * + * \snippet{doc} tables/propertyLists.dox ocpypl_table + * + * \defgroup FMPL File Mount Properties * \ingroup H5P + * Empty property class. + * + * + * \defgroup TCPL Datatype Creation Properties + * \ingroup OCPL + * TCPL isn't supported yet. + * + * + * \defgroup TAPL Datatype Access Properties + * \ingroup LAPL + * TAPL isn't supported yet. + * + * + * */ #endif /* H5Pmodule_H */ diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index cc325823313..8e5f333a7b0 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -482,7 +481,7 @@ H5Pget_obj_track_times(hid_t plist_id, hbool_t *track_times) * transfer property list. The FLAGS argument specifies certain * general properties of the filter and is documented below. * The CD_VALUES is an array of CD_NELMTS integers which are - * auxiliary data for the filter. The integer vlues will be + * auxiliary data for the filter. The integer values will be * stored in the dataset object header as part of the filter * information. * @@ -543,7 +542,7 @@ H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, si * transfer property list. The FLAGS argument specifies certain * general properties of the filter and is documented below. * The CD_VALUES is an array of CD_NELMTS integers which are - * auxiliary data for the filter. The integer vlues will be + * auxiliary data for the filter. The integer values will be * stored in the dataset object header as part of the filter * information. * @@ -609,7 +608,7 @@ H5Pmodify_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t * creation property list. The FLAGS argument specifies certain * general properties of the filter and is documented below. * The CD_VALUES is an array of CD_NELMTS integers which are - * auxiliary data for the filter. The integer vlues will be + * auxiliary data for the filter. The integer values will be * stored in the dataset object header as part of the filter * information. * @@ -671,7 +670,7 @@ H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, size_t cd * creation property list. The FLAGS argument specifies certain * general properties of the filter and is documented below. * The CD_VALUES is an array of CD_NELMTS integers which are - * auxiliary data for the filter. The integer vlues will be + * auxiliary data for the filter. The integer values will be * stored in the dataset object header as part of the filter * information. * @@ -782,7 +781,7 @@ H5Pget_nfilters(hid_t plist_id) * CD_NELMTS indicates the number of entries in the CD_VALUES * array allocated by the caller while on exit it contains the * number of values defined by the filter. FILTER_CONFIG is a bit - * field contaning encode/decode flags from H5Zpublic.h. The IDX + * field containing encode/decode flags from H5Zpublic.h. The IDX * should be a value between zero and N-1 as described for * H5Pget_nfilters() and the function will return failure if the * filter number is out of range. @@ -801,7 +800,7 @@ H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags /*out*/, size_t unsigned cd_values[] /*out*/, size_t namelen, char name[] /*out*/, unsigned *filter_config /*out*/) { - H5P_genplist_t * plist; /* Property list */ + H5P_genplist_t *plist; /* Property list */ H5O_pline_t pline; /* Filter pipeline */ const H5Z_filter_info_t *filter; /* Pointer to filter information */ H5Z_filter_t ret_value; /* return value */ @@ -867,7 +866,7 @@ H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags /*out*/, size_t * CD_NELMTS indicates the number of entries in the CD_VALUES * array allocated by the caller while on exit it contains the * number of values defined by the filter. FILTER_CONFIG is a bit - * field contaning encode/decode flags from H5Zpublic.h. The ID + * field containing encode/decode flags from H5Zpublic.h. The ID * should be the filter ID to retrieve the parameters for. If the * filter is not set for the property list, an error will be returned. * @@ -916,7 +915,7 @@ H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags * CD_NELMTS indicates the number of entries in the CD_VALUES * array allocated by the caller while on exit it contains the * number of values defined by the filter. FILTER_CONFIG is a bit - * field contaning encode/decode flags from H5Zpublic.h. The ID + * field containing encode/decode flags from H5Zpublic.h. The ID * should be the filter ID to retrieve the parameters for. If the * filter is not set for the property list, an error will be returned. * @@ -1356,7 +1355,7 @@ static herr_t H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) { const H5O_pline_t *pline = (const H5O_pline_t *)value; - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; size_t u; /* Local index variable */ FUNC_ENTER_STATIC_NOERR @@ -1447,7 +1446,7 @@ H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__ocrt_pipeline_dec(const void **_pp, void *_value) { - H5O_pline_t * pline = (H5O_pline_t *)_value; /* Property to set */ + H5O_pline_t *pline = (H5O_pline_t *)_value; /* Property to set */ const uint8_t **pp = (const uint8_t **)_pp; size_t nused; /* Number of filters used for pipeline */ unsigned enc_size; /* Size of encoded value (in bytes) */ @@ -1751,7 +1750,7 @@ H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags /*out*/, size_t { H5O_pline_t pline; /* Filter pipeline */ const H5Z_filter_info_t *filter; /* Pointer to filter information */ - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5Z_filter_t ret_value; /* return value */ FUNC_ENTER_API(H5Z_FILTER_ERROR) diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index ff959d2fb54..bdb486fd5e9 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -231,8 +230,8 @@ static herr_t H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value) { const H5O_copy_dtype_merge_list_t *src_dt_list; /* Source merge named datatype lists */ - H5O_copy_dtype_merge_list_t * dst_dt_list = NULL; /* Destination merge named datatype lists */ - H5O_copy_dtype_merge_list_t * dst_dt_list_tail = NULL, + H5O_copy_dtype_merge_list_t *dst_dt_list = NULL; /* Destination merge named datatype lists */ + H5O_copy_dtype_merge_list_t *dst_dt_list_tail = NULL, *tmp_dt_list = NULL; /* temporary merge named datatype lists */ herr_t ret_value = SUCCEED; @@ -363,8 +362,8 @@ static herr_t H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size) { const H5O_copy_dtype_merge_list_t *const *dt_list_ptr = (const H5O_copy_dtype_merge_list_t *const *)value; - uint8_t ** pp = (uint8_t **)_pp; - const H5O_copy_dtype_merge_list_t * dt_list; /* Pointer to merge named datatype list */ + uint8_t **pp = (uint8_t **)_pp; + const H5O_copy_dtype_merge_list_t *dt_list; /* Pointer to merge named datatype list */ size_t len; /* Length of path component */ FUNC_ENTER_STATIC_NOERR @@ -421,7 +420,7 @@ H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *_value) { H5O_copy_dtype_merge_list_t **dt_list = (H5O_copy_dtype_merge_list_t **)_value; /* Pointer to merge named datatype list */ - const uint8_t ** pp = (const uint8_t **)_pp; + const uint8_t **pp = (const uint8_t **)_pp; H5O_copy_dtype_merge_list_t *dt_list_tail = NULL, *tmp_dt_list = NULL; /* temporary merge named datatype lists */ size_t len; /* Length of path component */ @@ -723,7 +722,7 @@ H5Pget_copy_object(hid_t plist_id, unsigned *cpy_option /*out*/) herr_t H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5O_copy_dtype_merge_list_t *old_list; /* Merge committed dtype list currently present */ H5O_copy_dtype_merge_list_t *new_obj = NULL; /* New object to add to list */ herr_t ret_value = SUCCEED; /* Return value */ @@ -785,7 +784,7 @@ H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path) herr_t H5Pfree_merge_committed_dtype_paths(hid_t plist_id) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5O_copy_dtype_merge_list_t *dt_list; /* Merge committed dtype list currently present */ herr_t ret_value = SUCCEED; /* Return value */ @@ -832,7 +831,7 @@ H5Pfree_merge_committed_dtype_paths(hid_t plist_id) herr_t H5Pset_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t func, void *op_data) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ herr_t ret_value = SUCCEED; /* Return value */ @@ -880,7 +879,7 @@ H5Pset_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t func, void *op_data) herr_t H5Pget_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t *func, void **op_data) { - H5P_genplist_t * plist; /* Property list pointer */ + H5P_genplist_t *plist; /* Property list pointer */ H5O_mcdt_cb_info_t cb_info; /* Callback info struct */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index 699d5f3e5d7..5742419bff6 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -62,9 +61,9 @@ typedef enum { /* Define structure to hold property information */ typedef struct H5P_genprop_t { /* Values for this property */ - char * name; /* Name of property */ + char *name; /* Name of property */ size_t size; /* Size of property value */ - void * value; /* Pointer to property value */ + void *value; /* Pointer to property value */ H5P_prop_within_t type; /* Type of object the property is within */ hbool_t shared_name; /* Whether the name is shared or not */ @@ -83,25 +82,25 @@ typedef struct H5P_genprop_t { /* Define structure to hold class information */ struct H5P_genclass_t { struct H5P_genclass_t *parent; /* Pointer to parent class */ - char * name; /* Name of property list class */ + char *name; /* Name of property list class */ H5P_plist_type_t type; /* Type of property */ size_t nprops; /* Number of properties in class */ unsigned - plists; /* Number of property lists that have been created since the last modification to the class */ + plists; /* Number of property lists that have been created since the last modification to the class */ unsigned classes; /* Number of classes that have been derived since the last modification to the class */ unsigned ref_count; /* Number of outstanding ID's open on this class object */ hbool_t deleted; /* Whether this class has been deleted and is waiting for dependent classes & proplists to close */ unsigned revision; /* Revision number of a particular class (global) */ - H5SL_t * props; /* Skip list containing properties */ + H5SL_t *props; /* Skip list containing properties */ /* Callback function pointers & info */ H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ - void * create_data; /* Pointer to user data to pass along to create callback */ + void *create_data; /* Pointer to user data to pass along to create callback */ H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ - void * copy_data; /* Pointer to user data to pass along to copy callback */ + void *copy_data; /* Pointer to user data to pass along to copy callback */ H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ - void * close_data; /* Pointer to user data to pass along to close callback */ + void *close_data; /* Pointer to user data to pass along to close callback */ }; /* Define structure to hold property list information */ @@ -110,8 +109,8 @@ struct H5P_genplist_t { hid_t plist_id; /* Copy of the property list ID (for use in close callback) */ size_t nprops; /* Number of properties in class */ hbool_t class_init; /* Whether the class initialization callback finished successfully */ - H5SL_t * del; /* Skip list containing names of deleted properties */ - H5SL_t * props; /* Skip list containing properties */ + H5SL_t *del; /* Skip list containing names of deleted properties */ + H5SL_t *props; /* Skip list containing properties */ }; /* Property list/class iterator callback function pointer */ @@ -163,12 +162,12 @@ H5_DLL int H5P__iterate_pclass(const H5P_genclass_t *pclass, int *idx, H5P_it H5_DLL herr_t H5P__copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name); H5_DLL herr_t H5P__copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name); H5_DLL herr_t H5P__unregister(H5P_genclass_t *pclass, const char *name); -H5_DLL char * H5P__get_class_path(H5P_genclass_t *pclass); +H5_DLL char *H5P__get_class_path(H5P_genclass_t *pclass); H5_DLL H5P_genclass_t *H5P__open_class_path(const char *path); H5_DLL H5P_genclass_t *H5P__get_class_parent(const H5P_genclass_t *pclass); H5_DLL herr_t H5P__close_class(void *_pclass); -H5_DLL H5P_genprop_t *H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name); -H5_DLL hid_t H5P__new_plist_of_type(H5P_plist_type_t type); +H5_DLL H5P_genprop_t *H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name); +H5_DLL hid_t H5P__new_plist_of_type(H5P_plist_type_t type); /* Encode/decode routines */ H5_DLL herr_t H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop, void *buf, size_t *nalloc); diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 862c74f3180..1dbe6ced913 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -92,22 +91,22 @@ typedef herr_t (*H5P_reg_prop_func_t)(H5P_genclass_t *pclass); * class variables and methods used to initialize the class. */ typedef struct H5P_libclass_t { - const char * name; /* Class name */ + const char *name; /* Class name */ H5P_plist_type_t type; /* Class type */ - H5P_genclass_t ** par_pclass; /* Pointer to global parent class property list class */ - H5P_genclass_t ** pclass; /* Pointer to global property list class */ + H5P_genclass_t **par_pclass; /* Pointer to global parent class property list class */ + H5P_genclass_t **pclass; /* Pointer to global property list class */ hid_t *const class_id; /* Pointer to global property list class ID */ hid_t *const def_plist_id; /* Pointer to global default property list ID */ H5P_reg_prop_func_t reg_prop_func; /* Register class's properties */ /* Class callback function pointers & info */ H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ - void * create_data; /* Pointer to user data to pass along to create callback */ + void *create_data; /* Pointer to user data to pass along to create callback */ H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ - void * copy_data; /* Pointer to user data to pass along to copy callback */ + void *copy_data; /* Pointer to user data to pass along to copy callback */ H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ - void * close_data; /* Pointer to user data to pass along to close callback */ + void *close_data; /* Pointer to user data to pass along to close callback */ } H5P_libclass_t; /*****************************/ @@ -175,7 +174,7 @@ H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, v H5_DLL herr_t H5P_remove(H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_exist_plist(const H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); -H5_DLL char * H5P_get_class_name(H5P_genclass_t *pclass); +H5_DLL char *H5P_get_class_name(H5P_genclass_t *pclass); /* Internal helper routines */ H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse); @@ -196,11 +195,11 @@ H5_DLL herr_t H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsig H5_DLL htri_t H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id); /* Query internal fields of the property list struct */ -H5_DLL hid_t H5P_get_plist_id(const H5P_genplist_t *plist); +H5_DLL hid_t H5P_get_plist_id(const H5P_genplist_t *plist); H5_DLL H5P_genclass_t *H5P_get_class(const H5P_genplist_t *plist); /* *SPECIAL* Don't make more of these! -QAK */ -H5_DLL htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id); +H5_DLL htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id); H5_DLL H5P_genplist_t *H5P_object_verify(hid_t plist_id, hid_t pclass_id); /* Private DCPL routines */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 5adb05e3f2b..33a1df9c540 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -22,16 +21,17 @@ /* Public headers needed by this file */ #include "H5public.h" -#include "H5ACpublic.h" -#include "H5Dpublic.h" -#include "H5Fpublic.h" -#include "H5FDpublic.h" -#include "H5Ipublic.h" -#include "H5Lpublic.h" -#include "H5Opublic.h" -#include "H5MMpublic.h" -#include "H5Tpublic.h" -#include "H5Zpublic.h" +#include "H5ACpublic.h" /* Metadata cache */ +#include "H5Dpublic.h" /* Datasets */ +#include "H5Fpublic.h" /* Files */ +#include "H5FDpublic.h" /* File drivers */ +#include "H5Ipublic.h" /* ID management */ +#include "H5Lpublic.h" /* Links */ +#include "H5MMpublic.h" /* Memory management */ +#include "H5Opublic.h" /* Object headers */ +#include "H5Spublic.h" /* Dataspaces */ +#include "H5Tpublic.h" /* Datatypes */ +#include "H5Zpublic.h" /* Data filters */ /*****************/ /* Public Macros */ @@ -99,8 +99,10 @@ #define H5P_CRT_ORDER_TRACKED 0x0001 #define H5P_CRT_ORDER_INDEXED 0x0002 -/* Default value for all property list classes */ -#define H5P_DEFAULT (hid_t)0 +/** + * Default value of type \ref hid_t for all property list classes + */ +#define H5P_DEFAULT 0 /* (hid_t) */ #ifdef __cplusplus extern "C" { @@ -112,14 +114,72 @@ extern "C" { /* Define property list class callback function pointer types */ //! +/** + * \brief Callback function for H5Pcreate_class() + * + * \param[in] prop_id The identifier of the property list class being created + * \param[in] create_data User pointer to any class creation data required + * \return \herr_t + * + * \details This function is called when a new property list of the class + * with which this function was registered is being created. The + * function is called after any registered parent create function is + * called for each property value. + * + * If the create function returns a negative value, the new list is not + * returned to the user and the property list creation routine returns + * an error value. + * + * \since 1.4.0 + * + */ typedef herr_t (*H5P_cls_create_func_t)(hid_t prop_id, void *create_data); //! //! +/** + * \brief Callback function for H5Pcreate_class() + * + * \param[in] new_prop_id The identifier of the property list copy + * \param[in] old_prop_id The identifier of the property list being copied + * \param[in] copy_data User pointer to any copy data required + * \return \herr_t + * + * \details This function is called when an existing property list of this + * class is copied. The copy callback function is called after any + * registered parent copy callback function is called for each property + * value. + * + * If the copy routine returns a negative value, the new list is not + * returned to the user and the property list copy function returns an + * error value. + * + * \since 1.4.0 + * + */ typedef herr_t (*H5P_cls_copy_func_t)(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); //! //! +/** + * \brief Callback function for H5Pcreate_class() + * + * \param[in] prop_id The identifier of the property list class being created + * \param[in] close_data User pointer to any close data required + * \return \herr_t + * + * \details This function is called when a property list of the class + * with which this function was registered is being closed. The + * function is called after any registered parent close function is + * called for each property value. + * + * If the close function returns a negative value, the new list is not + * returned to the user and the property list close routine returns + * an error value. + * + * \since 1.4.0 + * + */ typedef herr_t (*H5P_cls_close_func_t)(hid_t prop_id, void *close_data); //! @@ -133,8 +193,8 @@ typedef herr_t (*H5P_cls_close_func_t)(hid_t prop_id, void *close_data); * \param[in,out] value The value for the property * \return \herr_t * - * \details The H5P_prp_cb1_t() describes the parameters used by the - * property create,copy and close callback functions. + * \details The H5P_prp_cb1_t() function describes the parameters used by the + * property create, copy and close callback functions. */ typedef herr_t (*H5P_prp_cb1_t)(const char *name, size_t size, void *value); //! @@ -149,8 +209,8 @@ typedef herr_t (*H5P_prp_cb1_t)(const char *name, size_t size, void *value); * \param[in] value The value for the property * \return \herr_t * - * \details The H5P_prp_cb2_t() describes the parameters used by the - * property set ,copy and delete callback functions. + * \details The H5P_prp_cb2_t() function describes the parameters used by the + * property set, copy and delete callback functions. */ typedef herr_t (*H5P_prp_cb2_t)(hid_t prop_id, const char *name, size_t size, void *value); //! @@ -158,12 +218,49 @@ typedef herr_t (*H5P_prp_cb2_t)(hid_t prop_id, const char *name, size_t size, vo typedef H5P_prp_cb1_t H5P_prp_create_func_t; typedef H5P_prp_cb2_t H5P_prp_set_func_t; typedef H5P_prp_cb2_t H5P_prp_get_func_t; +//! +/** + * \brief Callback function for encoding property values + * + * \param[in] value The property value to be encoded + * \param[out] buf The encoded property value + * \param[out] size The size of \p buf + * \return \herr_t + * + * \note There is currently no public API which exposes a callback of this type. + * + */ typedef herr_t (*H5P_prp_encode_func_t)(const void *value, void **buf, size_t *size); +//! +//! +/** + * \brief Callback function for decoding property values + * + * \param[in] buf A buffer containing an encoded property value + * \param[out] value The decoded property value + * \return \herr_t + * + * \note There is currently no public API which exposes a callback of this type. + * + */ typedef herr_t (*H5P_prp_decode_func_t)(const void **buf, void *value); +//! typedef H5P_prp_cb2_t H5P_prp_delete_func_t; typedef H5P_prp_cb1_t H5P_prp_copy_func_t; //! +/** + * \brief Callback function for comparing property values + * + * \param[in] value1 A property value + * \param[in] value2 A property value + * \param[in] size The size of the \p value1 and \p value2 buffers + * \return Returns a positive value if \c value1 is greater than \c value2, a + * negative value if \c value2 is greater than \c value1 and zero if + * \c value1 and \c value2 are equal. + * + * \see H5Pregister(), H5Pinsert() + */ typedef int (*H5P_prp_compare_func_t)(const void *value1, const void *value2, size_t size); //! @@ -171,6 +268,21 @@ typedef H5P_prp_cb1_t H5P_prp_close_func_t; /* Define property list iteration function type */ //! +/** + * \brief Callback function for H5Piterate() + * + * \param[in] id The identifier of a property list or property list class + * \param[in] name The name of the current property + * \param[in,out] iter_data The user context passed to H5Piterate() + * \return \herr_t_iter + * + * \details This function is called for each property encountered when + * iterating over a property list or property list class + * via H5Piterate(). + * + * \since 1.4.0 + * + */ typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data); //! @@ -236,15 +348,15 @@ typedef enum H5D_mpio_no_collective_cause_t { H5D_MPIO_DATA_TRANSFORMS = 0x04, /**< Collective I/O was not performed because data transforms needed to be applied */ H5D_MPIO_MPI_OPT_TYPES_ENV_VAR_DISABLED = 0x08, - /**< \todo FIXME! */ + /**< Collective I/O was disabled by environment variable (\Code{HDF5_MPI_OPT_TYPES}) */ H5D_MPIO_NOT_SIMPLE_OR_SCALAR_DATASPACES = 0x10, /**< Collective I/O was not performed because one of the dataspaces was neither simple nor scalar */ H5D_MPIO_NOT_CONTIGUOUS_OR_CHUNKED_DATASET = 0x20, /**< Collective I/O was not performed because the dataset was neither contiguous nor chunked */ H5D_MPIO_PARALLEL_FILTERED_WRITES_DISABLED = 0x40, - /**< \todo FIXME! */ + /**< Collective I/O was not performed because parallel filtered writes are disabled */ H5D_MPIO_ERROR_WHILE_CHECKING_COLLECTIVE_POSSIBLE = 0x80, - /**< \todo FIXME! */ + /**< Error */ H5D_MPIO_NO_COLLECTIVE_MAX_CAUSE = 0x100 /**< Sentinel */ } H5D_mpio_no_collective_cause_t; @@ -279,7 +391,7 @@ H5_DLLVAR hid_t H5P_CLS_LINK_ACCESS_ID_g; H5_DLLVAR hid_t H5P_CLS_VOL_INITIALIZE_ID_g; H5_DLLVAR hid_t H5P_CLS_REFERENCE_ACCESS_ID_g; -/* Default roperty list IDs */ +/* Default property list IDs */ /* (Internal to library, do not use! Use macros above) */ H5_DLLVAR hid_t H5P_LST_FILE_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_FILE_ACCESS_ID_g; @@ -308,7 +420,7 @@ H5_DLLVAR hid_t H5P_LST_REFERENCE_ACCESS_ID_g; /* Generic property list routines */ /** - * \ingroup GPLO + * \ingroup PLCR * * \brief Terminates access to a property list * @@ -326,7 +438,7 @@ H5_DLLVAR hid_t H5P_LST_REFERENCE_ACCESS_ID_g; */ H5_DLL herr_t H5Pclose(hid_t plist_id); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Closes an existing property list class * @@ -343,7 +455,7 @@ H5_DLL herr_t H5Pclose(hid_t plist_id); */ H5_DLL herr_t H5Pclose_class(hid_t plist_id); /** - * \ingroup GPLO + * \ingroup PLCR * * \brief Copies an existing property list to create a new property list * @@ -360,7 +472,7 @@ H5_DLL herr_t H5Pclose_class(hid_t plist_id); */ H5_DLL hid_t H5Pcopy(hid_t plist_id); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Copies a property from one list or class to another * @@ -396,7 +508,7 @@ H5_DLL hid_t H5Pcopy(hid_t plist_id); */ H5_DLL herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name); /** - * \ingroup GPLO + * \ingroup PLCR * * \brief Creates a new property list as an instance of a property list class * @@ -520,7 +632,7 @@ H5_DLL herr_t H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name); */ H5_DLL hid_t H5Pcreate(hid_t cls_id); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Creates a new property list class * @@ -549,77 +661,12 @@ H5_DLL hid_t H5Pcreate(hid_t cls_id); * those existing properties, only add or remove their own class * properties. Property list classes defined and supported in the * HDF5 library distribution are listed and briefly described in - * H5Pcreate(). The \p create routine is called when a new property - * list of this class is being created. The #H5P_cls_create_func_t - * callback function is defined as follows: - * - * \snippet this H5P_cls_create_func_t_snip - * - * The parameters to this callback function are defined as follows: - * - * - * - * - * - * - * - * - * - *
    \ref hid_t \c prop_idIN: The identifier of the property list being created
    \Code{void * create_data}IN: User pointer to any class creation data required
    - * - * The \p create routine is called after any registered - * \p create function is called for each property value. If the - * \p create routine returns a negative value, the new list is not - * returned to the user and the property list creation routine returns - * an error value. - * - * The \p copy routine is called when an existing property - * list of this class is copied. The #H5P_cls_copy_func_t callback - * function is defined as follows: - * \snippet this H5P_cls_copy_func_t_snip - * - * The parameters to this callback function are defined as follows: - * - * - * - * - * - * - * - * - * - *
    \ref hid_t \c prop_idIN: The identifier of the property list created by copying
    \Code{void * copy_data}IN: User pointer to any class copy data required
    - * - * The \p copy routine is called after any registered \p copy function - * is called for each property value. If the \p copy routine returns a - * negative value, the new list is not returned to the user and the - * property list \p copy routine returns an error value. + * H5Pcreate(). The \p create, \p copy, \p close functions are called + * when a property list of the new class is created, copied, or closed, + * respectively. * - * The \p close routine is called when a property list of this class - * is being closed. The #H5P_cls_close_func_t callback function is - * defined as follows: - * \snippet this H5P_cls_close_func_t_snip - * - * The parameters to this callback function are defined as follows: - * - * - * - * - * - * - * - * - * - *
    \ref hid_t \c prop_idIN: The identifier of the property list being closed
    \Code{void * close_data}IN: User pointer to any class close data required
    - * - * The \p close routine is called before any registered \p close - * function is called for each property value. If the \p close routine - * returns a negative value, the property list close routine returns - * an error value but the property list is still closed. - * - * H5Pclose_class() can be used to release the property list class - * identifier returned by this function so that resources leaks will - * not develop. + * H5Pclose_class() must be used to release the property list class + * identifier returned by this function. * * \since 1.4.0 * @@ -628,7 +675,7 @@ H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func H5P_cls_copy_func_t copy, void *copy_data, H5P_cls_close_func_t close, void *close_data); /** - * \ingroup GPLO + * \ingroup PLCR * * \brief Decodes property list received in a binary object buffer and * returns a new property list identifier @@ -657,7 +704,7 @@ H5_DLL hid_t H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func */ H5_DLL hid_t H5Pdecode(const void *buf); /** - * \ingroup GPLO + * \ingroup PLCR * * \brief Encodes the property values in a property list into a binary * buffer @@ -711,7 +758,7 @@ H5_DLL hid_t H5Pdecode(const void *buf); */ H5_DLL herr_t H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Compares two property lists or classes for equality * @@ -731,7 +778,7 @@ H5_DLL herr_t H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_i */ H5_DLL htri_t H5Pequal(hid_t id1, hid_t id2); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Queries whether a property name exists in a property list or * class @@ -749,7 +796,7 @@ H5_DLL htri_t H5Pequal(hid_t id1, hid_t id2); */ H5_DLL htri_t H5Pexist(hid_t plist_id, const char *name); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Queries the value of a property * @@ -781,7 +828,7 @@ H5_DLL htri_t H5Pexist(hid_t plist_id, const char *name); */ H5_DLL herr_t H5Pget(hid_t plist_id, const char *name, void *value); /** - *\ingroup GPLO + * \ingroup PLCR * * \brief Returns the property list class identifier for a property list * @@ -844,7 +891,7 @@ H5_DLL herr_t H5Pget(hid_t plist_id, const char *name, void *value); */ H5_DLL hid_t H5Pget_class(hid_t plist_id); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Retrieves the name of a class * @@ -988,7 +1035,7 @@ H5_DLL hid_t H5Pget_class(hid_t plist_id); */ H5_DLL char *H5Pget_class_name(hid_t pclass_id); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Retrieves the parent class of a property class * @@ -1004,7 +1051,7 @@ H5_DLL char *H5Pget_class_name(hid_t pclass_id); */ H5_DLL hid_t H5Pget_class_parent(hid_t pclass_id); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Queries the number of properties in a property list or class * @@ -1027,7 +1074,7 @@ H5_DLL hid_t H5Pget_class_parent(hid_t pclass_id); */ H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Queries the size of a property value in bytes * @@ -1048,7 +1095,7 @@ H5_DLL herr_t H5Pget_nprops(hid_t id, size_t *nprops); */ H5_DLL herr_t H5Pget_size(hid_t id, const char *name, size_t *size); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Registers a temporary property with a property list * @@ -1298,7 +1345,7 @@ H5_DLL herr_t H5Pinsert2(hid_t plist_id, const char *name, size_t size, void *va H5P_prp_get_func_t get, H5P_prp_delete_func_t prp_del, H5P_prp_copy_func_t copy, H5P_prp_compare_func_t compare, H5P_prp_close_func_t close); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Determines whether a property list is a member of a class * @@ -1318,7 +1365,7 @@ H5_DLL herr_t H5Pinsert2(hid_t plist_id, const char *name, size_t size, void *va */ H5_DLL htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Iterates over properties in a property class or list * @@ -1348,35 +1395,12 @@ H5_DLL htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id); * returned in this case, the iterator cannot be restarted if * one of the calls to its operator returns non-zero. * - * The prototype for the #H5P_iterate_t operator is as follows: - * \snippet this H5P_iterate_t_snip - * - * The operation receives the property list or class + * The operation \p iter_func receives the property list or class * identifier for the object being iterated over, \p id, the * name of the current property within the object, \p name, * and the pointer to the operator data passed in to H5Piterate(), - * \p iter_data. The valid return values from an operator are - * as follows: + * \p iter_data. * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    ZeroCauses the iterator to continue, returning zero when all - * properties have been processed
    PositiveCauses the iterator to immediately return that positive - * value, indicating short-circuit success. The iterator - * can be restarted at the index of the next property
    NegativeCauses the iterator to immediately return that value, - * indicating failure. The iterator can be restarted at the - * index of the next property
    * H5Piterate() assumes that the properties in the object * identified by \p id remain unchanged through the iteration. * If the membership changes during the iteration, the function's @@ -1387,7 +1411,7 @@ H5_DLL htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id); */ H5_DLL int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Registers a permanent property with a property list class * @@ -1668,7 +1692,7 @@ H5_DLL herr_t H5Pregister2(hid_t cls_id, const char *name, size_t size, void *de H5P_prp_delete_func_t prp_del, H5P_prp_copy_func_t copy, H5P_prp_compare_func_t compare, H5P_prp_close_func_t close); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Removes a property from a property list * @@ -1694,7 +1718,7 @@ H5_DLL herr_t H5Pregister2(hid_t cls_id, const char *name, size_t size, void *de */ H5_DLL herr_t H5Premove(hid_t plist_id, const char *name); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Sets a property list value * @@ -1726,7 +1750,7 @@ H5_DLL herr_t H5Premove(hid_t plist_id, const char *name); */ H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, const void *value); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Removes a property from a property list class * @@ -1745,8 +1769,6 @@ H5_DLL herr_t H5Pset(hid_t plist_id, const char *name, const void *value); */ H5_DLL herr_t H5Punregister(hid_t pclass_id, const char *name); -/* Object creation property list (OCPL) routines */ - /** * \ingroup DCPL * @@ -1766,6 +1788,9 @@ H5_DLL herr_t H5Punregister(hid_t pclass_id, const char *name); * */ H5_DLL htri_t H5Pall_filters_avail(hid_t plist_id); + +/* Object creation property list (OCPL) routines */ + /** * \ingroup OCPL * @@ -1849,9 +1874,6 @@ H5_DLL herr_t H5Pget_attr_phase_change(hid_t plist_id, unsigned *max_compact, un * * \brief Returns information about a filter in a pipeline * - * \todo Signature for H5Pget_filter2 is different in H5Pocpl.c than in - * H5Ppublic.h - * * \ocpl_id{plist_id} * \param[in] idx Sequence number within the filter pipeline of the filter * for which information is sought @@ -2210,7 +2232,7 @@ H5_DLL herr_t H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flag */ H5_DLL herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense); /** - * \ingroup OCPL + * \ingroup DCPL * * \brief Sets deflate (GNU gzip) compression method and compression level * @@ -2219,6 +2241,8 @@ H5_DLL herr_t H5Pset_attr_phase_change(hid_t plist_id, unsigned max_compact, uns * * \return \herr_t * + * \par_compr_note + * * \details H5Pset_deflate() sets the deflate compression method and the * compression level, \p level, for a dataset or group creation * property list, \p plist_id. @@ -2297,10 +2321,13 @@ H5_DLL herr_t H5Pset_deflate(hid_t plist_id, unsigned level); * (#H5Z_FILTER_DEFLATE) and the Fletcher32 error detection filter * (#H5Z_FILTER_FLETCHER32). * - * The array \p c_values contains \p cd_nelmts integers which are - * auxiliary data for the filter. The integer values will be - * stored in the dataset object header as part of the filter - * information. + * The array \p cd_values contains \p cd_nelmts unsigned integers + * which are auxiliary data for the filter. The values are typically + * used as parameters to control the filter. In a filter's + * \p set_local method (called from \p H5Dcreate), the values are + * interpreted and possibly modified before they are used to control + * the filter. These, possibly modified values, are then stored in + * the dataset object header as auxiliary data for the filter. * * The \p flags argument is a bit vector with the following * fields specifying certain general properties of the filter: @@ -3699,7 +3726,7 @@ H5_DLL herr_t H5Pget_libver_bounds(hid_t plist_id, H5F_libver_t *low, H5F_libver * \since 1.8.0 * */ -H5_DLL herr_t H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr); /* out */ +H5_DLL herr_t H5Pget_mdc_config(hid_t plist_id, H5AC_cache_config_t *config_ptr); /** * \ingroup FAPL * @@ -3854,13 +3881,13 @@ H5_DLL herr_t H5Pget_meta_block_size(hid_t fapl_id, hsize_t *size); * * The second example illustrates the two cases for retrieving the * number of read attempts from the file access property list of a file - * opened with SWMR acccess. + * opened with SWMR access. * * \include H5Pget_metadata_read_attempts.2.c * * The third example illustrates the two cases for retrieving the number * of read attempts from the file access property list of a file opened - * with non-SWMR acccess. + * with non-SWMR access. * * \include H5Pget_metadata_read_attempts.3.c * @@ -4147,17 +4174,14 @@ H5_DLL herr_t H5Pset_alignment(hid_t fapl_id, hsize_t threshold, hsize_t alignme * * \note Note: Raw dataset chunk caching is not currently * supported when using the MPI I/O and MPI POSIX file drivers - * in read/write mode; see H5Pset_fapl_mpio() and - * H5Pset_fapl_mpiposix(), respectively. When using one of these - * file drivers, all calls to H5Dread() and H5Dwrite() will access + * in read/write mode; see H5Pset_fapl_mpio(). When using this + * file driver, all calls to H5Dread() and H5Dwrite() will access * the disk directly, and H5Pset_cache() will have no effect on * performance. * * \note Raw dataset chunk caching is supported when these drivers are * used in read-only mode. * - * \todo Check on H5Pset_fapl_mpio() and H5Pset_fapl_mpiposix(). - * * \version 1.8.0 The use of the \p mdc_nelmts parameter was discontinued. * Metadata cache configuration is managed with * H5Pset_mdc_config() and H5Pget_mdc_config(). @@ -4265,7 +4289,7 @@ H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_ * The external link open file cache holds files open after * they have been accessed via an external link. This cache reduces * the number of times such files are opened when external links are - * accessed repeatedly and can siginificantly improves performance in + * accessed repeatedly and can significantly improves performance in * certain heavy-use situations and when low-level file opens or closes * are expensive. * @@ -5208,7 +5232,7 @@ H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_i #ifdef H5_HAVE_PARALLEL /** - * \ingroup GACPL + * \ingroup GAPL * * \brief Sets metadata I/O mode for read operations to collective or independent (default) * @@ -5277,7 +5301,7 @@ H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_i */ H5_DLL herr_t H5Pset_all_coll_metadata_ops(hid_t plist_id, hbool_t is_collective); /** - * \ingroup GACPL + * \ingroup GAPL * * \brief Retrieves metadata read mode setting * @@ -5346,12 +5370,38 @@ H5_DLL herr_t H5Pset_coll_metadata_write(hid_t plist_id, hbool_t is_collective); H5_DLL herr_t H5Pget_coll_metadata_write(hid_t plist_id, hbool_t *is_collective); /** - * \todo Add missing documentation + * \ingroup FAPL + * + * \brief Get the MPI communicator and info + * + * \fapl_id + * \param[out] comm MPI communicator + * \param[out] info MPI info object + * \return \herr_t + * + * \details H5Pget_mpi_params() gets the MPI communicator and info stored in + * the file access property list \p fapl_id. + * + * \todo When was this introduced? + * */ H5_DLL herr_t H5Pget_mpi_params(hid_t fapl_id, MPI_Comm *comm, MPI_Info *info); /** - * \todo Add missing documentation + * \ingroup FAPL + * + * \brief Set the MPI communicator and info + * + * \fapl_id + * \param[in] comm MPI communicator + * \param[in] info MPI info object + * \return \herr_t + * + * \details H5Pset_mpi_params() sets the MPI communicator and info stored in + * the file access property list \p fapl_id. + * + * \todo When was this introduced? + * */ H5_DLL herr_t H5Pset_mpi_params(hid_t fapl_id, MPI_Comm comm, MPI_Info info); #endif /* H5_HAVE_PARALLEL */ @@ -5627,6 +5677,9 @@ H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize); * are null pointers then the corresponding information is not * returned. * + * \note On Windows, off_t is typically a 32-bit signed long value, which + * limits the valid offset that can be returned to 2 GiB. + * * \version 1.6.4 \p idx parameter type changed to unsigned. * \since 1.0.0 * @@ -6237,6 +6290,8 @@ H5_DLL herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value * * \return \herr_t * + * \par_compr_note + * * \details H5Pset_shuffle() sets the shuffle filter, #H5Z_FILTER_SHUFFLE, * in the dataset creation property list \p plist_id. The shuffle * filter de-interlaces a block of data by reordering the bytes. @@ -6308,6 +6363,8 @@ H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); * * \return \herr_t * + * \par_compr_note + * * \details H5Pset_nbit() sets the N-Bit filter, #H5Z_FILTER_NBIT, in the * dataset creation property list \p plist_id. * @@ -6330,10 +6387,10 @@ H5_DLL herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); * byte 0 * * - * ???????? - * ????SPPP - * PPPPPPPP - * PPPP???? + * ???????? + * ????SPPP + * PPPPPPPP + * PPPP???? * * * Note: S - sign bit, P - significant bit, ? - padding bit; For @@ -6401,6 +6458,8 @@ H5_DLL herr_t H5Pset_nbit(hid_t plist_id); * * \return \herr_t * + * \par_compr_note + * * \details H5Pset_scaleoffset() sets the scale-offset filter, * #H5Z_FILTER_SCALEOFFSET, for a dataset. * @@ -6510,6 +6569,8 @@ H5_DLL herr_t H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, * * \return \herr_t * + * \par_compr_note + * * \details H5Pset_szip() sets an SZIP compression filter, #H5Z_FILTER_SZIP, * for a dataset. SZIP is a compression method designed for use with * scientific data. @@ -6955,9 +7016,6 @@ H5_DLL herr_t H5Pget_virtual_printf_gap(hid_t dapl_id, hsize_t *gap_size); * * \dapl_id * \param[out] view The flag specifying the view of the virtual dataset. - * Valid values are: - * \li #H5D_VDS_FIRST_MISSING - * \li #H5D_VDS_LAST_AVAILABLE * * \return \herr_t * @@ -7311,11 +7369,7 @@ H5_DLL herr_t H5Pset_virtual_printf_gap(hid_t dapl_id, hsize_t gap_size); * * \dapl_id * \param[in] view Flag specifying the extent of the data to be included - * in the view. Valid values are: - * \li #H5D_VDS_FIRST_MISSING: View includes all data - * before the first missing mapped data - * \li #H5D_VDS_LAST_AVAILABLE View includes all - * available mapped data + * in the view. * * \return \herr_t * @@ -7420,10 +7474,6 @@ H5_DLL size_t H5Pget_buffer(hid_t plist_id, void **tconv /*out*/, void **bkg /*o * If an error occurs, the buffer pointed to by \p expression is * unchanged, and the function returns a negative value. * - * \par Example - * An example snippet from examples/h5_dtransform.c: - * \snippet h5_dtransform.c H5Pget_data_transform_snip - * * \since 1.8.0 * */ @@ -7487,8 +7537,11 @@ H5_DLL herr_t H5Pget_hyper_vector_size(hid_t fapl_id, size_t *size /*out*/); * \details H5Pget_preserve() checks the status of the dataset transfer * property list. * + * \since 1.0.0 + * * \version 1.6.0 The flag parameter was changed from INTEGER to LOGICAL to * better match the C API. (Fortran 90) + * \version 1.8.2 Deprecated. * */ H5_DLL int H5Pget_preserve(hid_t plist_id); @@ -7516,6 +7569,8 @@ H5_DLL int H5Pget_preserve(hid_t plist_id); * * Please refer to the function H5Pset_type_conv_cb() for more details. * + * \since 1.8.0 + * */ H5_DLL herr_t H5Pget_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t *op, void **operate_data); /** @@ -7539,6 +7594,8 @@ H5_DLL herr_t H5Pget_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t *op, voi * H5Pset_vlen_mem_manager(), returning the parameters set by * that function. * + * \since 1.0.0 + * */ H5_DLL herr_t H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func, void **alloc_info, H5MM_free_t *free_func, void **free_info); @@ -7782,8 +7839,9 @@ H5_DLL herr_t H5Pset_hyper_vector_size(hid_t plist_id, size_t size); * I/O pipeline treats the destination datapoints as completely * uninitialized. * - * \todo Add missing version information: introduction, deprecation, etc. - * Why is the declaration not in the deprecated section? + * \since 1.0.0 + * + * \version 1.8.2 Deprecated. * */ H5_DLL herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); @@ -7811,7 +7869,7 @@ H5_DLL herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); * function prototype is as follows: * \snippet H5Tpublic.h H5T_conv_except_func_t_snip * - * \todo Add version information. + * \since 1.8.0 * */ H5_DLL herr_t H5Pset_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t op, void *operate_data); @@ -7861,7 +7919,8 @@ H5_DLL herr_t H5Pset_type_conv_cb(hid_t dxpl_id, H5T_conv_except_func_t op, void * set to \c NULL and the \p alloc_info and \p free_info parameters are * ignored. * - * \todo Add version information. + * \since 1.0.0 + * */ H5_DLL herr_t H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); @@ -8000,9 +8059,8 @@ H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no uint32_t *global_no_collective_cause); #endif /* H5_HAVE_PARALLEL */ -/* Link creation property list (LCPL) routines */ /** - * \ingroup ALCAPL + * \ingroup LCPL * * \brief Determines whether property is set to enable creating missing * intermediate groups @@ -8033,7 +8091,7 @@ H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no */ H5_DLL herr_t H5Pget_create_intermediate_group(hid_t plist_id, unsigned *crt_intmd /*out*/); /** - * \ingroup ALCAPL + * \ingroup LCPL * * \brief Specifies in property list whether to create missing * intermediate groups @@ -8415,9 +8473,8 @@ H5_DLL herr_t H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size size_t *key_alloc_size /*out*/); #endif /* H5_HAVE_MAP_API */ -/* String creation property list (STRCPL) routines */ /** - * \ingroup ALCAPL + * \ingroup ACPL * * \brief Retrieves the character encoding used to create a link or * attribute name @@ -8446,7 +8503,7 @@ H5_DLL herr_t H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size */ H5_DLL herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/); /** - * \ingroup ALCAPL + * \ingroup ACPL * * \brief Sets the character encoding used to encode link and attribute * names @@ -8487,7 +8544,6 @@ H5_DLL herr_t H5Pget_char_encoding(hid_t plist_id, H5T_cset_t *encoding /*out*/) */ H5_DLL herr_t H5Pset_char_encoding(hid_t plist_id, H5T_cset_t encoding); -/* Link access property list (LAPL) routines */ /** * \ingroup LAPL * @@ -8846,7 +8902,7 @@ H5_DLL herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks); /* Object copy property list (OCPYPL) routines */ /** - * \ingroup OCPPL + * \ingroup OCPYPL * * \brief Adds a path to the list of paths that will be searched in the * destination file for a matching committed datatype @@ -8961,7 +9017,7 @@ H5_DLL herr_t H5Pset_nlinks(hid_t plist_id, size_t nlinks); */ H5_DLL herr_t H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path); /** - * \ingroup OCPPL + * \ingroup OCPYPL * * \brief Clears the list of paths stored in the object copy property list * @@ -9012,7 +9068,7 @@ H5_DLL herr_t H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path */ H5_DLL herr_t H5Pfree_merge_committed_dtype_paths(hid_t plist_id); /** - * \ingroup OCPPL + * \ingroup OCPYPL * * \brief Retrieves the properties to be used when an object is copied * @@ -9037,7 +9093,7 @@ H5_DLL herr_t H5Pfree_merge_committed_dtype_paths(hid_t plist_id); */ H5_DLL herr_t H5Pget_copy_object(hid_t plist_id, unsigned *copy_options /*out*/); /** - * \ingroup OCPPL + * \ingroup OCPYPL * * \brief Retrieves the callback function from the specified object copy * property list @@ -9075,7 +9131,7 @@ H5_DLL herr_t H5Pget_copy_object(hid_t plist_id, unsigned *copy_options /*out*/) */ H5_DLL herr_t H5Pget_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t *func, void **op_data); /** - * \ingroup OCPPL + * \ingroup OCPYPL * * \brief Sets properties to be used when an object is copied * @@ -9168,7 +9224,7 @@ H5_DLL herr_t H5Pget_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t *func, */ H5_DLL herr_t H5Pset_copy_object(hid_t plist_id, unsigned copy_options); /** - * \ingroup OCPPL + * \ingroup OCPYPL * * \brief Sets the callback function that H5Ocopy() will invoke before * searching the entire destination file for a matching committed @@ -9266,7 +9322,7 @@ H5_DLL herr_t H5Pset_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t func, v /* Typedefs */ /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Registers a permanent property with a property list class * @@ -9388,9 +9444,6 @@ H5_DLL herr_t H5Pset_mcdt_search_cb(hid_t plist_id, H5O_mcdt_search_cb_t func, v * The #H5P_prp_cb2_t is as follows: * \snippet this H5P_prp_cb2_t_snip * - * - * \cpp_c_api_note - * */ /* Function prototypes */ @@ -9399,7 +9452,7 @@ H5_DLL herr_t H5Pregister1(hid_t cls_id, const char *name, size_t size, void *de H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_del, H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close); /** - * \ingroup GPLOA + * \ingroup PLCRA * * \brief Registers a temporary property with a property list * @@ -9504,15 +9557,14 @@ H5_DLL herr_t H5Pregister1(hid_t cls_id, const char *name, size_t size, void *de * * The #H5P_prp_cb2_t is as follows: * \snippet this H5P_prp_cb2_t_snip - - * \cpp_c_api_note + * */ H5_DLL herr_t H5Pinsert1(hid_t plist_id, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close); /** - * \ingroup GPLO + * \ingroup PLCRA * * \brief Encodes the property values in a property list into a binary * buffer diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c index 7e5ea461b1f..f684dc54a26 100644 --- a/src/H5Pstrcpl.c +++ b/src/H5Pstrcpl.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -218,7 +217,7 @@ static herr_t H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) { const H5T_cset_t *encoding = (const H5T_cset_t *)value; /* Create local alias for values */ - uint8_t ** pp = (uint8_t **)_pp; + uint8_t **pp = (uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR @@ -254,7 +253,7 @@ H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) static herr_t H5P__strcrt_char_encoding_dec(const void **_pp, void *_value) { - H5T_cset_t * encoding = (H5T_cset_t *)_value; /* Character set encoding */ + H5T_cset_t *encoding = (H5T_cset_t *)_value; /* Character set encoding */ const uint8_t **pp = (const uint8_t **)_pp; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Ptest.c b/src/H5Ptest.c index f22c30e8b34..ac81ea0872f 100644 --- a/src/H5Ptest.c +++ b/src/H5Ptest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -57,7 +56,7 @@ char * H5P__get_class_path_test(hid_t pclass_id) { H5P_genclass_t *pclass; /* Property class to query */ - char * ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5R.c b/src/H5R.c index e08e451e83e..9aad0163cbd 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -69,10 +68,10 @@ herr_t H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t obj_type; /* Object type of loc_id */ hid_t file_id = H5I_INVALID_HID; /* File ID */ - H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; @@ -157,14 +156,14 @@ H5Rcreate_object(hid_t loc_id, const char *name, hid_t oapl_id, H5R_ref_t *ref_p herr_t H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t obj_type; /* Object type of loc_id */ hid_t file_id = H5I_INVALID_HID; /* File ID */ - H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - struct H5S_t * space = NULL; /* Pointer to dataspace containing region */ + struct H5S_t *space = NULL; /* Pointer to dataspace containing region */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -249,10 +248,10 @@ H5Rcreate_region(hid_t loc_id, const char *name, hid_t space_id, hid_t oapl_id, herr_t H5Rcreate_attr(hid_t loc_id, const char *name, const char *attr_name, hid_t oapl_id, H5R_ref_t *ref_ptr) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t obj_type; /* Object type of loc_id */ hid_t file_id = H5I_INVALID_HID; /* File ID */ - H5VL_object_t * vol_obj_file = NULL; /* Object of file_id */ + H5VL_object_t *vol_obj_file = NULL; /* Object of file_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; @@ -461,11 +460,11 @@ hid_t H5Ropen_object(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ - void * opened_obj = NULL; /* Opened object */ + void *opened_obj = NULL; /* Opened object */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -534,13 +533,13 @@ hid_t H5Ropen_region(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t oapl_id) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ - void * opened_obj = NULL; /* Opened object */ + void *opened_obj = NULL; /* Opened object */ hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ - H5S_t * space = NULL; /* Dataspace pointer (copy) */ + H5S_t *space = NULL; /* Dataspace pointer (copy) */ hid_t space_id = H5I_INVALID_HID; /* Dataspace ID */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -629,13 +628,13 @@ hid_t H5Ropen_attr(H5R_ref_t *ref_ptr, hid_t rapl_id, hid_t aapl_id) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ - void * opened_obj = NULL; /* Opened object */ + void *opened_obj = NULL; /* Opened object */ hid_t opened_obj_id = H5I_INVALID_HID; /* Opened object ID */ - void * opened_attr = NULL; /* Opened attribute */ + void *opened_attr = NULL; /* Opened attribute */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -727,7 +726,7 @@ herr_t H5Rget_obj_type3(H5R_ref_t *ref_ptr, hid_t rapl_id, H5O_type_t *obj_type) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ herr_t ret_value = SUCCEED; /* Return value */ @@ -836,7 +835,7 @@ ssize_t H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *buf, size_t size) { hid_t loc_id; /* Reference location ID */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ ssize_t ret_value = 0; /* Return value */ diff --git a/src/H5RS.c b/src/H5RS.c index 141ea2e4958..37c35b80d0e 100644 --- a/src/H5RS.c +++ b/src/H5RS.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -36,7 +35,7 @@ /* Private typedefs & structs */ struct H5RS_str_t { - char * s; /* String to be reference counted */ + char *s; /* String to be reference counted */ unsigned wrapped; /* Indicates that the string to be ref-counted is not copied */ unsigned n; /* Reference count of number of pointers sharing string */ }; @@ -174,8 +173,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_DIAG_OFF("cast-qual") + ret_value->s = (char *)s; + H5_GCC_DIAG_ON("cast-qual") + ret_value->wrapped = 1; ret_value->n = 1; @@ -357,7 +364,7 @@ H5RS_dup(H5RS_str_t *ret_value) H5RS_str_t * H5RS_dup_str(const char *s) { - char * new_str; /* Duplicate of string */ + char *new_str; /* Duplicate of string */ size_t path_len; /* Length of the path */ H5RS_str_t *ret_value; diff --git a/src/H5RSprivate.h b/src/H5RSprivate.h index 32e1dc66c23..9903b74e529 100644 --- a/src/H5RSprivate.h +++ b/src/H5RSprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -52,7 +51,7 @@ H5_DLL H5RS_str_t *H5RS_dup(H5RS_str_t *s); H5_DLL H5RS_str_t *H5RS_dup_str(const char *s); H5_DLL int H5RS_cmp(const H5RS_str_t *rs1, const H5RS_str_t *rs2); H5_DLL ssize_t H5RS_len(const H5RS_str_t *rs); -H5_DLL char * H5RS_get_str(const H5RS_str_t *rs); +H5_DLL char *H5RS_get_str(const H5RS_str_t *rs); H5_DLL unsigned H5RS_get_count(const H5RS_str_t *rs); #endif /* H5RSprivate_H */ diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index f78460d54f0..dc91af1ae68 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -92,7 +91,7 @@ H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref const unsigned char *buf, H5O_token_t *obj_token) { hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ - H5VL_object_t * vol_obj_file = NULL; + H5VL_object_t *vol_obj_file = NULL; H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; herr_t ret_value = SUCCEED; @@ -240,7 +239,7 @@ H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t t H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ @@ -300,12 +299,12 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ - void * opened_obj = NULL; /* Opened object */ + void *opened_obj = NULL; /* Opened object */ const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -365,14 +364,14 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref) herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ - void * vol_obj_file = NULL; - unsigned char * buf = (unsigned char *)ref; /* Return reference pointer */ + void *vol_obj_file = NULL; + unsigned char *buf = (unsigned char *)ref; /* Return reference pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -483,7 +482,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ @@ -539,12 +538,12 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ H5I_type_t opened_type; /* Opened object type */ - void * opened_obj = NULL; /* Opened object */ + void *opened_obj = NULL; /* Opened object */ const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -608,15 +607,15 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *re hid_t H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ - void * vol_obj_file = NULL; /* VOL file */ + void *vol_obj_file = NULL; /* VOL file */ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0}; - H5F_t * f = NULL; /* Native file */ + H5F_t *f = NULL; /* Native file */ size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Reference buffer size */ - H5S_t * space = NULL; /* Dataspace object */ + H5S_t *space = NULL; /* Dataspace object */ hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */ - const unsigned char * buf = (const unsigned char *)ref; /* Reference pointer */ + const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -695,7 +694,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) ssize_t H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name, size_t size) { - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */ H5VL_loc_params_t loc_params; /* Location parameters */ H5O_token_t obj_token = {0}; /* Object token */ diff --git a/src/H5Rint.c b/src/H5Rint.c index cb56a847674..d46bbe5e355 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -542,10 +541,10 @@ H5R__get_loc_id(const H5R_ref_priv_t *ref) hid_t H5R__reopen_file(H5R_ref_priv_t *ref, hid_t fapl_id) { - H5P_genplist_t * plist; /* Property list for FAPL */ - void * new_file = NULL; /* File object opened */ + H5P_genplist_t *plist; /* Property list for FAPL */ + void *new_file = NULL; /* File object opened */ H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - H5VL_object_t * vol_obj = NULL; /* VOL object for file */ + H5VL_object_t *vol_obj = NULL; /* VOL object for file */ hbool_t supported; /* Whether 'post open' operation is supported by VOL connector */ hid_t ret_value = H5I_INVALID_HID; @@ -1143,7 +1142,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() */ @@ -1171,7 +1170,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 */ @@ -1185,7 +1184,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) @@ -1218,7 +1217,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; @@ -1234,7 +1233,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) @@ -1253,9 +1252,10 @@ static herr_t H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr) { const uint8_t *p = (const uint8_t *)buf; + const uint8_t *p_end = p + *nbytes - 1; size_t buf_size = 0; unsigned rank; - H5S_t * space; + H5S_t *space; herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1265,16 +1265,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) @@ -1285,7 +1285,11 @@ H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small") if (H5S_set_extent_simple(space, rank, NULL, NULL) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set extent rank for selection") - if (H5S_SELECT_DESERIALIZE(&space, &p) < 0) + + if (p - 1 > p_end) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Ran off end of buffer while decoding") + + if (H5S_SELECT_DESERIALIZE(&space, &p, (size_t)(p_end - p + 1)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "can't deserialize selection") *nbytes = buf_size; @@ -1350,7 +1354,7 @@ H5R__decode_string(const unsigned char *buf, size_t *nbytes, char **string_ptr) { const uint8_t *p = (const uint8_t *)buf; size_t string_len; - char * string = NULL; + char *string = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -1548,8 +1552,9 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbyt unsigned char *data = NULL; H5O_token_t token = {0}; size_t data_size; - const uint8_t *p; - H5S_t * space = NULL; + const uint8_t *p = NULL; + const uint8_t *p_end = NULL; + H5S_t *space = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1564,7 +1569,8 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbyt HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get object address */ - p = (const uint8_t *)data; + p = (const uint8_t *)data; + p_end = p + data_size - 1; H5MM_memcpy(&token, p, token_size); p += token_size; @@ -1584,7 +1590,11 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbyt HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "not found") /* Unserialize the selection */ - if (H5S_SELECT_DESERIALIZE(&space, &p) < 0) + + if (p - 1 >= p_end) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Ran off end of buffer while deserializing") + + if (H5S_SELECT_DESERIALIZE(&space, &p, (size_t)(p_end - p + 1)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "can't deserialize selection") *space_ptr = space; diff --git a/src/H5Rmodule.h b/src/H5Rmodule.h index 2a34d56d7b1..eb69466f932 100644 --- a/src/H5Rmodule.h +++ b/src/H5Rmodule.h @@ -25,11 +25,17 @@ #define H5_MY_PKG_ERR H5E_REFERENCE #define H5_MY_PKG_INIT YES +/** \page H5R_UG The HDF5 References + * @todo Under Construction + */ + /** - * \defgroup H5R H5R - * \brief Reference Interface - * \details The HDF5 Reference Interface, H5R, provides a mechanism for managing - * HDF5 referenced objects. + * \defgroup H5R References (H5R) + * + * Use the functions in this module to manage HDF5 references. Referents can + * be HDF5 objects, attributes, and selections on datasets a.k.a. dataset + * regions. + * */ #endif /* H5Rmodule_H */ diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index ee5fb710d37..b4f1bbf144b 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -43,7 +42,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 */ @@ -52,19 +51,19 @@ /* Object reference */ typedef struct H5R_ref_priv_obj_t { H5O_token_t token; /* Object token */ - char * filename; /* File name */ + char *filename; /* File name */ } H5R_ref_priv_obj_t; /* Region reference */ typedef struct H5R_ref_priv_reg_t { H5R_ref_priv_obj_t obj; /* Object reference */ - H5S_t * space; /* Selection */ + H5S_t *space; /* Selection */ } H5R_ref_priv_reg_t; /* Attribute reference */ typedef struct H5R_ref_priv_attr_t { H5R_ref_priv_obj_t obj; /* Object reference */ - char * name; /* Attribute name */ + char *name; /* Attribute name */ } H5R_ref_priv_attr_t; /* Generic reference type (keep it cache aligned) */ diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h index 6d6fcd5f994..0f129d29fab 100644 --- a/src/H5Rprivate.h +++ b/src/H5Rprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index e26a72c3ee3..5d2701c5a52 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -30,9 +29,11 @@ #define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t) #define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t) + 4) -/* Default reference buffer size. - * Note! Be careful with the sizes of the references because they should really - * depend on the run-time values in the file. +/** + * Default reference buffer size. + * + * \internal Note! Be careful with the sizes of the references because they + * should really depend on the run-time values in the file. */ #define H5R_REF_BUF_SIZE (64) @@ -74,7 +75,7 @@ typedef haddr_t hobj_ref_t; /** * Buffer to store heap ID and index * - * This needs to be large enough to store largest #haddr_t in a worst case + * This needs to be large enough to store largest haddr_t in a worst case * machine (8 bytes currently) plus an int. * * \deprecated Dataset region reference type that is used with deprecated @@ -258,7 +259,7 @@ H5_DLL herr_t H5Rdestroy(H5R_ref_t *ref_ptr); * \snippet this H5R_type_t_snip * * Note that #H5R_OBJECT1 and #H5R_DATASET_REGION1 can never be - * associated to an \ref H5R_ref_t reference and can therefore never be + * associated with an \ref H5R_ref_t reference and can, therefore, never be * returned through that function. * * \ref H5R_ref_t is defined in H5Rpublic.h as: @@ -301,7 +302,7 @@ H5_DLL htri_t H5Requal(const H5R_ref_t *ref1_ptr, const H5R_ref_t *ref2_ptr); * \return \herr_t * * \details H5Rcopy() creates a copy of an existing reference. - * \p src_ref_ptr points to the reference to copy and \p dst_ref_ptr is the + * \p src_ref_ptr points to the reference to copy, and \p dst_ref_ptr is the * pointer to the destination reference. * */ @@ -335,7 +336,7 @@ H5_DLL herr_t H5Rcopy(const H5R_ref_t *src_ref_ptr, H5R_ref_t *dst_ref_ptr); * * The object opened with this function should be closed when it * is no longer needed so that resource leaks will not develop. Use - * the appropriate close function such as H5Oclose() or H5Dclose() + * the appropriate close function, such as H5Oclose() or H5Dclose() * for datasets. * */ @@ -573,7 +574,7 @@ H5_DLL ssize_t H5Rget_attr_name(const H5R_ref_t *ref_ptr, char *name, size_t siz * * A \Emph{reference type} is the type of reference, either an object * reference or a dataset region reference. An \Emph{object reference} - * points to an HDF5 object while a \Emph{dataset region reference} + * points to an HDF5 object, while a \Emph{dataset region reference} * points to a defined region within a dataset. * * The \Emph{referenced object} is the object the reference points @@ -645,7 +646,7 @@ H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref * * The object opened with this function should be closed when it is no * longer needed so that resource leaks will not develop. Use the - * appropriate close function such as H5Oclose() or H5Dclose() for + * appropriate close function, such as H5Oclose() or H5Dclose() for * datasets. * * \version 1.10.0 Function H5Rdereference() renamed to H5Rdereference1() and @@ -782,7 +783,7 @@ H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H * * The object opened with this function should be closed when it is no * longer needed so that resource leaks will not develop. Use the - * appropriate close function such as H5Oclose() or H5Dclose() for + * appropriate close function, such as H5Oclose() or H5Dclose() for * datasets. * * \since 1.10.0 diff --git a/src/H5S.c b/src/H5S.c index d45a6f135ed..008b173c9b1 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -118,7 +117,7 @@ H5S__init_package(void) if (H5I_register_type(H5I_DATASPACE_CLS) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace ID class") - /* Initialize the atom group for the dataspace selction iterator IDs */ + /* Initialize the atom group for the dataspace selection iterator IDs */ if (H5I_register_type(H5I_SPACE_SEL_ITER_CLS) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace selection iterator ID class") @@ -241,7 +240,7 @@ H5S_term_package(void) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) +H5S_get_validated_dataspace(hid_t space_id, H5S_t **space) { herr_t ret_value = SUCCEED; /* Return value */ @@ -258,7 +257,7 @@ H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space) *space = NULL; else { /* Get the dataspace pointer */ - if (NULL == (*space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + if (NULL == (*space = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "space_id is not a dataspace ID") /* Check for valid selection */ @@ -782,7 +781,7 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) hssize_t H5Sget_simple_extent_npoints(hid_t space_id) { - H5S_t * ds; + H5S_t *ds; hssize_t ret_value; FUNC_ENTER_API(FAIL) @@ -1533,7 +1532,7 @@ H5Sencode2(hid_t obj_id, void *buf, size_t *nalloc, hid_t fapl_id) herr_t H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc) { - H5F_t * f = NULL; /* Fake file structure*/ + H5F_t *f = NULL; /* Fake file structure*/ size_t extent_size; /* Size of serialized dataspace extent */ hssize_t sselect_size; /* Signed size of serialized dataspace selection */ size_t select_size; /* Size of serialized dataspace selection */ @@ -1648,13 +1647,13 @@ H5Sdecode(const void *buf) H5S_t * H5S_decode(const unsigned char **p) { - H5F_t * f = NULL; /* Fake file structure*/ - H5S_t * ds; /* Decoded dataspace */ - H5S_extent_t * extent; /* Entent of decoded dataspace */ + H5F_t *f = NULL; /* Fake file structure*/ + H5S_t *ds; /* Decoded dataspace */ + H5S_extent_t *extent; /* Extent of decoded dataspace */ const unsigned char *pp = (*p); /* Local pointer for decoding */ size_t extent_size; /* size of the extent message*/ uint8_t sizeof_size; /* 'Size of sizes' for file */ - H5S_t * ret_value = NULL; /* Return value */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1696,9 +1695,10 @@ H5S_decode(const unsigned char **p) if (H5S_select_all(ds, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") - /* Decode the select part of dataspace. I believe this part always exists. */ + /* Decode the select part of dataspace. + * Because size of buffer is unknown, assume arbitrarily large buffer to allow decoding. */ *p = pp; - if (H5S_SELECT_DESERIALIZE(&ds, p) < 0) + if (H5S_SELECT_DESERIALIZE(&ds, p, SIZE_MAX) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode space selection") /* Set return value */ @@ -1762,7 +1762,7 @@ H5S_get_simple_extent_type(const H5S_t *space) H5S_class_t H5Sget_simple_extent_type(hid_t sid) { - H5S_t * space; + H5S_t *space; H5S_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5S_NO_CLASS) @@ -1985,7 +1985,7 @@ H5Sextent_equal(hid_t space1_id, hid_t space2_id) htri_t H5S_extent_equal(ds1, ds2) H5S_t *ds1, *ds2; IN: Dataspace objects to compare RETURNS - TRUE if equal, FALSE if unequal on succeess/Negative on failure + TRUE if equal, FALSE if unequal on success/Negative on failure DESCRIPTION Compare two dataspaces if their extents are identical. --------------------------------------------------------------------------*/ diff --git a/src/H5SL.c b/src/H5SL.c index 9d3f5b390eb..a9c231d0efd 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -36,13 +35,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 +63,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 +136,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 @@ -209,7 +158,7 @@ /* Check if we need to increase allocation of forward pointers */ \ if (LVL + 1 >= 1u << X->log_nalloc) { \ H5SL_node_t **_tmp; \ - HDassert(LVL + 1 == 1u << X->log_nalloc); \ + HDassert(LVL + 1 == 1U << X->log_nalloc); \ /* Double the amount of allocated space */ \ X->log_nalloc++; \ \ @@ -225,13 +174,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 +188,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++; \ } @@ -251,7 +200,7 @@ /* Check if we can reduce the allocation of forward pointers */ \ if (LVL <= 1u << (X->log_nalloc - 1)) { \ H5SL_node_t **_tmp; \ - HDassert(LVL == 1u << (X->log_nalloc - 1)); \ + HDassert(LVL == 1U << (X->log_nalloc - 1)); \ X->log_nalloc--; \ \ /* Allocate space for new forward pointers */ \ @@ -260,7 +209,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,12 +233,12 @@ else { \ HDassert(_lvl < (size_t)SLIST->curr_level); \ X->forward[_lvl + 1] = PREV->forward[_lvl + 1]; \ - } /* end else */ \ + } \ PREV->forward[_lvl + 1] = X; \ } /* Macro used to reduce the level of a node by 1. Does not update the head node - * "current level". PREV is the previous node of the currrent height of X. */ + * "current level". PREV is the previous node of the current height of X. */ #define H5SL_DEMOTE(X, PREV) \ { \ size_t _lvl = X->level; \ @@ -305,7 +254,7 @@ #define H5SL_INSERT(CMP, SLIST, X, TYPE, KEY, HASHVAL) \ { \ H5SL_node_t *_last = X; /* Lowest node in the current gap */ \ - H5SL_node_t *_next = NULL; /* Highest node in the currect gap */ \ + H5SL_node_t *_next = NULL; /* Highest node in the current gap */ \ H5SL_node_t *_drop; /* Low node of the gap to drop into */ \ int _count; /* Number of nodes in the current gap */ \ int _i; \ @@ -322,7 +271,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 +286,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 +299,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 +308,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 current 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 */ @@ -537,14 +481,13 @@ /* Skip list node data structure */ struct H5SL_node_t { - const void * key; /* Pointer to node's key */ - void * item; /* Pointer to node's item */ + const void *key; /* Pointer to node's key */ + void *item; /* Pointer to node's item */ size_t level; /* The level of this node */ size_t log_nalloc; /* log2(Number of slots allocated in forward) */ uint32_t hashval; /* Hash value for key (only for strings, currently) */ - 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 */ + struct H5SL_node_t *backward; /* Backward pointer from this node */ }; /* Main skip list data structure */ @@ -558,8 +501,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 */ @@ -651,11 +592,11 @@ H5SL_term_package(void) 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; n++; - } /* end if */ + } /* Free the list of factories */ if (H5SL_fac_g) { @@ -663,12 +604,12 @@ H5SL_term_package(void) H5SL_fac_nalloc_g = 0; n++; - } /* end if */ + } /* Mark the interface as uninitialized */ if (0 == n) H5_PKG_INIT_VAR = FALSE; - } /* end if */ + } FUNC_LEAVE_NOAPI(n) } /* H5SL_term_package() */ @@ -711,11 +652,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 +745,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 +820,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_DIAG_OFF("cast-qual") if (op) - /* Casting away const OK -QAK */ (void)(op)(node->item, (void *)node->key, op_data); + H5_GCC_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 = @@ -982,9 +929,9 @@ H5SL__close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) H5SL_t * H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) { - H5SL_t * new_slist = NULL; /* Pointer to new skip list object created */ + H5SL_t *new_slist = NULL; /* Pointer to new skip list object created */ H5SL_node_t *header; /* Pointer to skip list header node */ - H5SL_t * ret_value = NULL; /* Return value */ + H5SL_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1001,9 +948,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 +973,7 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) 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 +1004,6 @@ H5SL_count(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -1099,9 +1042,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 +1088,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) */ @@ -1186,7 +1123,7 @@ H5SL_remove(H5SL_t *slist, const void *key) { H5SL_node_t *x; /* Current node to examine */ uint32_t hashval = 0; /* Hash value for key */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1242,7 +1179,7 @@ H5SL_remove(H5SL_t *slist, const void *key) default: HDassert(0 && "Unknown skiplist type!"); - } /* end switch */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1269,7 +1206,7 @@ H5SL_remove(H5SL_t *slist, const void *key) void * H5SL_remove_first(H5SL_t *slist) { - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ H5SL_node_t *head = slist->header; /* Skip list header */ H5SL_node_t *tmp = slist->header->forward[0]; /* Temporary node pointer */ H5SL_node_t *next; /* Next node to search for */ @@ -1281,9 +1218,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 +1279,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) @@ -1380,7 +1314,7 @@ H5SL_search(H5SL_t *slist, const void *key) { H5SL_node_t *x; /* Current node to examine */ uint32_t hashval = 0; /* Hash value for key */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1436,7 +1370,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; @@ -1472,7 +1406,7 @@ H5SL_less(H5SL_t *slist, const void *key) { H5SL_node_t *x; /* Current node to examine */ uint32_t hashval = 0; /* Hash value for key */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1480,9 +1414,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 +1462,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 +1472,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) @@ -1580,7 +1511,7 @@ H5SL_greater(H5SL_t *slist, const void *key) { H5SL_node_t *x; /* Current node to examine */ uint32_t hashval = 0; /* Hash value for key */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1588,9 +1519,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 +1567,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 +1662,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 +1754,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 +1764,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 +1859,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 +1899,6 @@ H5SL_first(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2007,9 +1932,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) */ @@ -2020,7 +1942,7 @@ H5SL_next(H5SL_node_t *slist_node) NAME H5SL_prev PURPOSE - Gets a pointer to the previos node in a skip list + Gets a pointer to the previous node in a skip list USAGE H5SL_node_t *H5SL_prev(slist_node) H5SL_node_t *slist_node; IN: Pointer to skip list node @@ -2043,9 +1965,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 +1999,6 @@ H5SL_last(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2116,9 +2032,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 +2092,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_DIAG_OFF("cast-qual") + if ((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) + break; + H5_GCC_DIAG_ON("cast-qual") /* Advance to next node */ node = next; - } /* end while */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_iterate() */ @@ -2222,9 +2141,6 @@ H5SL_release(H5SL_t *slist) /* Check args */ HDassert(slist); - /* Not currently supported */ - HDassert(!slist->safe_iterating); - /* Check internal consistency */ /* (Pre-condition) */ @@ -2233,7 +2149,7 @@ H5SL_release(H5SL_t *slist) HGOTO_ERROR(H5E_SLIST, H5E_CANTFREE, FAIL, "can't release skip list nodes") done: - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_release() */ /*-------------------------------------------------------------------------- @@ -2274,9 +2190,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) */ @@ -2288,186 +2201,6 @@ H5SL_free(H5SL_t *slist, H5SL_operator_t op, void *op_data) FUNC_LEAVE_NOAPI(ret_value) } /* end H5SL_free() */ -/*-------------------------------------------------------------------------- - 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 diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index c9e11471cd2..7aaef87eeaf 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -60,21 +59,18 @@ 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 */ /********************/ -H5_DLL H5SL_t *H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp); -H5_DLL size_t H5SL_count(H5SL_t *slist); -H5_DLL herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key); +H5_DLL H5SL_t *H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp); +H5_DLL size_t H5SL_count(H5SL_t *slist); +H5_DLL herr_t H5SL_insert(H5SL_t *slist, void *item, const void *key); H5_DLL H5SL_node_t *H5SL_add(H5SL_t *slist, void *item, const void *key); -H5_DLL void * H5SL_remove(H5SL_t *slist, const void *key); -H5_DLL void * H5SL_remove_first(H5SL_t *slist); -H5_DLL void * H5SL_search(H5SL_t *slist, const void *key); -H5_DLL void * H5SL_less(H5SL_t *slist, const void *key); -H5_DLL void * H5SL_greater(H5SL_t *slist, const void *key); +H5_DLL void *H5SL_remove(H5SL_t *slist, const void *key); +H5_DLL void *H5SL_remove_first(H5SL_t *slist); +H5_DLL void *H5SL_search(H5SL_t *slist, const void *key); +H5_DLL void *H5SL_less(H5SL_t *slist, const void *key); +H5_DLL void *H5SL_greater(H5SL_t *slist, const void *key); H5_DLL H5SL_node_t *H5SL_find(H5SL_t *slist, const void *key); H5_DLL H5SL_node_t *H5SL_below(H5SL_t *slist, const void *key); H5_DLL H5SL_node_t *H5SL_above(H5SL_t *slist, const void *key); @@ -82,11 +78,10 @@ H5_DLL H5SL_node_t *H5SL_first(H5SL_t *slist); H5_DLL H5SL_node_t *H5SL_next(H5SL_node_t *slist_node); H5_DLL H5SL_node_t *H5SL_prev(H5SL_node_t *slist_node); H5_DLL H5SL_node_t *H5SL_last(H5SL_t *slist); -H5_DLL void * H5SL_item(H5SL_node_t *slist_node); +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 int H5SL_term_interface(void); diff --git a/src/H5SM.c b/src/H5SM.c index fa446cf94f9..47c3e0fce41 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -40,10 +39,10 @@ /* Udata struct for calls to H5SM__read_iter_op */ typedef struct H5SM_read_udata_t { - H5F_t * file; /* File in which sharing is happening (in) */ + H5F_t *file; /* File in which sharing is happening (in) */ H5O_msg_crt_idx_t idx; /* Creation index of this message (in) */ size_t buf_size; /* Size of the encoded message (out) */ - void * encoding_buf; /* The encoded message (out) */ + void *encoding_buf; /* The encoded message (out) */ } H5SM_read_udata_t; /********************/ @@ -64,7 +63,7 @@ static herr_t H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *h static herr_t H5SM__decr_ref(void *record, void *op_data, hbool_t *changed); static herr_t H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, const H5O_shared_t *mesg, unsigned *cache_flags, - size_t * /*out*/ mesg_size, void ** /*out*/ encoded_mesg); + size_t */*out*/ mesg_size, void **/*out*/ encoded_mesg); static herr_t H5SM__type_to_flag(unsigned type_id, unsigned *type_flag); static herr_t H5SM__read_iter_op(H5O_t *oh, H5O_mesg_t *mesg, unsigned sequence, unsigned *oh_modified, void *_udata); @@ -117,7 +116,7 @@ H5SM_init(H5F_t *f, H5P_genplist_t *fc_plist, const H5O_loc_t *ext_loc) haddr_t table_addr = HADDR_UNDEF; /* Address of SOHM master table in file */ unsigned list_max, btree_min; /* Phase change limits for SOHM indices */ unsigned index_type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Messages types stored in each index */ - unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Message size sharing threshhold for each index */ + unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Message size sharing threshold for each index */ unsigned type_flags_used; /* Message type flags used, for sanity checking */ unsigned x; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -400,7 +399,7 @@ H5SM_type_shared(H5F_t *f, unsigned type_id) herr_t H5SM_get_fheap_addr(H5F_t *f, unsigned type_id, haddr_t *fheap_addr) { - H5SM_master_table_t * table = NULL; /* Shared object master table */ + H5SM_master_table_t *table = NULL; /* Shared object master table */ H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ ssize_t index_num; /* Which index */ herr_t ret_value = SUCCEED; /* Return value */ @@ -450,8 +449,8 @@ static herr_t H5SM__create_index(H5F_t *f, H5SM_index_header_t *header) { H5HF_create_t fheap_cparam; /* Fractal heap creation parameters */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -699,14 +698,14 @@ static herr_t H5SM__convert_list_to_btree(H5F_t *f, H5SM_index_header_t *header, H5SM_list_t **_list, H5HF_t *fheap, H5O_t *open_oh) { - H5SM_list_t * list; /* Pointer to the existing message list */ + H5SM_list_t *list; /* Pointer to the existing message list */ H5SM_mesg_key_t key; /* Key for inserting records in v2 B-tree */ H5B2_create_t bt2_cparam; /* v2 B-tree creation parameters */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ haddr_t tree_addr; /* New v2 B-tree's address */ size_t num_messages; /* Number of messages being tracked */ size_t x; - void * encoding_buf = NULL; + void *encoding_buf = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -846,7 +845,7 @@ H5SM__bt2_convert_to_list_op(const void *record, void *op_data) static herr_t H5SM__convert_btree_to_list(H5F_t *f, H5SM_index_header_t *header) { - H5SM_list_t * list = NULL; + H5SM_list_t *list = NULL; H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ haddr_t btree_addr; herr_t ret_value = SUCCEED; @@ -1073,7 +1072,7 @@ htri_t H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, void *mesg, unsigned *mesg_flags) { - H5SM_master_table_t * table = NULL; + H5SM_master_table_t *table = NULL; H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ unsigned cache_flags = H5AC__NO_FLAGS_SET; ssize_t index_num; @@ -1185,7 +1184,7 @@ H5SM_try_share(H5F_t *f, H5O_t *open_oh, unsigned defer_flags, unsigned type_id, static herr_t H5SM__incr_ref(void *record, void *_op_data, hbool_t *changed) { - H5SM_sohm_t * message = (H5SM_sohm_t *)record; + H5SM_sohm_t *message = (H5SM_sohm_t *)record; H5SM_incr_ref_opdata *op_data = (H5SM_incr_ref_opdata *)_op_data; herr_t ret_value = SUCCEED; @@ -1262,15 +1261,15 @@ static herr_t H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t defer, unsigned type_id, void *mesg, unsigned *cache_flags_ptr) { - H5SM_list_t * list = NULL; /* List index */ + H5SM_list_t *list = NULL; /* List index */ H5SM_mesg_key_t key; /* Key used to search the index */ H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ H5O_shared_t shared; /* Shared H5O message */ hbool_t found = FALSE; /* Was the message in the index? */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ size_t buf_size; /* Size of the encoded message */ - void * encoding_buf = NULL; /* Buffer for encoded message */ + void *encoding_buf = NULL; /* Buffer for encoded message */ size_t empty_pos = SIZE_MAX; /* Empty entry in list */ herr_t ret_value = SUCCEED; @@ -1565,13 +1564,13 @@ H5SM__write_mesg(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, hbool_t herr_t H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) { - H5SM_master_table_t * table = NULL; + H5SM_master_table_t *table = NULL; unsigned cache_flags = H5AC__NO_FLAGS_SET; H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ ssize_t index_num; size_t mesg_size = 0; - void * mesg_buf = NULL; - void * native_mesg = NULL; + void *mesg_buf = NULL; + void *native_mesg = NULL; unsigned type_id; /* Message type ID to operate on */ herr_t ret_value = SUCCEED; @@ -1602,7 +1601,7 @@ H5SM_delete(H5F_t *f, H5O_t *open_oh, H5O_shared_t *sh_mesg) */ if (H5SM__delete_from_index(f, open_oh, &(table->indexes[index_num]), sh_mesg, &cache_flags, &mesg_size, &mesg_buf) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete mesage from SOHM index") + HGOTO_ERROR(H5E_SOHM, H5E_CANTDELETE, FAIL, "unable to delete message from SOHM index") /* Release the master SOHM table */ if (H5AC_unprotect(f, H5AC_SOHM_TABLE, H5F_SOHM_ADDR(f), table, cache_flags) < 0) @@ -1777,14 +1776,14 @@ static herr_t H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, const H5O_shared_t *mesg, unsigned *cache_flags, size_t *mesg_size /*out*/, void **encoded_mesg /*out*/) { - H5SM_list_t * list = NULL; + H5SM_list_t *list = NULL; H5SM_mesg_key_t key; H5SM_sohm_t message; /* Deleted message returned from index */ - H5SM_sohm_t * message_ptr; /* Pointer to deleted message returned from index */ - H5HF_t * fheap = NULL; /* Fractal heap that contains the message */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5SM_sohm_t *message_ptr; /* Pointer to deleted message returned from index */ + H5HF_t *fheap = NULL; /* Fractal heap that contains the message */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ size_t buf_size; /* Size of the encoded message (out) */ - void * encoding_buf = NULL; /* The encoded message (out) */ + void *encoding_buf = NULL; /* The encoded message (out) */ unsigned type_id; /* Message type to operate on */ herr_t ret_value = SUCCEED; @@ -1972,7 +1971,7 @@ H5SM__delete_from_index(H5F_t *f, H5O_t *open_oh, H5SM_index_header_t *header, c herr_t H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist) { - H5F_t * f = ext_loc->file; /* File pointer (convenience variable) */ + H5F_t *f = ext_loc->file; /* File pointer (convenience variable) */ H5O_shmesg_table_t sohm_table; /* SOHM message from superblock extension */ H5SM_master_table_t *table = NULL; /* SOHM master table */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ @@ -2128,7 +2127,7 @@ static herr_t H5SM__get_refcount_bt2_cb(const void *_record, void *_op_data) { const H5SM_sohm_t *record = (const H5SM_sohm_t *)_record; /* v2 B-tree record for message */ - H5SM_sohm_t * op_data = (H5SM_sohm_t *)_op_data; /* "op data" from v2 B-tree find */ + H5SM_sohm_t *op_data = (H5SM_sohm_t *)_op_data; /* "op data" from v2 B-tree find */ FUNC_ENTER_STATIC_NOERR @@ -2159,17 +2158,17 @@ H5SM__get_refcount_bt2_cb(const void *_record, void *_op_data) herr_t H5SM_get_refcount(H5F_t *f, unsigned type_id, const H5O_shared_t *sh_mesg, hsize_t *ref_count) { - H5HF_t * fheap = NULL; /* Fractal heap that contains shared messages */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ - H5SM_master_table_t * table = NULL; /* SOHM master table */ + H5HF_t *fheap = NULL; /* Fractal heap that contains shared messages */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ + H5SM_master_table_t *table = NULL; /* SOHM master table */ H5SM_table_cache_ud_t tbl_cache_udata; /* User-data for callback */ - H5SM_list_t * list = NULL; /* SOHM index list for message type (if in list form) */ - H5SM_index_header_t * header = NULL; /* Index header for message type */ + H5SM_list_t *list = NULL; /* SOHM index list for message type (if in list form) */ + H5SM_index_header_t *header = NULL; /* Index header for message type */ H5SM_mesg_key_t key; /* Key for looking up message */ H5SM_sohm_t message; /* Shared message returned from callback */ ssize_t index_num; /* Table index for message type */ size_t buf_size; /* Size of the encoded message */ - void * encoding_buf = NULL; /* Buffer for encoded message */ + void *encoding_buf = NULL; /* Buffer for encoded message */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_TAG(H5AC__SOHM_TAG) @@ -2386,7 +2385,7 @@ H5SM__read_mesg(H5F_t *f, const H5SM_sohm_t *mesg, H5HF_t *fheap, H5O_t *open_oh { H5SM_read_udata_t udata; /* User data for callbacks */ H5O_loc_t oloc; /* Object location for message in object header */ - H5O_t * oh = NULL; /* Object header for message in object header */ + H5O_t *oh = NULL; /* Object header for message in object header */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC @@ -2540,7 +2539,7 @@ herr_t H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwidth, unsigned table_vers, unsigned num_indexes) { - H5SM_master_table_t * table = NULL; /* SOHM master table */ + H5SM_master_table_t *table = NULL; /* SOHM master table */ H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ unsigned x; /* Counter variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2628,11 +2627,11 @@ H5SM_table_debug(H5F_t *f, haddr_t table_addr, FILE *stream, int indent, int fwi herr_t H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidth, haddr_t table_addr) { - H5SM_master_table_t * table = NULL; /* SOHM master table */ - H5SM_list_t * list = NULL; /* SOHM index list for message type (if in list form) */ + H5SM_master_table_t *table = NULL; /* SOHM master table */ + H5SM_list_t *list = NULL; /* SOHM index list for message type (if in list form) */ H5SM_list_cache_ud_t lst_cache_udata; /* List user-data for metadata cache callback */ H5SM_table_cache_ud_t tbl_cache_udata; /* Table user-data for metadata cache callback */ - H5HF_t * fh = NULL; /* Fractal heap for SOHM messages */ + H5HF_t *fh = NULL; /* Fractal heap for SOHM messages */ unsigned index_num; /* Index of list, within master table */ unsigned x; /* Counter variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2736,10 +2735,10 @@ H5SM_list_debug(H5F_t *f, haddr_t list_addr, FILE *stream, int indent, int fwidt herr_t H5SM_ih_size(H5F_t *f, hsize_t *hdr_size, H5_ih_info_t *ih_info) { - H5SM_master_table_t * table = NULL; /* SOHM master table */ + H5SM_master_table_t *table = NULL; /* SOHM master table */ H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ + H5HF_t *fheap = NULL; /* Fractal heap handle */ + H5B2_t *bt2 = NULL; /* v2 B-tree handle for index */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index 2dca9fdefc8..a23e1189c4e 100644 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -40,7 +39,7 @@ /********************/ /* v2 B-tree callbacks */ -static void * H5SM__bt2_crt_context(void *udata); +static void *H5SM__bt2_crt_context(void *udata); static herr_t H5SM__bt2_dst_context(void *ctx); static herr_t H5SM__bt2_store(void *native, const void *udata); static herr_t H5SM__bt2_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); @@ -86,9 +85,9 @@ H5FL_DEFINE_STATIC(H5SM_bt2_ctx_t); static void * H5SM__bt2_crt_context(void *_f) { - H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ + H5F_t *f = (H5F_t *)_f; /* User data for building callback context */ H5SM_bt2_ctx_t *ctx; /* Callback context structure */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5SMcache.c b/src/H5SMcache.c index 2ad467f1721..10e592968be 100644 --- a/src/H5SMcache.c +++ b/src/H5SMcache.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -54,14 +53,14 @@ /* Metadata cache (H5AC) callbacks */ static herr_t H5SM__cache_table_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5SM__cache_table_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5SM__cache_table_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5SM__cache_table_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5SM__cache_table_image_len(const void *thing, size_t *image_len); static herr_t H5SM__cache_table_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5SM__cache_table_free_icr(void *thing); static herr_t H5SM__cache_list_get_initial_load_size(void *udata, size_t *image_len); static htri_t H5SM__cache_list_verify_chksum(const void *image_ptr, size_t len, void *udata_ptr); -static void * H5SM__cache_list_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); +static void *H5SM__cache_list_deserialize(const void *image, size_t len, void *udata, hbool_t *dirty); static herr_t H5SM__cache_list_image_len(const void *thing, size_t *image_len); static herr_t H5SM__cache_list_serialize(const H5F_t *f, void *image, size_t len, void *thing); static herr_t H5SM__cache_list_free_icr(void *thing); @@ -200,13 +199,13 @@ static void * H5SM__cache_table_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5F_t * f; /* File pointer -- from user data */ - H5SM_master_table_t * table = NULL; /* Shared message table that we deserializing */ + H5F_t *f; /* File pointer -- from user data */ + H5SM_master_table_t *table = NULL; /* Shared message table that we deserializing */ H5SM_table_cache_ud_t *udata = (H5SM_table_cache_ud_t *)_udata; /* Pointer to user data */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into input buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into input buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ size_t u; /* Counter variable for index headers */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -352,7 +351,7 @@ static herr_t H5SM__cache_table_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { H5SM_master_table_t *table = (H5SM_master_table_t *)_thing; /* Shared message table to encode */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t computed_chksum; /* Computed metadata checksum value */ size_t u; /* Counter variable */ @@ -507,7 +506,7 @@ H5SM__cache_list_get_initial_load_size(void *_udata, size_t *image_len) htri_t H5SM__cache_list_verify_chksum(const void *_image, size_t H5_ATTR_UNUSED len, void *_udata) { - const uint8_t * image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ H5SM_list_cache_ud_t *udata = (H5SM_list_cache_ud_t *)_udata; /* User data for callback */ size_t chk_size; /* Exact size of the node with checksum at the end */ uint32_t stored_chksum; /* Stored metadata checksum value */ @@ -551,13 +550,13 @@ static void * H5SM__cache_list_deserialize(const void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_udata, hbool_t H5_ATTR_UNUSED *dirty) { - H5SM_list_t * list = NULL; /* The SOHM list being read in */ + H5SM_list_t *list = NULL; /* The SOHM list being read in */ H5SM_list_cache_ud_t *udata = (H5SM_list_cache_ud_t *)_udata; /* User data for callback */ H5SM_bt2_ctx_t ctx; /* Message encoding context */ - const uint8_t * image = (const uint8_t *)_image; /* Pointer into input buffer */ + const uint8_t *image = (const uint8_t *)_image; /* Pointer into input buffer */ uint32_t stored_chksum; /* Stored metadata checksum value */ size_t u; /* Counter variable for messages in list */ - void * ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -667,9 +666,9 @@ H5SM__cache_list_image_len(const void *_thing, size_t *image_len) static herr_t H5SM__cache_list_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_NDEBUG_UNUSED len, void *_thing) { - H5SM_list_t * list = (H5SM_list_t *)_thing; /* Instance being serialized */ + H5SM_list_t *list = (H5SM_list_t *)_thing; /* Instance being serialized */ H5SM_bt2_ctx_t ctx; /* Message encoding context */ - uint8_t * image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ uint32_t computed_chksum; /* Computed metadata checksum value */ size_t mesgs_serialized; /* Number of messages serialized */ size_t u; /* Local index variable */ diff --git a/src/H5SMmessage.c b/src/H5SMmessage.c index 4499b0c3069..c066626c045 100644 --- a/src/H5SMmessage.c +++ b/src/H5SMmessage.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -178,7 +177,7 @@ herr_t H5SM__message_compare(const void *rec1, const void *rec2, int *result) { const H5SM_mesg_key_t *key = (const H5SM_mesg_key_t *)rec1; - const H5SM_sohm_t * mesg = (const H5SM_sohm_t *)rec2; + const H5SM_sohm_t *mesg = (const H5SM_sohm_t *)rec2; herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -279,7 +278,7 @@ H5SM__message_compare(const void *rec1, const void *rec2, int *result) herr_t H5SM__message_encode(uint8_t *raw, const void *_nrecord, void *_ctx) { - H5SM_bt2_ctx_t * ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ + H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ const H5SM_sohm_t *message = (const H5SM_sohm_t *)_nrecord; FUNC_ENTER_PACKAGE_NOERR @@ -323,7 +322,7 @@ herr_t H5SM__message_decode(const uint8_t *raw, void *_nrecord, void *_ctx) { H5SM_bt2_ctx_t *ctx = (H5SM_bt2_ctx_t *)_ctx; /* Callback context structure */ - H5SM_sohm_t * message = (H5SM_sohm_t *)_nrecord; + H5SM_sohm_t *message = (H5SM_sohm_t *)_nrecord; FUNC_ENTER_PACKAGE_NOERR diff --git a/src/H5SMpkg.h b/src/H5SMpkg.h index ae9a5f630a1..6e446015b7c 100644 --- a/src/H5SMpkg.h +++ b/src/H5SMpkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -180,7 +179,7 @@ typedef struct { H5AC_info_t cache_info; H5SM_index_header_t *header; /* Pointer to the corresponding index header */ - H5SM_sohm_t * messages; /* Actual list, stored as an array */ + H5SM_sohm_t *messages; /* Actual list, stored as an array */ } H5SM_list_t; /* Typedef for shared object header message master table */ @@ -195,9 +194,9 @@ struct H5SM_master_table_t { /* Typedef for searching an index (list or B-tree) */ typedef struct { - H5F_t * file; /* File in which sharing is happening */ - H5HF_t * fheap; /* The heap for this message type, open. */ - void * encoding; /* The message encoded, or NULL */ + H5F_t *file; /* File in which sharing is happening */ + H5HF_t *fheap; /* The heap for this message type, open. */ + void *encoding; /* The message encoded, or NULL */ size_t encoding_size; /* Size of the encoding, or 0 */ H5SM_sohm_t message; /* The message to find/insert. * If the message doesn't yet have a @@ -234,7 +233,7 @@ typedef struct H5SM_table_cache_ud_t { /* Callback info for loading a shared message list index into the cache */ typedef struct H5SM_list_cache_ud_t { - H5F_t * f; /* File that shared message index stored as a table is in */ + H5F_t *f; /* File that shared message index stored as a table is in */ H5SM_index_header_t *header; /* Index header for this list */ } H5SM_list_cache_ud_t; diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h index efe9355516a..95f831edff2 100644 --- a/src/H5SMprivate.h +++ b/src/H5SMprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5SMtest.c b/src/H5SMtest.c index d6f96be1cab..72f6547c320 100644 --- a/src/H5SMtest.c +++ b/src/H5SMtest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -78,7 +77,7 @@ H5SM__get_mesg_count_test(H5F_t *f, unsigned type_id, size_t *mesg_count) /* Check for shared messages being enabled */ if (H5F_addr_defined(H5F_SOHM_ADDR(f))) { - H5SM_index_header_t * header; /* Index header for message type */ + H5SM_index_header_t *header; /* Index header for message type */ H5SM_table_cache_ud_t cache_udata; /* User-data for callback */ ssize_t index_num; /* Table index for message type */ diff --git a/src/H5Sall.c b/src/H5Sall.c index 35ddf3d599a..00ab1e23193 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -49,22 +48,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 herr_t H5S__all_deserialize(H5S_t **space, const 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, const size_t p_size, hbool_t skip); 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 +143,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 +556,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 +576,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 +591,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 */ @@ -638,13 +637,13 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__all_deserialize(H5S_t **space, const uint8_t **p) +H5S__all_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, hbool_t skip) { - uint32_t version; /* Version number */ - H5S_t * tmp_space = NULL; /* Pointer to actual dataspace to use, - either *space or a newly allocated one */ - herr_t ret_value = SUCCEED; /* return value */ - + uint32_t version; /* Version number */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + herr_t ret_value = SUCCEED; /* return value */ + const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */ FUNC_ENTER_STATIC HDassert(p); @@ -664,12 +663,16 @@ H5S__all_deserialize(H5S_t **space, const uint8_t **p) tmp_space = *space; /* Decode version */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *p, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection version") UINT32DECODE(*p, version); if (version < H5S_ALL_VERSION_1 || version > H5S_ALL_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for all selection") /* Skip over the remainder of the header */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *p, 8, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding header") *p += 8; /* Change to "all" selection */ @@ -864,7 +867,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 +880,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 +897,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 +910,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 +960,7 @@ H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) 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 +973,7 @@ H5S__all_shape_same(const H5S_t *space1, const H5S_t *space2) 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/H5Sdbg.c b/src/H5Sdbg.c index d20916b026b..f4d027b99ba 100644 --- a/src/H5Sdbg.c +++ b/src/H5Sdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Sdeprec.c b/src/H5Sdeprec.c index d050102e41b..0ca9e9faca2 100644 --- a/src/H5Sdeprec.c +++ b/src/H5Sdeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 029adad4b21..db8d5736c22 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -84,10 +83,10 @@ typedef hsize_t hbounds_t; * H5S__hyper_project_intersect() */ typedef struct { const H5S_hyper_span_t - * ds_span[H5S_MAX_RANK]; /* Array of the current spans in the destination space in each dimension */ + *ds_span[H5S_MAX_RANK]; /* Array of the current spans in the destination space in each dimension */ hsize_t ds_low[H5S_MAX_RANK]; /* Array of current low bounds (of iteration) for each element in ds_span */ H5S_hyper_span_info_t - * ps_span_info[H5S_MAX_RANK]; /* Array of span info structs for projected space during iteration */ + *ps_span_info[H5S_MAX_RANK]; /* Array of span info structs for projected space during iteration */ uint32_t ps_clean_bitmap; /* Bitmap of whether the nth rank has a clean projected space since the last time it was set to 1 */ unsigned ss_rank; /* Rank of source space */ @@ -109,7 +108,7 @@ typedef struct { /********************/ /* Local Prototypes */ /********************/ -static H5S_hyper_span_t * H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, +static H5S_hyper_span_t *H5S__hyper_new_span(hsize_t low, hsize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next); static H5S_hyper_span_info_t *H5S__hyper_new_span_info(unsigned rank); static H5S_hyper_span_info_t *H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, @@ -152,7 +151,7 @@ static herr_t H5S__set_regular_hyperslab(H5S_t *space, const hsize_t start[], c const hsize_t *opt_stride, const hsize_t opt_count[], const hsize_t *opt_block); static herr_t H5S__fill_in_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2, H5S_t **result); -static H5S_t * H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2); +static H5S_t *H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2); static herr_t H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); static herr_t H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, @@ -160,7 +159,7 @@ static herr_t H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t max static herr_t H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len); static herr_t H5S__hyper_proj_int_build_proj(H5S_hyper_project_intersect_ud_t *udata); -static herr_t H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, +static herr_t H5S__hyper_proj_int_iterate(H5S_hyper_span_info_t *ss_span_info, const H5S_hyper_span_info_t *sis_span_info, hsize_t count, unsigned depth, H5S_hyper_project_intersect_ud_t *udata); static void H5S__hyper_get_clip_diminfo(hsize_t start, hsize_t stride, hsize_t *count, hsize_t *block, @@ -173,23 +172,23 @@ 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 herr_t H5S__hyper_deserialize(H5S_t **space, const 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, const size_t p_size, hbool_t skip); 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); 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); @@ -295,12 +294,12 @@ H5S__hyper_print_spans_helper(FILE *f, const H5S_hyper_span_t *span, unsigned de FUNC_ENTER_STATIC_NOERR while (span) { - HDfprintf(f, "%s: %*sdepth=%u, span=%p, (%Hu, %Hu), next=%p\n", FUNC, depth * 2, "", depth, span, - span->low, span->high, span->next); + HDfprintf(f, "%s: %*sdepth=%u, span=%p, (%" PRIuHSIZE ", %" PRIuHSIZE "), next=%p\n", FUNC, depth * 2, + "", depth, (void *)span, span->low, span->high, (void *)span->next); if (span->down) { - HDfprintf(f, "%s: %*sspans=%p, count=%u, bounds[0]={%Hu, %Hu}, head=%p\n", FUNC, (depth + 1) * 2, - "", span->down, span->down->count, span->down->low_bounds[0], - span->down->high_bounds[0], span->down->head); + HDfprintf(f, "%s: %*sspans=%p, count=%u, bounds[0]={%" PRIuHSIZE ", %" PRIuHSIZE "}, head=%p\n", + FUNC, (depth + 1) * 2, "", (void *)span->down, span->down->count, + span->down->low_bounds[0], span->down->high_bounds[0], (void *)span->down->head); H5S__hyper_print_spans_helper(f, span->down->head, depth + 1); } /* end if */ span = span->next; @@ -315,8 +314,9 @@ H5S__hyper_print_spans(FILE *f, const H5S_hyper_span_info_t *span_lst) FUNC_ENTER_STATIC_NOERR if (span_lst != NULL) { - HDfprintf(f, "%s: spans=%p, count=%u, bounds[0]={%Hu, %Hu}, head=%p\n", FUNC, span_lst, - span_lst->count, span_lst->low_bounds[0], span_lst->high_bounds[0], span_lst->head); + HDfprintf(f, "%s: spans=%p, count=%u, bounds[0]={%" PRIuHSIZE ", %" PRIuHSIZE "}, head=%p\n", FUNC, + (void *)span_lst, span_lst->count, span_lst->low_bounds[0], span_lst->high_bounds[0], + (void *)span_lst->head); H5S__hyper_print_spans_helper(f, span_lst->head, 0); } /* end if */ @@ -343,16 +343,16 @@ H5S__hyper_print_diminfo_helper(FILE *f, const char *field, unsigned ndims, cons if (dinfo != NULL) { HDfprintf(f, "%s: %s: start=[", FUNC, field); for (u = 0; u < ndims; u++) - HDfprintf(f, "%Hd%s", dinfo[u].start, (u < (ndims - 1) ? ", " : "]\n")); + HDfprintf(f, "%" PRIuHSIZE "%s", dinfo[u].start, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: stride=[", FUNC, field); for (u = 0; u < ndims; u++) - HDfprintf(f, "%Hu%s", dinfo[u].stride, (u < (ndims - 1) ? ", " : "]\n")); + HDfprintf(f, "%" PRIuHSIZE "%s", dinfo[u].stride, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: count=[", FUNC, field); for (u = 0; u < ndims; u++) - HDfprintf(f, "%Hu%s", dinfo[u].count, (u < (ndims - 1) ? ", " : "]\n")); + HDfprintf(f, "%" PRIuHSIZE "%s", dinfo[u].count, (u < (ndims - 1) ? ", " : "]\n")); HDfprintf(f, "%s: %s: block=[", FUNC, field); for (u = 0; u < ndims; u++) - HDfprintf(f, "%Hu%s", dinfo[u].block, (u < (ndims - 1) ? ", " : "]\n")); + HDfprintf(f, "%" PRIuHSIZE "%s", dinfo[u].block, (u < (ndims - 1) ? ", " : "]\n")); } /* end if */ else HDfprintf(f, "%s: %s==NULL\n", FUNC, field); @@ -411,31 +411,31 @@ H5S__hyper_print_spans_dfs(FILE *f, const H5S_hyper_span_info_t *span_lst, unsig for (u = 0; u < depth; u++) HDfprintf(f, "\t"); - HDfprintf(f, "DIM[%u]: ref_count=%u, #elems=%u, head=%p, tail=%p, actual_tail=%p, matched=%t\n", depth, - span_lst->count, num_elems, span_lst->head, span_lst->tail, actual_tail, + HDfprintf(f, "DIM[%u]: ref_count=%u, #elems=%u, head=%p, tail=%p, actual_tail=%p, matched=%d\n", depth, + span_lst->count, num_elems, (void *)span_lst->head, (void *)span_lst->tail, (void *)actual_tail, (span_lst->tail == actual_tail)); for (u = 0; u < depth; u++) HDfprintf(f, "\t"); HDfprintf(f, "low_bounds=["); for (u = 0; u < dims - 1; u++) - HDfprintf(f, "%llu,", span_lst->low_bounds[u]); - HDfprintf(f, "%llu]\n", span_lst->low_bounds[dims - 1]); + HDfprintf(f, "%" PRIuHSIZE ",", span_lst->low_bounds[u]); + HDfprintf(f, "%" PRIuHSIZE "]\n", span_lst->low_bounds[dims - 1]); for (u = 0; u < depth; u++) HDfprintf(f, "\t"); HDfprintf(f, "high_bounds=["); for (u = 0; u < dims - 1; u++) - HDfprintf(f, "%llu,", span_lst->high_bounds[u]); - HDfprintf(f, "%llu]\n", span_lst->high_bounds[dims - 1]); + HDfprintf(f, "%" PRIuHSIZE ",", span_lst->high_bounds[u]); + HDfprintf(f, "%" PRIuHSIZE "]\n", span_lst->high_bounds[dims - 1]); cur_elem = span_lst->head; elem_idx = 0; while (cur_elem) { for (u = 0; u < depth; u++) HDfprintf(f, "\t"); - HDfprintf(f, "ELEM[%u]: ptr=%p, low=%Hu, high=%Hu, down=%p\n", elem_idx++, cur_elem, cur_elem->low, - cur_elem->high, cur_elem->down); + HDfprintf(f, "ELEM[%u]: ptr=%p, low=%" PRIuHSIZE ", high=%" PRIuHSIZE ", down=%p\n", elem_idx++, + (void *)cur_elem, cur_elem->low, cur_elem->high, (void *)cur_elem->down); if (cur_elem->down) H5S__hyper_print_spans_dfs(f, cur_elem->down, depth + 1, dims); cur_elem = cur_elem->next; @@ -472,7 +472,7 @@ H5S__hyper_print_space_dfs(FILE *f, const H5S_t *space) HDassert(hslab); HDfprintf(f, "=======================\n"); - HDfprintf(f, "SPACE: span_lst=%p, #dims=%u, offset_changed=%d\n", hslab->span_lst, dims, + HDfprintf(f, "SPACE: span_lst=%p, #dims=%u, offset_changed=%d\n", (void *)hslab->span_lst, dims, space->select.offset_changed); HDfprintf(f, " offset=["); @@ -483,25 +483,25 @@ H5S__hyper_print_space_dfs(FILE *f, const H5S_t *space) HDfprintf(f, " low_bounds=["); if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { for (u = 0; u < dims - 1; u++) - HDfprintf(f, "%llu,", space->select.sel_info.hslab->diminfo.low_bounds[u]); - HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->diminfo.low_bounds[dims - 1]); + HDfprintf(f, "%" PRIuHSIZE ",", space->select.sel_info.hslab->diminfo.low_bounds[u]); + HDfprintf(f, "%" PRIuHSIZE "]\n", space->select.sel_info.hslab->diminfo.low_bounds[dims - 1]); } /* end if */ else { for (u = 0; u < dims - 1; u++) - HDfprintf(f, "%llu,", space->select.sel_info.hslab->span_lst->low_bounds[u]); - HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->span_lst->low_bounds[dims - 1]); + HDfprintf(f, "%" PRIuHSIZE ",", space->select.sel_info.hslab->span_lst->low_bounds[u]); + HDfprintf(f, "%" PRIuHSIZE "]\n", space->select.sel_info.hslab->span_lst->low_bounds[dims - 1]); } /* end else */ HDfprintf(f, " high_bounds=["); if (space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) { for (u = 0; u < dims - 1; u++) - HDfprintf(f, "%llu,", space->select.sel_info.hslab->diminfo.high_bounds[u]); - HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->diminfo.high_bounds[dims - 1]); + HDfprintf(f, "%" PRIuHSIZE ",", space->select.sel_info.hslab->diminfo.high_bounds[u]); + HDfprintf(f, "%" PRIuHSIZE "]\n", space->select.sel_info.hslab->diminfo.high_bounds[dims - 1]); } /* end if */ else { for (u = 0; u < dims - 1; u++) - HDfprintf(f, "%llu,", space->select.sel_info.hslab->span_lst->high_bounds[u]); - HDfprintf(f, "%llu]\n", space->select.sel_info.hslab->span_lst->high_bounds[dims - 1]); + HDfprintf(f, "%" PRIuHSIZE ",", space->select.sel_info.hslab->span_lst->high_bounds[u]); + HDfprintf(f, "%" PRIuHSIZE "]\n", space->select.sel_info.hslab->span_lst->high_bounds[dims - 1]); } /* end else */ /* Print out diminfo, if it's valid */ @@ -558,7 +558,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 */ @@ -585,13 +585,13 @@ 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) { /* Initialize the information needed for regular hyperslab I/O */ const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - const hsize_t * mem_size; /* Temporary pointer to dataspace extent's dimension sizes */ + const hsize_t *mem_size; /* Temporary pointer to dataspace extent's dimension sizes */ unsigned cont_dim = 0; /* # of contiguous dimensions */ /* Set the temporary pointer to the dimension information */ @@ -969,7 +969,7 @@ H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter) /* Check for a single "regular" hyperslab */ if (iter->u.hyp.diminfo_valid) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - const hsize_t * toff; /* Temporary offset in selection */ + const hsize_t *toff; /* Temporary offset in selection */ /* Check if the offset of the iterator is at the last location in all dimensions */ tdiminfo = iter->u.hyp.diminfo; @@ -1103,9 +1103,9 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) } /* end if */ /* Must be an irregular hyperslab selection */ else { - H5S_hyper_span_t * curr_span = NULL; /* Current hyperslab span node */ + H5S_hyper_span_t *curr_span = NULL; /* Current hyperslab span node */ H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t * abs_arr; /* Absolute hyperslab span position */ + hsize_t *abs_arr; /* Absolute hyperslab span position */ int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ @@ -1295,9 +1295,9 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) } /* end if */ /* Must be an irregular hyperslab selection */ else { - H5S_hyper_span_t * curr_span = NULL; /* Current hyperslab span node */ + H5S_hyper_span_t *curr_span = NULL; /* Current hyperslab span node */ H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t * abs_arr; /* Absolute hyperslab span position */ + hsize_t *abs_arr; /* Absolute hyperslab span position */ int curr_dim; /* Temporary rank holder */ /* Set the rank of the fastest changing dimension */ @@ -1411,14 +1411,14 @@ static herr_t H5S__hyper_iter_get_seq_list_gen(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) { - H5S_hyper_span_t * curr_span; /* Current hyperslab span node */ + H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t * slab; /* Cumulative size of each dimension in bytes */ + hsize_t *slab; /* Cumulative size of each dimension in bytes */ hsize_t loc_off; /* Byte offset in the dataspace */ hsize_t last_span_end = 0; /* The offset of the end of the last span */ - hsize_t * abs_arr; /* Absolute hyperslab span position, in elements */ - hsize_t * loc_arr; /* Byte offset of hyperslab span position within buffer */ - const hssize_t * sel_off; /* Offset within the dataspace extent */ + hsize_t *abs_arr; /* Absolute hyperslab span position, in elements */ + hsize_t *loc_arr; /* Byte offset of hyperslab span position within buffer */ + const hssize_t *sel_off; /* Offset within the dataspace extent */ size_t span_elmts = 0; /* Number of elements to actually use for this span */ size_t span_size = 0; /* Number of bytes in current span to actually process */ size_t io_left; /* Initial number of elements to process */ @@ -1873,9 +1873,9 @@ static herr_t H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) { - hsize_t * mem_size; /* Size of the source buffer */ - hsize_t * slab; /* Hyperslab size */ - const hssize_t * sel_off; /* Selection offset in dataspace */ + hsize_t *mem_size; /* Size of the source buffer */ + hsize_t *slab; /* Hyperslab size */ + const hssize_t *sel_off; /* Selection offset in dataspace */ hsize_t offset[H5S_MAX_RANK]; /* Coordinate offset in dataspace */ hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary block count */ hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block offset */ @@ -2059,7 +2059,7 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Increment the offset and count for the other dimensions */ temp_dim = (int)fast_dim - 1; while (temp_dim >= 0) { - /* Move to the next row in the curent dimension */ + /* Move to the next row in the current dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; @@ -2177,7 +2177,7 @@ H5S__hyper_iter_get_seq_list_opt(H5S_sel_iter_t *iter, size_t maxseq, size_t max /* Increment the offset and count for the other dimensions */ temp_dim = (int)fast_dim - 1; while (temp_dim >= 0) { - /* Move to the next row in the curent dimension */ + /* Move to the next row in the current dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; @@ -2325,11 +2325,11 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t size_t *nelem, hsize_t *off, size_t *len) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - const hssize_t * sel_off; /* Selection offset in dataspace */ - hsize_t * mem_size; /* Size of the source buffer */ + const hssize_t *sel_off; /* Selection offset in dataspace */ + hsize_t *mem_size; /* Size of the source buffer */ hsize_t base_offset[H5S_MAX_RANK]; /* Base coordinate offset in dataspace */ hsize_t offset[H5S_MAX_RANK]; /* Coordinate offset in dataspace */ - hsize_t * slab; /* Hyperslab size */ + hsize_t *slab; /* Hyperslab size */ hsize_t fast_dim_block; /* Local copies of fastest changing dimension info */ hsize_t loc; /* Coordinate offset */ size_t tot_blk_count; /* Total number of blocks left to output */ @@ -2491,7 +2491,7 @@ H5S__hyper_iter_get_seq_list_single(H5S_sel_iter_t *iter, size_t maxseq, size_t /* Increment the offset and count for the other dimensions */ while (temp_dim >= 0) { - /* Move to the next row in the curent dimension */ + /* Move to the next row in the current dimension */ offset[temp_dim]++; tmp_block[temp_dim]++; @@ -2619,7 +2619,7 @@ H5S__hyper_iter_get_seq_list(H5S_sel_iter_t *iter, size_t maxseq, size_t maxelem /* Check for the special case of just one H5Sselect_hyperslab call made */ if (iter->u.hyp.diminfo_valid) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ - const hssize_t * sel_off; /* Selection offset in dataspace */ + const hssize_t *sel_off; /* Selection offset in dataspace */ unsigned ndims; /* Number of dimensions of dataset */ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ hbool_t single_block; /* Whether the selection is a single block */ @@ -2878,9 +2878,9 @@ H5S__hyper_new_span_info(unsigned rank) static H5S_hyper_span_info_t * H5S__hyper_copy_span_helper(H5S_hyper_span_info_t *spans, unsigned rank, unsigned op_info_i, uint64_t op_gen) { - H5S_hyper_span_t * span; /* Hyperslab span */ - H5S_hyper_span_t * new_span; /* Temporary hyperslab span */ - H5S_hyper_span_t * prev_span; /* Previous hyperslab span */ + H5S_hyper_span_t *span; /* Hyperslab span */ + H5S_hyper_span_t *new_span; /* Temporary hyperslab span */ + H5S_hyper_span_t *prev_span; /* Previous hyperslab span */ H5S_hyper_span_info_t *new_down; /* New down span tree */ H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ @@ -3208,7 +3208,7 @@ H5S__hyper_free_span(H5S_hyper_span_t *span) static herr_t H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) { - H5S_hyper_sel_t * dst_hslab; /* Pointer to destination hyperslab info */ + H5S_hyper_sel_t *dst_hslab; /* Pointer to destination hyperslab info */ const H5S_hyper_sel_t *src_hslab; /* Pointer to source hyperslab info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3483,7 +3483,7 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref) hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid) { - H5S_t * space; /* Dataspace to modify selection of */ + H5S_t *space; /* Dataspace to modify selection of */ hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) @@ -3512,7 +3512,7 @@ H5Sget_select_hyper_nblocks(hid_t spaceid) USAGE hssize_t H5S__hyper_get_enc_size_real(max_size, enc_size) hsize_t max_size: IN: The maximum size of the hyperslab selection info - unint8_t *enc_size: OUT:The encoding size + uint8_t *enc_size: OUT:The encoding size RETURNS The size to encode hyperslab selection info DESCRIPTION @@ -3574,7 +3574,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 */ @@ -3583,7 +3583,7 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ H5F_libver_t low_bound; /* The 'low' bound of library format versions */ H5F_libver_t high_bound; /* The 'high' bound of library format versions */ htri_t is_regular; /* A regular hyperslab or not */ - uint32_t tmp_version; /* Local temporay version */ + uint32_t tmp_version; /* Local temporary version */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3727,7 +3727,7 @@ H5S__hyper_get_version_enc_size(const H5S_t *space, hsize_t block_count, uint32_ 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 */ @@ -3828,7 +3828,7 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, hsize_t *start, uint8_t enc_size, uint8_t **p) { H5S_hyper_span_t *curr; /* Pointer to current hyperslab span */ - uint8_t * pp = (*p); /* Local pointer for decoding */ + uint8_t *pp = (*p); /* Local pointer for decoding */ FUNC_ENTER_STATIC_NOERR @@ -3927,7 +3927,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. @@ -3942,15 +3942,15 @@ 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 */ hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ hsize_t start[H5S_MAX_RANK]; /* Location of start of hyperslab */ hsize_t end[H5S_MAX_RANK]; /* Location of end of hyperslab */ - uint8_t * pp; /* Local pointer for encoding */ - uint8_t * lenp = NULL; /* pointer to length location for later storage */ + uint8_t *pp; /* Local pointer for encoding */ + uint8_t *lenp = NULL; /* pointer to length location for later storage */ uint32_t len = 0; /* number of bytes used */ uint32_t version; /* Version number */ uint8_t flags = 0; /* Flags for message */ @@ -3971,7 +3971,7 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) pp = (*p); HDassert(pp); - /* Set some convienence values */ + /* Set some convenience values */ ndims = space->extent.rank; diminfo = space->select.sel_info.hslab->diminfo.opt; @@ -4074,7 +4074,7 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) else { HDassert(version == H5S_HYPER_VERSION_1); - /* Set some convienence values */ + /* Set some convenience values */ fast_dim = ndims - 1; /* Encode number of hyperslabs */ @@ -4220,21 +4220,21 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) +H5S__hyper_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, hbool_t skip) { - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, - either *space or a newly allocated one */ - hsize_t dims[H5S_MAX_RANK]; /* Dimenion sizes */ - hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */ - hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */ - uint32_t version; /* Version number */ - uint8_t flags = 0; /* Flags */ - uint8_t enc_size = 0; /* Encoded size of selection info */ - unsigned rank; /* rank of points */ - const uint8_t *pp; /* Local pointer for decoding */ - unsigned u; /* Local counting variable */ - herr_t ret_value = FAIL; /* return value */ - + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */ + hsize_t start[H5S_MAX_RANK]; /* hyperslab start information */ + hsize_t block[H5S_MAX_RANK]; /* hyperslab block information */ + uint32_t version; /* Version number */ + uint8_t flags = 0; /* Flags */ + uint8_t enc_size = 0; /* Encoded size of selection info */ + unsigned rank; /* rank of points */ + const uint8_t *pp; /* Local pointer for decoding */ + unsigned u; /* Local counting variable */ + herr_t ret_value = FAIL; /* return value */ + const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */ FUNC_ENTER_STATIC /* Check args */ @@ -4255,6 +4255,8 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) tmp_space = *space; /* Decode version */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection version") UINT32DECODE(pp, version); if (version < H5S_HYPER_VERSION_1 || version > H5S_HYPER_VERSION_LATEST) @@ -4262,13 +4264,22 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) if (version >= (uint32_t)H5S_HYPER_VERSION_2) { /* Decode flags */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 1, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection flags") flags = *(pp)++; - if (version >= (uint32_t)H5S_HYPER_VERSION_3) + if (version >= (uint32_t)H5S_HYPER_VERSION_3) { /* decode size of offset info */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 1, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding selection encoding size") enc_size = *(pp)++; + } else { /* Skip over the remainder of the header */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 4, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding selection header") pp += 4; enc_size = H5S_SELECT_INFO_ENC_SIZE_8; } /* end else */ @@ -4279,6 +4290,8 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) } else { /* Skip over the remainder of the header */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 8, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection header") pp += 8; enc_size = H5S_SELECT_INFO_ENC_SIZE_4; } /* end else */ @@ -4288,6 +4301,8 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection") /* Decode the rank of the point selection */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection rank") UINT32DECODE(pp, rank); if (!*space) { @@ -4299,8 +4314,8 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) else /* Verify the rank of the provided dataspace */ if (rank != tmp_space->extent.rank) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, - "rank of serialized selection does not match dataspace") + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "rank of serialized selection does not match dataspace") if (flags & H5S_HYPER_REGULAR) { hsize_t stride[H5S_MAX_RANK]; /* Hyperslab stride information */ @@ -4314,6 +4329,10 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: for (u = 0; u < tmp_space->extent.rank; u++) { + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 4 * sizeof(uint16_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding selection ranks") + UINT16DECODE(pp, start[u]); UINT16DECODE(pp, stride[u]); @@ -4329,6 +4348,10 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) case H5S_SELECT_INFO_ENC_SIZE_4: for (u = 0; u < tmp_space->extent.rank; u++) { + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 4 * sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding selection ranks") + UINT32DECODE(pp, start[u]); UINT32DECODE(pp, stride[u]); @@ -4344,6 +4367,10 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) case H5S_SELECT_INFO_ENC_SIZE_8: for (u = 0; u < tmp_space->extent.rank; u++) { + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 4 * sizeof(uint64_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding selection ranks") + UINT64DECODE(pp, start[u]); UINT64DECODE(pp, stride[u]); @@ -4370,23 +4397,32 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) const hsize_t *stride; /* Hyperslab stride information */ const hsize_t *count; /* Hyperslab count information */ hsize_t end[H5S_MAX_RANK]; /* Hyperslab end information */ - hsize_t * tstart; /* Temporary hyperslab pointers */ - hsize_t * tend; /* Temporary hyperslab pointers */ - hsize_t * tblock; /* Temporary hyperslab pointers */ + hsize_t *tstart; /* Temporary hyperslab pointers */ + hsize_t *tend; /* Temporary hyperslab pointers */ + hsize_t *tblock; /* Temporary hyperslab pointers */ size_t num_elem; /* Number of elements in selection */ unsigned v; /* Local counting variable */ /* Decode the number of blocks */ switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint16_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding number of selection blocks") UINT16DECODE(pp, num_elem); break; case H5S_SELECT_INFO_ENC_SIZE_4: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding number of selection blocks") UINT32DECODE(pp, num_elem); break; case H5S_SELECT_INFO_ENC_SIZE_8: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint64_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding number of selection blocks") UINT64DECODE(pp, num_elem); break; @@ -4403,6 +4439,10 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) /* Decode the starting and ending points */ switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, rank * 2 * sizeof(uint16_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding selection coordinates") + for (tstart = start, v = 0; v < rank; v++, tstart++) UINT16DECODE(pp, *tstart); for (tend = end, v = 0; v < rank; v++, tend++) @@ -4410,6 +4450,10 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) break; case H5S_SELECT_INFO_ENC_SIZE_4: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, rank * 2 * sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding selection coordinates") + for (tstart = start, v = 0; v < rank; v++, tstart++) UINT32DECODE(pp, *tstart); for (tend = end, v = 0; v < rank; v++, tend++) @@ -4417,6 +4461,10 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p) break; case H5S_SELECT_INFO_ENC_SIZE_8: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, rank * 2 * sizeof(uint64_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding selection coordinates") + for (tstart = start, v = 0; v < rank; v++, tstart++) UINT64DECODE(pp, *tstart); for (tend = end, v = 0; v < rank; v++, tend++) @@ -4617,7 +4665,7 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numblo hbool_t done; /* Whether we are done with the iteration */ unsigned u; /* Counter */ - /* Set some convienence values */ + /* Set some convenience values */ ndims = space->extent.rank; fast_dim = ndims - 1; @@ -4904,7 +4952,7 @@ static herr_t H5S__hyper_offset(const H5S_t *space, hsize_t *offset) { const hssize_t *sel_offset; /* Pointer to the selection's offset */ - const hsize_t * dim_size; /* Pointer to a dataspace's extent */ + const hsize_t *dim_size; /* Pointer to a dataspace's extent */ hsize_t accum; /* Accumulator for dimension sizes */ unsigned rank; /* Dataspace rank */ int i; /* index variable */ @@ -5111,7 +5159,7 @@ H5S__hyper_is_contiguous(const H5S_t *space) large_contiguous = TRUE; /* assume true and reset if the dimensions don't match */ small_contiguous = FALSE; /* assume false initially */ - /* Check for a "large contigous" block */ + /* Check for a "large contiguous" block */ for (u = 0; u < space->extent.rank; u++) { if (diminfo[u].count > 1) { large_contiguous = FALSE; @@ -5144,7 +5192,7 @@ H5S__hyper_is_contiguous(const H5S_t *space) } /* end if */ else { H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ - H5S_hyper_span_t * span; /* Hyperslab span node */ + H5S_hyper_span_t *span; /* Hyperslab span node */ /* * For a hyperslab to be contiguous, it must have only one block and @@ -5325,7 +5373,7 @@ H5S__hyper_is_single(const H5S_t *space) 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 @@ -5338,7 +5386,7 @@ H5S__hyper_is_single(const H5S_t *space) 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 */ @@ -5351,7 +5399,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) @@ -5575,8 +5623,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 @@ -5593,7 +5641,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 */ @@ -5616,9 +5664,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 && @@ -5663,11 +5711,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") @@ -5776,9 +5824,9 @@ H5S__hyper_release(H5S_t *space) static H5S_hyper_span_t * H5S__hyper_coord_to_span(unsigned rank, const hsize_t *coords) { - H5S_hyper_span_t * new_span; /* Pointer to new span tree for coordinate */ + H5S_hyper_span_t *new_span; /* Pointer to new span tree for coordinate */ H5S_hyper_span_info_t *down = NULL; /* Pointer to new span tree for next level down */ - H5S_hyper_span_t * ret_value = NULL; /* Return value */ + H5S_hyper_span_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -6254,7 +6302,7 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, unsigned rank, c 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 @@ -6269,7 +6317,7 @@ H5S__hyper_intersect_block_helper(H5S_hyper_span_info_t *spans, unsigned rank, c 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 */ @@ -6285,7 +6333,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) { @@ -6673,7 +6721,7 @@ H5S__hyper_project_simple_higher(const H5S_t *base_space, H5S_t *new_space) delta_rank = (new_space->extent.rank - base_space->extent.rank); while (curr_dim < delta_rank) { H5S_hyper_span_info_t *new_span_info; /* Pointer to list of spans */ - H5S_hyper_span_t * new_span; /* Temporary hyperslab span */ + H5S_hyper_span_t *new_span; /* Temporary hyperslab span */ /* Allocate a new span_info node */ if (NULL == (new_span_info = H5S__hyper_new_span_info(new_space->extent.rank))) { @@ -8010,7 +8058,7 @@ H5S__hyper_merge_spans_helper(H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf /* Work through the list of spans in the new list */ while (span_a != NULL && span_b != NULL) { H5S_hyper_span_info_t *tmp_spans; /* Pointer to temporary new span tree */ - H5S_hyper_span_t * tmp_span; /* Pointer to temporary new span */ + H5S_hyper_span_t *tmp_span; /* Pointer to temporary new span */ /* Check if the 'a' span is completely before 'b' span */ /* AAAAAAA */ @@ -8526,8 +8574,8 @@ H5S__hyper_make_spans(unsigned rank, const hsize_t *start, const hsize_t *stride const hsize_t *block) { H5S_hyper_span_info_t *down = NULL; /* Pointer to spans in next dimension down */ - H5S_hyper_span_t * last_span; /* Current position in hyperslab span list */ - H5S_hyper_span_t * head = NULL; /* Head of new hyperslab span list */ + H5S_hyper_span_t *last_span; /* Current position in hyperslab span list */ + H5S_hyper_span_t *head = NULL; /* Head of new hyperslab span list */ int i; /* Counters */ H5S_hyper_span_info_t *ret_value = NULL; /* Return value */ @@ -8790,14 +8838,14 @@ H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, const H5S_hyper_dim_t } /* end if */ else { /* Check if block values are the same */ - if (tmp_diminfo[curr_dim].block != new_hyper_diminfo[curr_dim].block) { + if (tmp_diminfo[curr_dim].block != high_block) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ /* Check phase of strides */ if ((tmp_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride) != - (new_hyper_diminfo[curr_dim].start % tmp_diminfo[curr_dim].stride)) { + (high_start % tmp_diminfo[curr_dim].stride)) { space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; break; } /* end if */ @@ -8815,9 +8863,9 @@ H5S__hyper_update_diminfo(H5S_t *space, H5S_seloper_t op, const H5S_hyper_dim_t /* XOR: Make sure the slabs border */ if (high_start != (tmp_diminfo[curr_dim].start + (tmp_diminfo[curr_dim].count * tmp_diminfo[curr_dim].stride))) { - space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; - break; - } /* end if */ + space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO; + break; + } /* end if */ /* Set count for combined selection */ tmp_diminfo[curr_dim].count = @@ -9719,7 +9767,7 @@ H5S__hyper_regular_and_single_block(H5S_t *space, const hsize_t start[], const h else /* Selection & block don't overlap, set to "none" selection */ if (H5S_select_none(space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't convert selection") } /* end if */ else { hsize_t new_start[H5S_MAX_RANK]; /* New start for hyperslab selection */ @@ -10783,7 +10831,7 @@ H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2) else /* Combine spans from space1 & spans from space2, with the result in space1 */ if (H5S__fill_in_select(space1, op, space2, &space1) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't perform operation on two selections") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't perform operation on two selections") done: FUNC_LEAVE_NOAPI(ret_value) @@ -11330,9 +11378,8 @@ sis_span_info unsigned depth; IN: Depth of iteration (in terms of rank) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, - const H5S_hyper_span_info_t *sis_span_info, hsize_t count, unsigned depth, - H5S_hyper_project_intersect_ud_t *udata) +H5S__hyper_proj_int_iterate(H5S_hyper_span_info_t *ss_span_info, const H5S_hyper_span_info_t *sis_span_info, + hsize_t count, unsigned depth, H5S_hyper_project_intersect_ud_t *udata) { const H5S_hyper_span_t *ss_span; /* Current span in source space */ const H5S_hyper_span_t *sis_span; /* Current span in source intersect space */ @@ -11515,7 +11562,7 @@ H5S__hyper_proj_int_iterate(const H5S_hyper_span_info_t *ss_span_info, udata->skip += (count - 1) * (udata->skip - old_skip); } /* end if */ else { - /* Third case: agorithm added skip and nelem (in that + /* Third case: algorithm added skip and nelem (in that * order). Add the same skip and nelem once for each item * remaining in count. */ hsize_t skip_add; @@ -11591,14 +11638,14 @@ 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; - const H5S_hyper_span_info_t * ds_span_info; - H5S_hyper_span_info_t * ss_span_info_buf = NULL; - H5S_hyper_span_info_t * ds_span_info_buf = NULL; + H5S_hyper_span_info_t *ss_span_info; + const H5S_hyper_span_info_t *ds_span_info; + H5S_hyper_span_info_t *ss_span_info_buf = NULL; + H5S_hyper_span_info_t *ds_span_info_buf = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -11621,7 +11668,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") @@ -11643,7 +11690,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") @@ -11663,7 +11710,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") @@ -11714,7 +11761,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, else /* If we did not add anything to proj_space, select none instead */ if (H5S_select_none(proj_space) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection") done: /* Free ss_span_info_buf */ @@ -12169,13 +12216,13 @@ H5S_t * H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) { H5S_hyper_sel_t *hslab; /* Convenience pointer to hyperslab info */ - H5S_t * space_out = NULL; /* Dataspace to return */ + H5S_t *space_out = NULL; /* Dataspace to return */ hsize_t start[H5S_MAX_RANK]; /* Hyperslab selection info for unlim. selection */ hsize_t stride[H5S_MAX_RANK]; hsize_t count[H5S_MAX_RANK]; hsize_t block[H5S_MAX_RANK]; unsigned u; /* Local index variable */ - H5S_t * ret_value = NULL; /* Return value */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -12359,7 +12406,7 @@ H5Sis_regular_hyperslab(hid_t spaceid) herr_t H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[], hsize_t count[], hsize_t block[]) { - H5S_t * space; /* Dataspace to query */ + H5S_t *space; /* Dataspace to query */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Smodule.h b/src/H5Smodule.h index bb33eb855a7..9c6682e9a44 100644 --- a/src/H5Smodule.h +++ b/src/H5Smodule.h @@ -29,31 +29,1526 @@ #define H5_MY_PKG_ERR H5E_DATASPACE #define H5_MY_PKG_INIT YES -/**\defgroup H5S H5S - * \brief Dataspace Interface +/** \page H5S_UG Dataspaces and Partial I/O * - * \details The Dataspace Interface provides functions for creating and - * working with dataspaces. * - * A dataspace has two roles: + * \section sec_dataspace HDF5 Dataspaces and Partial I/O * - * \li It contains the spatial information (logical layout) of a - * dataset stored in a file. - * \li It describes an application’s data buffers and data elements - * participating in I/O. In other words, it can be used to - * select a portion or subset of a dataset. + * HDF5 dataspaces describe the \Emph{shape} of datasets in memory or in HDF5 + * files. Dataspaces can be empty (#H5S_NULL), a singleton (#H5S_SCALAR), or + * a multi-dimensional, regular grid (#H5S_SIMPLE). Dataspaces can be re-shaped. * - * The spatial information of a dataset in a file includes the - * rank and dimensions of the dataset, which are a permanent part - * of the dataset definition. It can have dimensions that are fixed - * (unchanging) or unlimited, which means they can grow in size - * (or are extendible). + * Subsets of dataspaces can be "book-marked" or used to restrict I/O operations + * using \Emph{selections}. Furthermore, certain set operations are supported + * for selections. * - * A dataspace can consist of: - * \li no elements (NULL) - * \li a single element (scalar), or - * \li a simple array. + * \subsection subsec_dataspace_intro Introduction * + * The HDF5 \Emph{dataspace} is a required component of an HDF5 dataset or attribute definition. The dataspace + * defines the size and shape of the dataset or attribute raw data. In other words, a dataspace defines the + * number of dimensions and the size of each dimension of the multidimensional array in which the raw data + * is represented. The dataspace must be defined when the dataset or attribute is created. + * + * The \Emph{dataspace} is also used during dataset I/O operations, defining the elements of the dataset that + * participate in the I/O operation. + * + * This chapter explains the \Emph{dataspace} object and its use in dataset and attribute creation and data + * transfer. It also describes selection operations on a dataspace used to implement subâ€setting, + * subâ€sampling, and scatterâ€gather access to datasets. + * + * \subsection subsec_dataspace_function Dataspace Function Summaries + * @see H5S reference manual provides a reference list of dataspace functions, the H5S APIs. + * + * \subsection subsec_dataspace_program Definition of Dataspace Objects and the Dataspace Programming Model + * + * This section introduces the notion of the HDF5 dataspace object and a programming model for creating + * and working with dataspaces. + * + * \subsubsection subsubsec_dataspace_program_object Dataspace Objects + * + * An HDF5 dataspace is a required component of an HDF5 dataset or attribute. A dataspace defines the size + * and the shape of a dataset’s or an attribute’s raw data. Currently, HDF5 supports the following types of + * the dataspaces: + * \li Scalar dataspaces + * \li Simple dataspaces + * \li Null dataspaces + * + * A scalar dataspace, #H5S_SCALAR, represents just one element, a scalar. Note that the datatype of this one + * element may be very complex; example would be a compound structure with members being of any + * allowed HDF5 datatype, including multidimensional arrays, strings, and nested compound structures. By + * convention, the rank of a scalar dataspace is always 0 (zero); think of it geometrically as a single, + * dimensionless point, though that point may be complex. + * + * A simple dataspace, #H5S_SIMPLE , is a multidimensional array of elements. The dimensionality of the + * dataspace (or the rank of the array) is fixed and is defined at creation time. The size of each dimension + * can grow during the life time of the dataspace from the current size up to the maximum size. Both the + * current size and the maximum size are specified at creation time. The sizes of dimensions at any particular + * time in the life of a dataspace are called the current dimensions, or the dataspace extent. They can be + * queried along with the maximum sizes. + * + * A null dataspace, #H5S_NULL, contains no data elements. Note that no selections can be applied to a null + * dataset as there is nothing to select. + * + * As shown in the UML diagram in the figure below, an HDF5 simple dataspace object has three attributes: + * the rank or number of dimensions; the current sizes, expressed as an array of length rank with each element + * of the array denoting the current size of the corresponding dimension; and the maximum sizes, + * expressed as an array of length rank with each element of the array denoting the maximum size of the + * corresponding dimension. + * + * + * + * + * + *
    + * \image html Dspace_simple.gif "A simple dataspace" + *
    + * + * \em Note: A simple dataspace is defined by its rank, the current size of each dimension, and the maximum + * size of each dimension. + * + * The size of a current dimension cannot be greater than the maximum size, which can be unlimited, specified + * as #H5S_UNLIMITED. Note that while the HDF5 file format and library impose no maximum size on an + * unlimited dimension, practically speaking its size will always be limited to the biggest integer available + * on the particular system being used. + * + * Dataspace rank is restricted to 32, the standard limit in C on the rank of an array, in the current + * implementation of the HDF5 Library. The HDF5 file format, on the other hand, allows any rank up to the + * maximum integer value on the system, so the library restriction can be raised in the future if higher + * dimensionality is required. + * + * Note that most of the time Fortran applications calling HDF5 will work with dataspaces of rank less than + * or equal to seven, since seven is the maximum number of dimensions in a Fortran array. But dataspace rank + * is not limited to seven for Fortran applications. + * + * The current dimensions of a dataspace, also referred to as the dataspace extent, define the bounding box + * for dataset elements that can participate in I/O operations. + * + * \subsubsection subsubsec_dataspace_program_model Dataspace Programming Model + * + * The programming model for creating and working with HDF5 dataspaces can be summarized as follows: + * \li 1. Create a dataspace + * \li 2. Use the dataspace to create a dataset in the file or to describe a data array in memory + * \li 3. Modify the dataspace to define dataset elements that will participate in I/O operations + * \li 4. Use the modified dataspace while reading/writing dataset raw data or to create a region reference + * \li 5. Close the dataspace when no longer needed + * + * The rest of this section will address steps 1, 2, and 5 of the programming model; steps 3 and 4 will be + * discussed in later sections of this chapter. + * + *

    Creating a Dataspace

    + * + * A dataspace can be created by calling the \ref H5Screate function. Since the + * definition of a simple dataspace requires the specification of dimensionality (or rank) and initial and + * maximum dimension sizes, the HDF5 Library provides a convenience API, \ref H5Screate_simple to create a + * simple dataspace in one step. + * + * The following examples illustrate the usage of these APIs. + * + *

    Creating a Scalar Dataspace

    + * + * Creating a Scalar Dataspace + * \code + * hid_t space_id; + * . . . + * space_id = H5Screate(H5S_SCALAR); + * \endcode + * As mentioned above, the dataspace will contain only one element. Scalar dataspaces are used more often + * for describing attributes that have just one value. For example, the attribute temperature with the value + * Celsius is used to indicate that the dataset with this attribute stores temperature values using the + * Celsius scale. + * + *

    Creating a Null Dataspace

    + * + * A null dataspace is created with the \ref H5Screate function. + * \code + * hid_t space_id; + * . . . + * space_id = H5Screate(H5S_NULL); + * \endcode + * As mentioned above, the dataspace will contain no elements. + * + *

    Creating a Simple Dataspace

    + * + * Let’s assume that an application wants to store a twoâ€dimensional array of data, A(20,100). During the + * life of the application, the first dimension of the array can grow up to 30; there is no restriction on + * the size of the second dimension. The following steps are used to declare a dataspace for the dataset + * in which the array data will be stored. + * \code + * hid_t space_id; + * int rank = 2; + * hsize_t current_dims[2] = {20, 100}; + * hsize_t max_dims[2] = {30, H5S_UNLIMITED}; + * . . . + * space_id = H5Screate(H5S_NULL); + * H5Sset_extent_simple(space_id, rank, current_dims, max_dims); + * \endcode + * + * Alternatively, the convenience APIs H5Screate_simple/h5screate_simple_f can replace the + * H5Screate/h5screate_f and H5Sset_extent_simple/h5sset_extent_simple_f calls. + * \code + * space_id = H5Screate_simple(rank, current_dims, max_dims); + * \endcode + * + * In this example, a dataspace with current dimensions of 20 by 100 is created. The first dimension can be + * extended only up to 30. The second dimension, however, is declared unlimited; it can be extended up to + * the largest available integer value on the system. + * + * Note that when there is a difference between the current dimensions and the maximum dimensions of an + * array, then chunking storage must be used. In other words, if the number of dimensions may change over + * the life of the dataset, then chunking must be used. If the array dimensions are fixed (if the number of + * current dimensions is equal to the maximum number of dimensions when the dataset is created), then + * contiguous storage can be used. For more information, see "Data Transfer". + * + * Maximum dimensions can be the same as current dimensions. In such a case, the sizes of dimensions + * cannot be changed during the life of the dataspace object. In C, \c NULL can be used to indicate to the + * \ref H5Screate_simple and \ref H5Sset_extent_simple functions that the maximum sizes of all dimensions + * are the same as the current sizes. + * \code + * space_id = H5Screate_simple(rank, current_dims, NULL); + * \endcode + * The created dataspace will have current and maximum dimensions of 20 and 100 correspondingly, and the + * sizes of those dimensions cannot be changed. + * + *

    C versus Fortran Dataspaces

    + * + * Dataspace dimensions are numbered from 1 to rank. HDF5 uses C storage conventions, assuming that the + * last listed dimension is the fastestâ€changing dimension and the firstâ€listed dimension is the slowest + * changing. The HDF5 file format storage layout specification adheres to the C convention and the HDF5 + * Library adheres to the same convention when storing dataspace dimensions in the file. This affects how + * C programs and tools interpret data written from Fortran programs and vice versa. The example below + * illustrates the issue. + * + * When a Fortran application describes a dataspace to store an array as A(20,100), it specifies the value of + * the first dimension to be 20 and the second to be 100. Since Fortran stores data by columns, the + * firstâ€listed dimension with the value 20 is the fastestâ€changing dimension and the lastâ€listed dimension + * with the value 100 is the slowestâ€changing. In order to adhere to the HDF5 storage convention, the HDF5 + * Fortran wrapper transposes dimensions, so the first dimension becomes the last. The dataspace dimensions + * stored in the file will be 100,20 instead of 20,100 in order to correctly describe the Fortran data that + * is stored in 100 columns, each containing 20 elements. + * + * When a Fortran application reads the data back, the HDF5 Fortran wrapper transposes the dimensions + * once more, returning the first dimension to be 20 and the second to be 100, describing correctly the sizes + * of the array that should be used to read data in the Fortran array A(20,100). + * + * When a C application reads data back, the dimensions will come out as 100 and 20, correctly describing + * the size of the array to read data into, since the data was written as 100 records of 20 elements each. + * Therefore C tools such as h5dump and h5ls always display transposed dimensions and values for the data + * written by a Fortran application. + * + * Consider the following simple example of equivalent C 3 x 5 and Fortran 5 x 3 arrays. As illustrated in + * the figure below, a C application will store a 3 x 5 2â€dimensional array as three 5â€element rows. In order + * to store the same data in the same order, a Fortran application must view the array as a 5 x 3 array with + * three 5â€element columns. The dataspace of this dataset, as written from Fortran, will therefore be + * described as 5 x 3 in the application but stored and described in the file according to the C convention + * as a 3 x 5 array. This ensures that C and Fortran applications will always read the data in the order in + * which it was written. The HDF5 Fortran interface handles this transposition automatically. + * \code + * // C + * \#define NX 3 // dataset dimensions + * \#define NY 5 + * . . . + * int data[NX][NY]; // data to write + * . . . + * // Data and output buffer initialization. + * for (j = 0; j < NX; j++) + * for (i = 0; i < NY; i++) + * data[j][i] = i + j; + * // + * // 1 2 3 4 5 + * // 6 7 8 9 10 + * // 11 12 13 14 15 + * // + * . . . + * dims[0] = NX; + * dims[1] = NY; + * dataspace = H5Screate_simple(RANK, dims, NULL); + * \endcode + * + * \code + * ! Fortran + * INTEGER, PARAMETER :: NX = 3 + * INTEGER, PARAMETER :: NX = 5 + * . . . + * INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/NY, NX/) ! Dataset dimensions + * . . . + * ! + * ! Initialize data + * ! + * do i = 1, NY + * do j = 1, NX + * data(i,j) = i + (j-1)*NY + * enddo + * enddo + * ! + * ! Data + * ! + * ! 1 6 11 + * ! 2 7 12 + * ! 3 8 13 + * ! 4 9 14 + * ! 5 10 15 + * . . . + * CALL h5screate_simple_f(rank, dims, dspace_id, error) + * \endcode + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Comparing C and Fortran dataspaces
    + * A dataset stored by a C program in a 3 x 5 array: + *
    + * \image html Dspace_CvsF1.gif + *
    + * The same dataset stored by a Fortran program in a 5 x 3 array: + *
    + * \image html Dspace_CvsF2.gif + *
    + * The first dataset above as written to an HDF5 file from C or the second dataset above as written + * from Fortran: + *
    + * \image html Dspace_CvsF3.gif + *
    + * The first dataset above as written to an HDF5 file from Fortran: + *
    + * \image html Dspace_CvsF4.gif + *
    + * + * Note: The HDF5 Library stores arrays along the fastestâ€changing dimension. This approach is often + * referred to as being “in C order.†C, C++, and Java work with arrays in rowâ€major order. In other words, + * the row, or the last dimension, is the fastestâ€changing dimension. Fortran, on the other hand, handles + * arrays in columnâ€major order making the column, or the first dimension, the fastestâ€changing dimension. + * Therefore, the C and Fortran arrays illustrated in the top portion of this figure are stored identically + * in an HDF5 file. This ensures that data written by any language can be meaningfully read, interpreted, + * and manipulated by any other. + * + *

    Finding Dataspace Characteristics

    + * + * The HDF5 Library provides several APIs designed to query the characteristics of a dataspace. + * + * The function \ref H5Sis_simple returns information about the type of a dataspace. + * This function is rarely used and currently supports only simple and scalar dataspaces. + * + * To find out the dimensionality, or rank, of a dataspace, use \ref H5Sget_simple_extent_ndims. + * \ref H5Sget_simple_extent_dims can also be used to find out the rank. See + * the example below. If both functions return 0 for the value of rank, then the dataspace is scalar. + * + * To query the sizes of the current and maximum dimensions, use \ref H5Sget_simple_extent_dims. + * + * The following example illustrates querying the rank and dimensions of a dataspace using these functions. + * \code + * hid_t space_id; + * int rank; + * hsize_t *current_dims; + * hsize_t *max_dims; + * . . . + * rank = H5Sget_simple_extent_ndims(space_id); + * // (or rank = H5Sget_simple_extent_dims(space_id, NULL, NULL);) + * current_dims = (hsize_t)malloc(rank * sizeof(hsize_t)); + * max_dims = (hsize_t)malloc(rank * sizeof(hsize_t)); + * H5Sget_simple_extent_dims(space_id, current_dims, max_dims); + * // Print values here + * \endcode + * + * \subsection subsec_dataspace_transfer Dataspaces and Data Transfer + * + * Read and write operations transfer data between an HDF5 file on disk and in memory. The shape that the + * array data takes in the file and in memory may be the same, but HDF5 also allows users the ability to + * represent data in memory in a different shape than in the file. If the shape of an array in the file and + * in memory will be the same, then the same dataspace definition can be used for both. If the shape of an + * array in memory needs to be different than the shape in the file, then the dataspace definition for the + * shape of the array in memory can be changed. During a read operation, the array will be read into the + * different shape in memory, and during a write operation, the array will be written to the file in the + * shape specified by the dataspace in the file. The only qualification is that the number of elements read + * or written must be the same in both the source and the destination dataspaces. + * + * Item a in the figure below shows a simple example of a read operation in which the data is stored as a 3 + * by 4 array in the file (item b) on disk, but the program wants it to be a 4 by 3 array in memory. This is + * accomplished by setting the memory dataspace to describe the desired memory layout, as in item c. The read + * operation reads the data in the file array into the memory array. + * + * + * + * + * + *
    + * \image html Dspace_read.gif "Data layout before and after a read operation" + *
    + * + * + * + * + * + *
    + * \image html Dspace_move.gif "Moving data from disk to memory" + *
    + + * Both the source and destination are stored as contiguous blocks of storage with the elements in the order + * specified by the dataspace. The figure above shows one way the elements might be organized. In item a, + * the elements are stored as 3 blocks of 4 elements. The destination is an array of 12 elements in memory + * (see item c). As the figure suggests, the transfer reads the disk blocks into a memory buffer (see item b), + * and then writes the elements to the correct locations in memory. A similar process occurs in reverse when + * data is written to disk. + * + * \subsubsection subsubsec_dataspace_transfer_select Data Selection + * + * In addition to rearranging data, the transfer may select the data elements from the source and destination. + * + * Data selection is implemented by creating a dataspace object that describes the selected elements (within + * the hyper rectangle) rather than the whole array. Two dataspace objects with selections can be used in + * data transfers to read selected elements from the source and write selected elements to the destination. + * When data is transferred using the dataspace object, only the selected elements will be transferred. + * + * This can be used to implement partial I/O, including: + * \li Subâ€setting †reading part of a large dataset + * \li Sampling †reading selected elements (for example, every second element) of a dataset + * \li Scatterâ€gather †read nonâ€contiguous elements into contiguous locations (gather) or read contiguous + * elements into nonâ€contiguous locations (scatter) or both + * + * To use selections, the following steps are followed: + * \li 1. Get or define the dataspace for the source and destination + * \li 2. Specify one or more selections for source and destination dataspaces + * \li 3. Transfer data using the dataspaces with selections + * + * A selection is created by applying one or more selections to a dataspace. A selection may override any + * other selections (#H5S_SELECT_SET) or may be “Ored†with previous selections on the same dataspace + * (#H5S_SELECT_OR). In the latter case, the resulting selection is the union of the selection and all + * previously selected selections. Arbitrary sets of points from a dataspace can be selected by specifying + * an appropriate set of selections. + * + * Two selections are used in data transfer, so the source and destination must be compatible, as described + * below. + * + * There are two forms of selection, hyperslab and point. A selection must be either a point selection or a + * set of hyperslab selections. Selections cannot be mixed. + * + * The definition of a selection within a dataspace, not the data in the selection, cannot be saved to the + * file unless the selection definition is saved as a region reference. For more information, + * see \ref subsec_dataspace_refer. + * + *

    Hyperslab Selection

    + * + * A hyperslab is a selection of elements from a hyper rectangle. An HDF5 hyperslab is a rectangular pattern + * defined by four arrays. The four arrays are summarized in the table below. + * + * The offset defines the origin of the hyperslab in the original dataspace. + * + * The stride is the number of elements to increment between selected elements. A stride of ‘1’ is every + * element, a stride of ‘2’ is every second element, etc. Note that there may be a different stride for + * each dimenâ€sion of the dataspace. The default stride is 1. + * + * The count is the number of elements in the hyperslab selection. When the stride is 1, the selection is a + * hyper rectangle with a corner at the offset and size count[0] by count[1] by.... When stride is greater + * than one, the hyperslab bounded by the offset and the corners defined by stride[n] * count[n]. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Hyperslab elements
    + * Parameter + * + * Description + *
    + * Offset + * + * The starting location for the hyperslab. + *
    + * Stride + * + * The number of elements to separate each element or block to be selected. + *
    + * Count + * + * The number of elements or blocks to select along each dimension. + *
    + * Block + * + * The size of the block selected from the dataspace. + *
    + * + * The block is a count on the number of repetitions of the hyperslab. The default block size is '1', which is + * one hyperslab. A block of 2 would be two hyperslabs in that dimension, with the second starting at + * offset[n] + (count[n] * stride[n]) + 1. + * + * A hyperslab can be used to access a subâ€set of a large dataset. The figure below shows an example of a + * hyperslab that reads a rectangle from the middle of a larger two dimensional array. The destination is the + * same shape as the source. + * + * + * + * + * + *
    + * \image html Dspace_subset.gif "Access a subâ€set of data with a hyperslab" + *
    + * + * Hyperslabs can be combined to select complex regions of the source and destination. The figure below + * shows an example of a transfer from one nonâ€rectangular region into another nonâ€rectangular region. The + * source is defined as the union of two hyperslabs, and the destination is the union of three hyperslabs. + * + * + * + * + * + *
    + * \image html Dspace_complex.gif "Build complex regions with hyperslab unions" + *
    + * + * Hyperslabs may also be used to collect or scatter data from regular patterns. The figure below shows an + * example where the source is a repeating pattern of blocks, and the destination is a single, one dimensional + * array. + * + * + * + * + * + *
    + * \image html Dspace_combine.gif "Use hyperslabs to combine or disperse data" + *
    + * + *

    Select Points

    + * + * The second type of selection is an array of points such as coordinates. Essentially, this selection is a + * list of all the points to include. The figure below shows an example of a transfer of seven elements from + * a two dimensional dataspace to a three dimensional dataspace using a point selection to specify the points. + * + * + * + * + * + *
    + * \image html Dspace_point.gif "Point selection" + *
    + * + *

    Rules for Defining Selections

    + * + * A selection must have the same number of dimensions (rank) as the dataspace it is applied to, although it + * may select from only a small region such as a plane from a 3D dataspace. Selections do not affect the + * extent of the dataspace, the selection may be larger than the dataspace. The boundaries of selections are + * reconciled with the extent at the time of the data transfer. + * + *

    Data Transfer with Selections

    + * + * A data transfer (read or write) with selections is the same as any read or write, except the source + * and destination dataspace have compatible selections. + * + * During the data transfer, the following steps are executed by the library: + * \li The source and destination dataspaces are checked to assure that the selections are compatible. + *
    • Each selection must be within the current extent of the dataspace. A selection may be + * defined to extend outside the current extent of the dataspace, but the dataspace cannot be + * accessed if the selection is not valid at the time of the access.
    • + *
    • The total number of points selected in the source and destination must be the same. Note + * that the dimensionality of the source and destination can be different (for example, the + * source could be 2D, the destination 1D or 3D), and the shape can be different, but the number of + * elements selected must be the same.
    + * \li The data is transferred, element by element. + * + * Selections have an iteration order for the points selected, which can be any permutation of the dimensions + * involved (defaulting to 'C' array order) or a specific order for the selected points, for selections + * composed of single array elements with \ref H5Sselect_elements. + * + * The elements of the selections are transferred in rowâ€major, or C order. That is, it is assumed that the + * first dimension varies slowest, the second next slowest, and so forth. For hyperslab selections, the order + * can be any permutation of the dimensions involved (defaulting to ‘C’ array order). When multiple hyperslabs + * are combined, the hyperslabs are coalesced into contiguous reads and writes. + * + * In the case of point selections, the points are read and written in the order specified. + * + * \subsubsection subsubsec_dataspace_transfer_model Programming Model + * + *

    Selecting Hyperslabs

    + * + * Suppose we want to read a 3x4 hyperslab from a dataset in a file beginning at the element <1,2> in the + * dataset, and read it into a 7 x 7 x 3 array in memory. See the figure below. In order to do this, we must + * create a dataspace that describes the overall rank and dimensions of the dataset in the file as well as + * the position and size of the hyperslab that we are extracting from that dataset. + * + * + * + * + * + *
    + * \image html Dspace_select.gif "Selecting a hyperslab" + *
    + * + * The code in the first example below illustrates the selection of the hyperslab in the file dataspace. + * The second example below shows the definition of the destination dataspace in memory. Since the inâ€memory + * dataspace has three dimensions, the hyperslab is an array with three dimensions with the last dimension + * being 1: <3,4,1>. The third example below shows the read using the source and destination dataspaces + * with selections. + * + * Selecting a hyperslab + * \code + * //get the file dataspace. + * dataspace = H5Dget_space(dataset); // dataspace identifier + * + * // Define hyperslab in the dataset. + * offset[0] = 1; + * offset[1] = 2; + * count[0] = 3; + * count[1] = 4; + * status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, NULL, count, NULL); + * \endcode + * + * Defining the destination memory + * \code + * // Define memory dataspace. + * dimsm[0] = 7; + * dimsm[1] = 7; + * dimsm[2] = 3; + * memspace = H5Screate_simple(3,dimsm,NULL); + * + * // Define memory hyperslab. + * offset_out[0] = 3; + * offset_out[1] = 0; + * offset_out[2] = 0; + * count_out[0] = 3; + * count_out[1] = 4; + * count_out[2] = 1; + * status = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL, count_out, NULL); + * \endcode + * + * A sample read specifying source and destination dataspaces + * \code + * ret = H5Dread(dataset, H5T_NATIVE_INT, memspace,dataspace, H5P_DEFAULT, data); + * \endcode + * + *

    Example with Strides and Blocks

    + * + * Consider an 8 x 12 dataspace into which we want to write eight 3 x 2 blocks in a two dimensional array + * from a source dataspace in memory that is a 50â€element one dimensional array. See the figure below. + * + * + * + * + * + *
    + * \image html Dspace_write1to2.gif "Write from a one dimensional array to a two dimensional array" + *
    + * + * The example below shows code to write 48 elements from the one dimensional array to the file dataset + * starting with the second element in vector. The destination hyperslab has the following parameters: + * offset=(0,1), stride=(4,3), count=(2,4), block=(3,2). The source has the parameters: offset=(1), + * stride=(1), count=(48), block=(1). After these operations, the file dataspace will have the values + * shown in item b in the figure above. Notice that the values are inserted in the file dataset in + * rowâ€major order. + * + * Write from a one dimensional array to a two dimensional array + * \code + * // Select hyperslab for the dataset in the file, using 3 x 2 blocks, (4,3) stride (2,4) + * // count starting at the position (0,1). + * offset[0] = 0; offset[1] = 1; + * stride[0] = 4; stride[1] = 3; + * count[0] = 2; count[1] = 4; + * block[0] = 3; block[1] = 2; + * ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, offset, stride, count, block); + * + * // Create dataspace for the first dataset. + * mid1 = H5Screate_simple(MSPACE1_RANK, dim1, NULL); + * + * // Select hyperslab. + * // We will use 48 elements of the vector buffer starting + * // at the second element. Selected elements are + * // 1 2 3 . . . 48 + * offset[0] = 1; + * stride[0] = 1; + * count[0] = 48; + * block[0] = 1; + * ret = H5Sselect_hyperslab(mid1, H5S_SELECT_SET, offset, stride, count, block); + * + * // Write selection from the vector buffer to the dataset in the file. + * ret = H5Dwrite(dataset, H5T_NATIVE_INT, midd1, fid, H5P_DEFAULT, vector) + * \endcode + * + *

    Selecting a Union of Hyperslabs

    + * + * The HDF5 Library allows the user to select a union of hyperslabs and write or read the selection into + * another selection. The shapes of the two selections may differ, but the number of elements must be + * equal. + * + * + * + * + * + *
    + * \image html Dspace_transfer.gif "Transferring hyperslab unions" + *
    + * + * The figure above shows the transfer of a selection that is two overlapping hyperslabs from the dataset + * into a union of hyperslabs in the memory dataset. Note that the destination dataset has a different shape + * from the source dataset. Similarly, the selection in the memory dataset could have a different shape than + * the selected union of hyperslabs in the original file. For simplicity, the selection is that same shape + * at the destination. + * + * To implement this transfer, it is necessary to: + * \li 1. Get the source dataspace + * \li 2. Define one hyperslab selection for the source + * \li 3. Define a second hyperslab selection, unioned with the first + * \li 4. Get the destination dataspace + * \li 5. Define one hyperslab selection for the destination + * \li 6. Define a second hyperslab selection, unioned with the first + * \li 7. Execute the data transfer (H5Dread or H5Dwrite) using the source and destination dataspaces + * + * The example below shows example code to create the selections for the source dataspace (the file). The + * first hyperslab is size 3 x 4 and the left upper corner at the position (1,2). The hyperslab is a simple + * rectangle, so the stride and block are 1. The second hyperslab is 6 x 5 at the position (2,4). The second + * selection is a union with the first hyperslab (#H5S_SELECT_OR). + * + * Select source hyperslabs + * \code + * fid = H5Dget_space(dataset); + * + * // Select first hyperslab for the dataset in the file. + * offset[0] = 1; offset[1] = 2; + * block[0] = 1; block[1] = 1; + * stride[0] = 1; stride[1] = 1; + * count[0] = 3; count[1] = 4; + * ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, offset, stride, count, block); + * + * // Add second selected hyperslab to the selection. + * offset[0] = 2; offset[1] = 4; + * block[0] = 1; block[1] = 1; + * stride[0] = 1; stride[1] = 1; + * count[0] = 6; count[1] = 5; + * ret = H5Sselect_hyperslab(fid, H5S_SELECT_OR, offset, stride, count, block); + * \endcode + * + * The example below shows example code to create the selection for the destination in memory. The steps + * are similar. In this example, the hyperslabs are the same shape, but located in different positions in the + * dataspace. The first hyperslab is 3 x 4 and starts at (0,0), and the second is 6 x 5 and starts at (1,2). + * Finally, the H5Dread call transfers the selected data from the file dataspace to the selection in memory. + * In this example, the source and destination selections are two overlapping rectangles. In general, any + * number of rectangles can be OR’ed, and they do not have to be contiguous. The order of the selections + * does not matter, but the first should use #H5S_SELECT_SET ; subsequent selections are unioned using + * #H5S_SELECT_OR. + * + * It is important to emphasize that the source and destination do not have to be the same shape (or number + * of rectangles). As long as the two selections have the same number of elements, the data can be + * transferred. + * + * Select destination hyperslabs + * \code + * // Create memory dataspace. + * mid = H5Screate_simple(MSPACE_RANK, mdim, NULL); + * + * // Select two hyperslabs in memory. Hyperslabs has the + * // same size and shape as the selected hyperslabs for + * // the file dataspace. + * offset[0] = 0; offset[1] = 0; + * block[0] = 1; block[1] = 1; + * stride[0] = 1; stride[1] = 1; + * count[0] = 3; count[1] = 4; + * ret = H5Sselect_hyperslab(mid, H5S_SELECT_SET, offset, stride, count, block); + * + * offset[0] = 1; offset[1] = 2; + * block[0] = 1; block[1] = 1; + * stride[0] = 1; stride[1] = 1; + * count[0] = 6; count[1] = 5; + * ret = H5Sselect_hyperslab(mid, H5S_SELECT_OR, offset, stride, count, block); + * + * ret = H5Dread(dataset, H5T_NATIVE_INT, mid, fid, H5P_DEFAULT, matrix_out); + * \endcode + * + *

    Selecting a List of Independent Points

    + * + * It is also possible to specify a list of elements to read or write using the function H5Sselect_elements. + * + * The procedure is similar to hyperslab selections. + * \li 1. Get the source dataspace + * \li 2. Set the selected points + * \li 3. Get the destination dataspace + * \li 4. Set the selected points + * \li 5. Transfer the data using the source and destination dataspaces + * + * The figure below shows an example where four values are to be written to four separate points in a two + * dimensional dataspace. The source dataspace is a one dimensional array with the values 53, 59, 61, 67. + * The destination dataspace is an 8 x 12 array. The elements are to be written to the points + * (0,0), (3,3), (3,5), and (5,6). In this example, the source does not require a selection. The example + * below the figure shows example code to implement this transfer. + * + * A point selection lists the exact points to be transferred and the order they will be transferred. The + * source and destination are required to have the same number of elements. A point selection can be used + * with a hyperslab (for example, the source could be a point selection and the destination a hyperslab, + * or vice versa), so long as the number of elements selected are the same. + * + * + * + * + * + *
    + * \image html Dspace_separate.gif "Write data to separate points" + *
    + * + * Write data to separate points + * \code + * hsize_t dim2[] = {4}; + * int values[] = {53, 59, 61, 67}; + * + * // file dataspace + * hssize_t coord[4][2]; + * + * // Create dataspace for the second dataset. + * mid2 = H5Screate_simple(1, dim2, NULL); + * + * // Select sequence of NPOINTS points in the file dataspace. + * coord[0][0] = 0; coord[0][1] = 0; + * coord[1][0] = 3; coord[1][1] = 3; + * coord[2][0] = 3; coord[2][1] = 5; + * coord[3][0] = 5; coord[3][1] = 6; + * + * ret = H5Sselect_elements(fid, H5S_SELECT_SET, NPOINTS, (const hssize_t **)coord); + * + * ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid2, fid, H5P_DEFAULT, values); + * \endcode + * + *

    Combinations of Selections

    + * + * Selections are a very flexible mechanism for reorganizing data during a data transfer. With different + * combinations of dataspaces and selections, it is possible to implement many kinds of data transfers + * including subâ€setting, sampling, and reorganizing the data. The table below gives some example combinations + * of source and destination, and the operations they implement. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Selection operations
    + *

    Source

    + *
    + *

    Destination

    + *
    + *

    Operation

    + *
    + *

    All

    + *
    + *

    All

    + *
    + *

    Copy whole array

    + *
    + *

    All

    + *
    + *

    All (different shape)

    + *
    + *

    Copy and reorganize array

    + *
    + *

    Hyperslab

    + *
    + *

    All

    + *
    + *

    Sub-set

    + *
    + *

    Hyperslab

    + *
    + *

    Hyperslab (same shape)

    + *
    + *

    Selection

    + *
    + *

    Hyperslab

    + *
    + *

    Hyperslab (different shape)

    + *
    + *

    Select and rearrange

    + *
    + *

    Hyperslab with stride or block

    + *
    + *

    All or hyperslab with stride 1

    + *
    + *

    Sub-sample, scatter

    + *
    + *

    Hyperslab

    + *
    + *

    Points

    + *
    + *

    Scatter

    + *
    + *

    Points

    + *
    + *

    Hyperslab or all

    + *
    + *

    Gather

    + *
    + *

    Points

    + *
    + *

    Points (same)

    + *
    + *

    Selection

    + *
    + *

    Points

    + *
    + *

    Points (different)

    + *
    + *

    Reorder points

    + *
    + * + * \subsection subsec_dataspace_select Dataspace Selection Operations and Data Transfer + * + * This section is under construction. + * + * \subsection subsec_dataspace_refer References to Dataset Regions + * + * Another use of selections is to store a reference to a region of a dataset. An HDF5 object reference + * object is a pointer to an object (dataset, group, or committed datatype) in the file. A selection can + * be used to create a pointer to a set of selected elements of a dataset, called a region reference. The + * selection can be either a point selection or a hyperslab selection. + * + * A region reference is an object maintained by the HDF5 Library. The region reference can be stored in a + * dataset or attribute, and then read. The dataset or attribute is defined to have the special datatype, + * #H5T_STD_REF_DSETREG. + * + * To discover the elements and/or read the data, the region reference can be dereferenced. The + * #H5Rdereference call returns an identifier for the dataset, and then the selected dataspace can be + * retrieved with a call to #H5Rget_region(). The selected dataspace can be used to read the selected data + * elements. + * + * For more information, \see subsubsec_datatype_other_refs. + * + * \subsubsection subsubsec_dataspace_refer_use Example Uses for Region References + * + * Region references are used to implement stored pointers to data within a dataset. For example, features + * in a large dataset might be indexed by a table. See the figure below. This table could be stored as an + * HDF5 dataset with a compound datatype, for example, with a field for the name of the feature and a region + * reference to point to the feature in the dataset. See the second figure below. + * + * + * + * + * + *
    + * \image html Dspace_features.gif " Features indexed by a table" + *
    + * + * + * + * + * + *
    + * \image html Dspace_features_cmpd.gif "Storing the table with a compound datatype" + *
    + * + * + * \subsubsection subsubsec_dataspace_refer_create Creating References to Regions + * + * To create a region reference: + * \li 1. Create or open the dataset that contains the region + * \li 2. Get the dataspace for the dataset + * \li 3. Define a selection that specifies the region + * \li 4. Create a region reference using the dataset and dataspace with selection + * \li 5. Write the region reference(s) to the desired dataset or attribute + * + * The figure below shows a diagram of a file with three datasets. Dataset D1 and D2 are two dimensional + * arrays of integers. Dataset R1 is a one dimensional array of references to regions in D1 and D2. The + * regions can be any valid selection of the dataspace of the target dataset. + * + * + * + * + *
    + * \image html Dspace_three_datasets.gif "A file with three datasets" + *
    + * Note: In the figure above, R1 is a 1 D array of region pointers; each pointer refers to a selection + * in one dataset. + * + * The example below shows code to create the array of region references. The references are created in an + * array of type #hdset_reg_ref_t. Each region is defined as a selection on the dataspace of the dataset, + * and a reference is created using \ref H5Rcreate(). The call to \ref H5Rcreate() specifies the file, + * dataset, and the dataspace with selection. + * + * Create an array of region references + * \code + * // create an array of 4 region references + * hdset_reg_ref_t ref[4]; + * + * // Create a reference to the first hyperslab in the first Dataset. + * offset[0] = 1; offset[1] = 1; + * count[0] = 3; count[1] = 2; + * status = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, offset, NULL, count, NULL); + * status = H5Rcreate(&ref[0], file_id, "D1", H5R_DATASET_REGION, space_id); + * + * // The second reference is to a union of hyperslabs in the first Dataset + * offset[0] = 5; offset[1] = 3; + * count[0] = 1; count[1] = 4; + * status = H5Sselect_none(space_id); + * status = H5Sselect_hyperslab(space_id, H5S_SELECT_SET, offset, NULL, count, NULL); + * offset[0] = 6; offset[1] = 5; + * count[0] = 1; count[1] = 2; + * status = H5Sselect_hyperslab(space_id, H5S_SELECT_OR, offset, NULL, count, NULL); + * status = H5Rcreate(&ref[1], file_id, "D1", H5R_DATASET_REGION, space_id); + * + * // the fourth reference is to a selection of points in the first Dataset + * status = H5Sselect_none(space_id); + * coord[0][0] = 4; coord[0][1] = 4; + * coord[1][0] = 2; coord[1][1] = 6; + * coord[2][0] = 3; coord[2][1] = 7; + * coord[3][0] = 1; coord[3][1] = 5; + * coord[4][0] = 5; coord[4][1] = 8; + * + * status = H5Sselect_elements(space_id, H5S_SELECT_SET, num_points, (const hssize_t **)coord); + * status = H5Rcreate(&ref[3], file_id, "D1", H5R_DATASET_REGION, space_id); + * + * // the third reference is to a hyperslab in the second Dataset + * offset[0] = 0; offset[1] = 0; + * count[0] = 4; count[1] = 6; + * status = H5Sselect_hyperslab(space_id2, H5S_SELECT_SET, offset, NULL, count, NULL); + * status = H5Rcreate(&ref[2], file_id, "D2", H5R_DATASET_REGION, space_id2); + * \endcode + * + * When all the references are created, the array of references is written to the dataset R1. The + * dataset is declared to have datatype #H5T_STD_REF_DSETREG. See the example below. + * + * Write the array of references to a dataset + * \code + * Hsize_t dimsr[1]; + * dimsr[0] = 4; + * + * // Dataset with references. + * spacer_id = H5Screate_simple(1, dimsr, NULL); + * dsetr_id = H5Dcreate(file_id, "R1", H5T_STD_REF_DSETREG, spacer_id, H5P_DEFAULT, H5P_DEFAULT, + * H5P_DEFAULT); + * + * // Write dataset with the references. + * status = H5Dwrite(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref); + * + * \endcode + * + * When creating region references, the following rules are enforced. + * \li The selection must be a valid selection for the target dataset, just as when transferring data + * \li The dataset must exist in the file when the reference is created; #H5Rcreate + * \li The target dataset must be in the same file as the stored reference + * + * \subsubsection subsubsec_dataspace_refer_read Reading References to Regions + * + * To retrieve data from a region reference, the reference must be read from the file, and then the data can + * be retrieved. The steps are: + * \li 1. Open the dataset or attribute containing the reference objects + * \li 2. Read the reference object(s) + * \li 3. For each region reference, get the dataset (#H5Rdereference) and dataspace (#H5Rget_region) + * \li 4. Use the dataspace and datatype to discover what space is needed to store the data, allocate the + * correct storage and create a dataspace and datatype to define the memory data layout + * + * The example below shows code to read an array of region references from a dataset, and then read the + * data from the first selected region. Note that the region reference has information that records the + * dataset (within the file) and the selection on the dataspace of the dataset. After dereferencing the + * regions reference, the datatype, number of points, and some aspects of the selection can be discovered. + * (For a union of hyperslabs, it may not be possible to determine the exact set of hyperslabs that has been + * combined.) + * The table below the code example shows the inquiry functions. + * + * When reading data from a region reference, the following rules are enforced: + * \li The target dataset must be present and accessible in the file + * \li The selection must be a valid selection for the dataset + * + * Read an array of region references; read from the first selection + * \code + * dsetr_id = H5Dopen (file_id, "R1", H5P_DEFAULT); + * status = H5Dread(dsetr_id, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_out); + * + * // Dereference the first reference. + * // 1) get the dataset (H5Rdereference) + * // 2) get the selected dataspace (H5Rget_region) + * + * dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[0]); + * space_id = H5Rget_region(dsetr_id, H5R_DATASET_REGION, &ref_out[0]); + * + * // Discover how many points and shape of the data + * ndims = H5Sget_simple_extent_ndims(space_id); + * H5Sget_simple_extent_dims(space_id,dimsx,NULL); + * + * // Read and display hyperslab selection from the dataset. + * dimsy[0] = H5Sget_select_npoints(space_id); + * spacex_id = H5Screate_simple(1, dimsy, NULL); + * + * status = H5Dread(dsetv_id, H5T_NATIVE_INT, H5S_ALL, space_id, H5P_DEFAULT, data_out); + * printf("Selected hyperslab: "); + * for (i = 0; i < 8; i++) { + * printf("\n"); + * for (j = 0; j < 10; j++) + * printf("%d ", data_out[i][j]); + * } + * printf("\n"); + * \endcode + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    The inquiry functions
    + *

    Function

    + *
    + *

    Information

    + *
    + * @ref H5Sget_select_npoints + * + *

    The number of elements in the selection (hyperslab or point selection).

    + *
    + * @ref H5Sget_select_bounds + * + *

    The bounding box that encloses the selected points (hyperslab or point selection).

    + *
    + * @ref H5Sget_select_hyper_nblocks + * + *

    The number of blocks in the selection.

    + *
    + * @ref H5Sget_select_hyper_blocklist + * + *

    A list of the blocks in the selection.

    + *
    + * @ref H5Sget_select_elem_npoints + * + *

    The number of points in the selection.

    + *
    + * @ref H5Sget_select_elem_pointlist + * + *

    The points.

    + *
    + * + * + * \subsection subsec_dataspace_sample Sample Programs + * + * This section contains the full programs from which several of the code examples in this chapter were + * derived. The h5dump output from the program’s output file immediately follows each program. + * + * h5_write.c + * \code + * #include "hdf5.h" + * + * #define H5FILE_NAME "SDS.h5" + * #define DATASETNAME "C Matrix" + * #define NX 3 + * #define NY 5 + * #define RANK 2 // dataset dimensions + * + * int + * main (void) + * { + * hid_t file, dataset; // file and dataset identifiers + * hid_t datatype, dataspace; // identifiers + * hsize_t dims[2]; // dataset dimensions + * herr_t status; + * int data[NX][NY]; // data to write + * int i, j; + * + * // + * // Data and output buffer initialization. + * for (j = 0; j < NX; j++) { + * for (i = 0; i < NY; i++) + * data[j][i] = i + 1 + j*NY; + * } + * // 1 2 3 4 5 + * // 6 7 8 9 10 + * // 11 12 13 14 15 + * + * // Create a new file using H5F_ACC_TRUNC access, + * // default file creation properties, and default file + * // access properties. + * file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + * + * // Describe the size of the array and create the data space for fixed + * // size dataset. + * dims[0] = NX; + * dims[1] = NY; + * dataspace = H5Screate_simple(RANK, dims, NULL); + * + * // Create a new dataset within the file using defined dataspace and + * // datatype and default dataset creation properties. + * dataset = H5Dcreate(file, DATASETNAME, H5T_NATIVE_INT, dataspace, H5P_DEFAULT, + * H5P_DEFAULT, H5P_DEFAULT); + * + * // Write the data to the dataset using default transfer properties. + * status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + * + * // Close/release resources. + * H5Sclose(dataspace); + * H5Dclose(dataset); + * H5Fclose(file); + * + * return 0; + * } + * + * SDS.out + * ------- + * HDF5 "SDS.h5" { + * GROUP "/" { + * DATASET "C Matrix" { + * DATATYPE H5T_STD_I32BE + * DATASPACE SIMPLE { ( 3, 5 ) / ( 3, 5 ) } + * DATA { + * 1, 2, 3, 4, 5, + * 6, 7, 8, 9, 10, + * 11, 12, 13, 14, 15 + * } + * } + * + * \endcode + * + * h5_write.f90 + * \code + * ---------- + * PROGRAM DSETEXAMPLE + * + * USE HDF5 ! This module contains all necessary modules + * + * IMPLICIT NONE + * + * CHARACTER(LEN=7), PARAMETER :: filename = "SDSf.h5" ! File name + * CHARACTER(LEN=14), PARAMETER :: dsetname = "Fortran Matrix" ! Dataset name + * INTEGER, PARAMETER :: NX = 3 + * INTEGER, PARAMETER :: NY = 5 + * + * INTEGER(HID_T) :: file_id ! File identifier + * INTEGER(HID_T) :: dset_id ! Dataset identifier + * INTEGER(HID_T) :: dspace_id ! Dataspace identifier + * + * INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/3,5/) ! Dataset dimensions + * INTEGER :: rank = 2 ! Dataset rank + * INTEGER :: data(NX,NY) + * INTEGER :: error ! Error flag + * INTEGER :: i, j + * + * ! + * ! Initialize data + * ! + * do i = 1, NX + * do j = 1, NY + * data(i,j) = j + (i-1)*NY + * enddo + * enddo + * ! + * ! Data + * ! + * ! 1 2 3 4 5 + * ! 6 7 8 9 10 + * ! 11 12 13 14 15 + * + * ! + * ! Initialize FORTRAN interface. + * ! + * CALLh5open_f(error) + * + * ! + * ! Create a new file using default properties. + * ! + * CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) + * + * ! + * ! Create the dataspace. + * ! + * CALL h5screate_simple_f(rank, dims, dspace_id, error) + * + * ! + * ! Create and write dataset using default properties. + * ! + * CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, & + * dset_id, error, H5P_DEFAULT_F, H5P_DEFAULT_F, & + * H5P_DEFAULT_F) + * + * CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data, dims, error) + * + * ! + * ! End access to the dataset and release resources used by it. + * ! + * CALL h5dclose_f(dset_id, error) + * + * ! + * ! Terminate access to the data space. + * ! + * CALL h5sclose_f(dspace_id, error) + * + * ! + * ! Close the file. + * ! + * CALL h5fclose_f(file_id, error) + * + * ! + * ! Close FORTRAN interface. + * ! + * CALL h5close_f(error) + * + * END PROGRAM DSETEXAMPLE + * + * SDSf.out + * -------- + * HDF5 "SDSf.h5" { + * GROUP "/" { + * DATASET "Fortran Matrix" { + * DATATYPE H5T_STD_I32BE + * DATASPACE SIMPLE { ( 5, 3 ) / ( 5, 3 ) } + * DATA { + * 1, 6, 11, + * 2, 7, 12, + * 3, 8, 13, + * 4, 9, 14, + * 5, 10, 15 + * } + * } + * } + * } + * + * \endcode + * + * h5_write_tr.f90 + * \code + * PROGRAM DSETEXAMPLE + * + * USE HDF5 ! This module contains all necessary modules + * + * IMPLICIT NONE + * + * CHARACTER(LEN=10), PARAMETER :: filename = "SDSf_tr.h5" ! File name + * CHARACTER(LEN=24), PARAMETER :: dsetname = "Fortran Transpose Matrix"! Dataset name + * + * INTEGER, PARAMETER :: NX = 3 + * INTEGER, PARAMETER :: NY = 5 + * + * INTEGER(HID_T) :: file_id ! File identifier + * INTEGER(HID_T) :: dset_id ! Dataset identifier + * INTEGER(HID_T) :: dspace_id ! Dataspace identifier + * + * INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/NY, NX/) ! Dataset dimensions + * INTEGER :: rank = 2 ! Dataset rank + * INTEGER :: data(NY,NX) + * + * INTEGER :: error ! Error flag + * INTEGER :: i, j + * + * ! + * ! Initialize data + * ! + * do i = 1, NY + * do j = 1, NX + * data(i,j) = i + (j-1)*NY + * enddo + * enddo + * + * ! + * ! Data + * ! + * ! 1 6 11 + * ! 2 7 12 + * ! 3 8 13 + * ! 4 9 14 + * ! 5 10 15 + * + * ! + * ! Initialize FORTRAN interface. + * ! + * CALL h5open_f(error) + * + * ! + * ! Create a new file using default properties. + * ! + * CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error) + * + * ! + * ! Create the dataspace. + * ! + * CALL h5screate_simple_f(rank, dims, dspace_id, error) + * + * ! + * ! Create and write dataset using default properties. + * ! + * CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, & + * dset_id, error, H5P_DEFAULT_F, H5P_DEFAULT_F, & + * H5P_DEFAULT_F) + * CALL h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, data, dims, error) + * + * ! + * ! End access to the dataset and release resources used by it. + * ! + * CALL h5dclose_f(dset_id, error) + * + * ! + * ! Terminate access to the data space. + * ! + * CALL h5sclose_f(dspace_id, error) + * + * ! + * ! Close the file. + * ! + * CALL h5fclose_f(file_id, error) + * + * ! + * ! Close FORTRAN interface. + * ! + * CALL h5close_f(error) + * + * END PROGRAM DSETEXAMPLE + * + * SDSf_tr.out + * ----------- + * HDF5 "SDSf_tr.h5" { + * GROUP "/" { + * DATASET "Fortran Transpose Matrix" { + * DATATYPE H5T_STD_I32LE + * DATASPACE SIMPLE { ( 3, 5 ) / ( 3, 5 ) } + * DATA { + * 1, 2, 3, 4, 5, + * 6, 7, 8, 9, 10, + * 11, 12, 13, 14, 15 + * } + * } + * } + * } + * + * \endcode + * + * Previous Chapter \ref sec_datatype - Next Chapter \ref sec_attribute + * + */ + +/** + * \defgroup H5S Dataspaces (H5S) + * + * Use the functions in this module to manage HDF5 dataspaces \Emph{and} selections. + * + * HDF5 dataspaces describe the \Emph{shape} of datasets in memory or in HDF5 + * files. Dataspaces can be empty (#H5S_NULL), a singleton (#H5S_SCALAR), or + * a multi-dimensional, regular grid (#H5S_SIMPLE). Dataspaces can be re-shaped. + * + * Subsets of dataspaces can be "book-marked" or used to restrict I/O operations + * using \Emph{selections}. Furthermore, certain set operations are supported + * for selections. + * + * */ #endif /* H5Smodule_H */ diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 7b85209c650..0eb6dcb43f8 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -73,10 +72,10 @@ static herr_t H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_poin static herr_t H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted); -static herr_t H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute_map, +static herr_t H5S__mpio_permute_type(H5S_t *space, size_t elmt_size, hsize_t **permute_map, MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); -static herr_t H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, - int *count, hbool_t *is_derived_type); +static herr_t H5S__mpio_reg_hyper_type(H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type); static herr_t H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, hbool_t *is_derived_type); static herr_t H5S__release_datatype(H5S_mpio_mpitype_list_t *type_list); @@ -95,6 +94,9 @@ static herr_t H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t * /* Declare a free list to manage the H5S_mpio_mpitype_node_t struct */ H5FL_DEFINE_STATIC(H5S_mpio_mpitype_node_t); +/* Declare a free list to manage dataspace selection iterators */ +H5FL_EXTERN(H5S_sel_iter_t); + /*------------------------------------------------------------------------- * Function: H5S__mpio_all_type * @@ -201,11 +203,11 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points, MPI_Aint * { MPI_Datatype elmt_type; /* MPI datatype for individual element */ hbool_t elmt_type_created = FALSE; /* Whether the element MPI datatype was created */ - int * inner_blocks = NULL; /* Arrays for MPI datatypes when "large" datatype needed */ - MPI_Aint * inner_disps = NULL; + int *inner_blocks = NULL; /* Arrays for MPI datatypes when "large" datatype needed */ + MPI_Aint *inner_disps = NULL; MPI_Datatype *inner_types = NULL; #if MPI_VERSION < 3 - int * blocks = NULL; /* Array of block sizes for MPI hindexed create call */ + int *blocks = NULL; /* Array of block sizes for MPI hindexed create call */ hsize_t u; /* Local index variable */ #endif hsize_t bigio_count; /* Transition point to create derived type */ @@ -368,7 +370,7 @@ static herr_t H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute, hbool_t *is_permuted) { - MPI_Aint * disp = NULL; /* Datatype displacement for each point*/ + MPI_Aint *disp = NULL; /* Datatype displacement for each point*/ H5S_pnt_node_t *curr = NULL; /* Current point being operated on in from the selection */ hssize_t snum_points; /* Signed number of elements in selection */ hsize_t num_points; /* Sumber of points in the selection */ @@ -501,17 +503,19 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, MPI_Datatype *new_type, - int *count, hbool_t *is_derived_type) +H5S__mpio_permute_type(H5S_t *space, size_t elmt_size, hsize_t **permute, MPI_Datatype *new_type, int *count, + hbool_t *is_derived_type) { - MPI_Aint * disp = NULL; /* Datatype displacement for each point*/ - H5S_sel_iter_t sel_iter; /* Selection iteration info */ - hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ - hssize_t snum_points; /* Signed number of elements in selection */ - hsize_t num_points; /* Number of points in the selection */ - size_t max_elem; /* Maximum number of elements allowed in sequences */ - hsize_t u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + MPI_Aint *disp = NULL; /* Datatype displacement for each point*/ + H5S_sel_iter_t *sel_iter = NULL; /* Selection iteration info */ + hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ + hssize_t snum_points; /* Signed number of elements in selection */ + hsize_t num_points; /* Number of points in the selection */ + hsize_t *off = NULL; + size_t *len = NULL; + size_t max_elem; /* Maximum number of elements allowed in sequences */ + hsize_t u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -527,8 +531,18 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, if (NULL == (disp = (MPI_Aint *)H5MM_malloc(sizeof(MPI_Aint) * num_points))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of displacements") + /* Allocate arrays to hold sequence offsets and lengths */ + if (NULL == (off = H5MM_malloc(H5D_IO_VECTOR_SIZE * sizeof(*off)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate sequence offsets array") + if (NULL == (len = H5MM_malloc(H5D_IO_VECTOR_SIZE * sizeof(*len)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate sequence lengths array") + + /* Allocate a selection iterator for iterating over the dataspace */ + if (NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "couldn't allocate dataspace selection iterator") + /* Initialize selection iterator */ - if (H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0) + if (H5S_select_iter_init(sel_iter, space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") sel_iter_init = TRUE; /* Selection iteration info has been initialized */ @@ -538,14 +552,12 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, /* Loop, while elements left in selection */ u = 0; while (max_elem > 0) { - hsize_t off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */ - size_t len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */ - size_t nelem; /* Number of elements used in sequences */ - size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequence being worked on */ + size_t nelem; /* Number of elements used in sequences */ + size_t nseq; /* Number of sequences generated */ + size_t curr_seq; /* Current sequence being worked on */ /* Get the sequences of bytes */ - if (H5S_SELECT_ITER_GET_SEQ_LIST(&sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, + if (H5S_SELECT_ITER_GET_SEQ_LIST(sel_iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "sequence length generation failed") @@ -602,9 +614,14 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, done: /* Release selection iterator */ - if (sel_iter_init) - if (H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) + if (sel_iter) { + if (sel_iter_init && H5S_SELECT_ITER_RELEASE(sel_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter); + } + + H5MM_free(len); + H5MM_free(off); /* Free memory */ if (disp) @@ -634,11 +651,11 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, *------------------------------------------------------------------------- */ static herr_t -H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, +H5S__mpio_reg_hyper_type(H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) { - H5S_sel_iter_t sel_iter; /* Selection iteration info */ - hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ + H5S_sel_iter_t *sel_iter = NULL; /* Selection iteration info */ + hbool_t sel_iter_init = FALSE; /* Selection iteration info has been initialized */ struct dim { /* less hassle than malloc/free & ilk */ hssize_t start; @@ -668,32 +685,37 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new HDassert(sizeof(MPI_Aint) >= sizeof(elmt_size)); bigio_count = H5_mpi_get_bigio_count(); + + /* Allocate a selection iterator for iterating over the dataspace */ + if (NULL == (sel_iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "couldn't allocate dataspace selection iterator") + /* Initialize selection iterator */ - if (H5S_select_iter_init(&sel_iter, space, elmt_size, 0) < 0) + if (H5S_select_iter_init(sel_iter, space, elmt_size, 0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") sel_iter_init = TRUE; /* Selection iteration info has been initialized */ /* Abbreviate args */ - diminfo = sel_iter.u.hyp.diminfo; + diminfo = sel_iter->u.hyp.diminfo; HDassert(diminfo); /* Make a local copy of the dimension info so we can operate with them */ /* Check if this is a "flattened" regular hyperslab selection */ - if (sel_iter.u.hyp.iter_rank != 0 && sel_iter.u.hyp.iter_rank < space->extent.rank) { + if (sel_iter->u.hyp.iter_rank != 0 && sel_iter->u.hyp.iter_rank < space->extent.rank) { /* Flattened selection */ - rank = sel_iter.u.hyp.iter_rank; + rank = sel_iter->u.hyp.iter_rank; #ifdef H5S_DEBUG if (H5DEBUG(S)) HDfprintf(H5DEBUG(S), "%s: Flattened selection\n", FUNC); #endif for (u = 0; u < rank; ++u) { H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t) - d[u].start = (hssize_t)diminfo[u].start + sel_iter.u.hyp.sel_off[u]; + d[u].start = (hssize_t)diminfo[u].start + sel_iter->u.hyp.sel_off[u]; d[u].strid = diminfo[u].stride; d[u].block = diminfo[u].block; d[u].count = diminfo[u].count; - d[u].xtent = sel_iter.u.hyp.size[u]; + d[u].xtent = sel_iter->u.hyp.size[u]; #ifdef H5S_DEBUG if (H5DEBUG(S)) { @@ -803,8 +825,8 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new else /* Create the compound datatype for this operation (> 2GB) */ if (H5_mpio_create_large_type(elmt_size, 0, MPI_BYTE, &inner_type) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, - "couldn't create a large inner datatype in hyper selection") + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, + "couldn't create a large inner datatype in hyper selection") /******************************************************* * Construct the type by walking the hyperslab dims @@ -951,9 +973,11 @@ H5S__mpio_reg_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new done: /* Release selection iterator */ - if (sel_iter_init) - if (H5S_SELECT_ITER_RELEASE(&sel_iter) < 0) + if (sel_iter) { + if (sel_iter_init && H5S_SELECT_ITER_RELEASE(sel_iter) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + sel_iter = H5FL_FREE(H5S_sel_iter_t, sel_iter); + } #ifdef H5S_DEBUG if (H5DEBUG(S)) @@ -1116,10 +1140,10 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t e hsize_t bigio_count; /* Transition point to create derived type */ size_t alloc_count = 0; /* Number of span tree nodes allocated at this level */ size_t outercount = 0; /* Number of span tree nodes at this level */ - MPI_Datatype * inner_type = NULL; + MPI_Datatype *inner_type = NULL; hbool_t inner_types_freed = FALSE; /* Whether the inner_type MPI datatypes have been freed */ - int * blocklen = NULL; - MPI_Aint * disp = NULL; + int *blocklen = NULL; + MPI_Aint *disp = NULL; size_t u; /* Local index variable */ int mpi_code; /* MPI return status code */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1145,7 +1169,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t e /* If this is the fastest changing dimension, it is the base case for derived datatype. */ span = spans->head; if (NULL == span->down) { - hbool_t large_block = FALSE; /* Wether the block length is larger than 32 bit integer */ + hbool_t large_block = FALSE; /* Whether the block length is larger than 32 bit integer */ outercount = 0; while (span) { @@ -1154,7 +1178,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t e /* Check if we need to increase the size of the buffers */ if (outercount >= alloc_count) { MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */ - int * tmp_blocklen; /* Temporary pointer to new block length buffer */ + int *tmp_blocklen; /* Temporary pointer to new block length buffer */ /* Double the allocation count */ alloc_count *= 2; @@ -1246,8 +1270,8 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t e /* Check if we need to increase the size of the buffers */ if (outercount >= alloc_count) { - MPI_Aint * tmp_disp; /* Temporary pointer to new displacement buffer */ - int * tmp_blocklen; /* Temporary pointer to new block length buffer */ + MPI_Aint *tmp_disp; /* Temporary pointer to new displacement buffer */ + int *tmp_blocklen; /* Temporary pointer to new block length buffer */ MPI_Datatype *tmp_inner_type; /* Temporary pointer to inner MPI datatype buffer */ /* Double the allocation count */ @@ -1364,7 +1388,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down, size_t e *------------------------------------------------------------------------- */ herr_t -H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, +H5S_mpio_space_type(H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Snone.c b/src/H5Snone.c index 82e513e14eb..116396b9db1 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -49,22 +48,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 herr_t H5S__none_deserialize(H5S_t **space, const 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, const size_t p_size, hbool_t skip); 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 +143,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 +512,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 +532,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 +547,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 */ @@ -594,12 +593,13 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_deserialize(H5S_t **space, const uint8_t **p) +H5S__none_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, hbool_t skip) { - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, - either *space or a newly allocated one */ - uint32_t version; /* Version number */ - herr_t ret_value = SUCCEED; /* return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + uint32_t version; /* Version number */ + herr_t ret_value = SUCCEED; /* return value */ + const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */ FUNC_ENTER_STATIC @@ -619,12 +619,16 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) tmp_space = *space; /* Decode version */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *p, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection version") UINT32DECODE(*p, version); if (version < H5S_NONE_VERSION_1 || version > H5S_NONE_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for none selection") /* Skip over the remainder of the header */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *p, 8, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection header") *p += 8; /* Change to "none" selection */ @@ -803,7 +807,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 +820,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 +837,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 +850,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 +868,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 +881,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 496cab65777..46631f69eb2 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -150,7 +149,7 @@ struct H5S_pnt_list_t { struct H5S_hyper_span_t { hsize_t low, high; /* Low & high bounds of elements selected for span, inclusive */ struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */ - struct H5S_hyper_span_t * next; /* Pointer to next span in list */ + struct H5S_hyper_span_t *next; /* Pointer to next span in list */ }; /* "Operation info" struct. Used to hold temporary information during copies, @@ -201,7 +200,7 @@ struct H5S_hyper_span_info_t { typedef enum { H5S_DIMINFO_VALID_IMPOSSIBLE, /* 0: diminfo is not valid and can never be valid with the current selection */ - H5S_DIMINFO_VALID_NO, /* 1: diminfo is not valid but may or may not be possible to constuct */ + H5S_DIMINFO_VALID_NO, /* 1: diminfo is not valid but may or may not be possible to construct */ H5S_DIMINFO_VALID_YES /* 2: diminfo is valid */ } H5S_diminfo_valid_t; @@ -242,11 +241,12 @@ 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); +typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t **space, const uint8_t **p, const size_t p_size, + hbool_t skip); /* Method to determine smallest n-D bounding box containing the current selection */ typedef herr_t (*H5S_sel_bounds_func_t)(const H5S_t *space, hsize_t *start, hsize_t *end); /* Method to determine linear offset of initial element in selection within dataspace */ @@ -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 { @@ -286,7 +285,7 @@ typedef struct { H5S_sel_release_func_t release; /* Method to release current selection */ H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */ H5S_sel_serial_size_func_t - serial_size; /* Method to determine number of bytes required to store current selection */ + serial_size; /* Method to determine number of bytes required to store current selection */ H5S_sel_serialize_func_t serialize; /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ H5S_sel_deserialize_func_t deserialize; /* Method to store create selection from "serialized" form (a byte @@ -294,7 +293,7 @@ typedef struct { H5S_sel_bounds_func_t bounds; /* Method to determine to smallest n-D bounding box containing the current selection */ H5S_sel_offset_func_t - offset; /* Method to determine linear offset of initial element in selection within dataspace */ + offset; /* Method to determine linear offset of initial element in selection within dataspace */ H5S_sel_unlim_dim_func_t unlim_dim; /* Method to get unlimited dimension of selection (or -1 for none) */ H5S_sel_num_elem_non_unlim_func_t num_elem_non_unlim; /* Method to get the number of elements in a slice through the unlimited dimension */ @@ -304,9 +303,9 @@ typedef struct { H5S_sel_shape_same_func_t shape_same; /* Method to determine if two dataspaces' selections are the same shape */ H5S_sel_intersect_block_func_t - intersect_block; /* Method to determine if a dataspaces' selection intersects a block */ - H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */ - H5S_sel_adjust_s_func_t adjust_s; /* Method to adjust a selection by an offset (signed) */ + intersect_block; /* Method to determine if a dataspaces' selection intersects a block */ + H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */ + H5S_sel_adjust_s_func_t adjust_s; /* Method to adjust a selection by an offset (signed) */ H5S_sel_project_scalar project_scalar; /* Method to construct scalar dataspace projection */ H5S_sel_project_simple project_simple; /* Method to construct simple dataspace projection */ H5S_sel_iter_init_func_t iter_init; /* Method to initialize iterator for current selection */ @@ -322,7 +321,7 @@ typedef struct { hsize_t num_elem; /* Number of elements in selection */ union { - H5S_pnt_list_t * pnt_lst; /* Info about list of selected points (order is important) */ + H5S_pnt_list_t *pnt_lst; /* Info about list of selected points (order is important) */ H5S_hyper_sel_t *hslab; /* Info about hyperslab selection */ } sel_info; } H5S_select_t; @@ -370,7 +369,7 @@ typedef struct H5S_sel_iter_class_t { H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */ H5S_sel_iter_get_seq_list_func_t - iter_get_seq_list; /* Method to retrieve a list of offset/length sequences for selection iterator */ + iter_get_seq_list; /* Method to retrieve a list of offset/length sequences for selection iterator */ H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ } H5S_sel_iter_class_t; @@ -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); /* Testing functions */ #ifdef H5S_TESTING diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 929499f0a78..7ef7c38dcba 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -59,22 +58,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 herr_t H5S__point_deserialize(H5S_t **space, const 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, const size_t p_size, hbool_t skip); 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 */ @@ -123,7 +122,7 @@ const H5S_select_class_t H5S_sel_point[1] = {{ H5S__point_iter_init, }}; -/* Format version bounds for dataspace hyperslab selection */ +/* Format version bounds for dataspace point selection */ const unsigned H5O_sds_point_ver_bounds[] = { H5S_POINT_VERSION_1, /* H5F_LIBVER_EARLIEST */ H5S_POINT_VERSION_1, /* H5F_LIBVER_V18 */ @@ -169,7 +168,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 */ @@ -1001,7 +1000,7 @@ H5S__point_is_valid(const H5S_t *space) hssize_t H5Sget_select_elem_npoints(hid_t spaceid) { - H5S_t * space; /* Dataspace to modify selection of */ + H5S_t *space; /* Dataspace to modify selection of */ hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) @@ -1059,7 +1058,7 @@ H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t * hsize_t bounds_start[H5S_MAX_RANK]; /* Starting coordinate of bounding box */ hsize_t bounds_end[H5S_MAX_RANK]; /* Opposite coordinate of bounding box */ hsize_t max_size = 0; /* Maximum selection size */ - unsigned u; /* Local index veriable */ + unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1158,7 +1157,7 @@ H5S__point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t * 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 */ @@ -1203,7 +1202,7 @@ H5S__point_serial_size(const H5S_t *space) 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. @@ -1218,11 +1217,11 @@ H5S__point_serial_size(const H5S_t *space) 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 */ - uint8_t * lenp = NULL; /* pointer to length location for later storage */ + uint8_t *pp; /* Local pointer for encoding */ + uint8_t *lenp = NULL; /* pointer to length location for later storage */ uint32_t len = 0; /* number of bytes used */ unsigned u; /* local counting variable */ uint32_t version; /* Version number */ @@ -1351,20 +1350,20 @@ H5S__point_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__point_deserialize(H5S_t **space, const uint8_t **p) +H5S__point_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size, hbool_t skip) { - H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, - either *space or a newly allocated one */ - hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */ - uint32_t version; /* Version number */ - uint8_t enc_size = 0; /* Encoded size of selection info */ - hsize_t * coord = NULL, *tcoord; /* Pointer to array of elements */ - const uint8_t *pp; /* Local pointer for decoding */ - uint64_t num_elem = 0; /* Number of elements in selection */ - unsigned rank; /* Rank of points */ - unsigned i, j; /* local counting variables */ - herr_t ret_value = SUCCEED; /* Return value */ - + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */ + uint32_t version; /* Version number */ + uint8_t enc_size = 0; /* Encoded size of selection info */ + hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ + const uint8_t *pp; /* Local pointer for decoding */ + uint64_t num_elem = 0; /* Number of elements in selection */ + unsigned rank; /* Rank of points */ + unsigned i, j; /* local counting variables */ + herr_t ret_value = SUCCEED; /* Return value */ + const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */ FUNC_ENTER_STATIC /* Check args */ @@ -1385,16 +1384,23 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) tmp_space = *space; /* Decode version */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection version") UINT32DECODE(pp, version); if (version < H5S_POINT_VERSION_1 || version > H5S_POINT_VERSION_LATEST) HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for point selection") - if (version >= (uint32_t)H5S_POINT_VERSION_2) + if (version >= (uint32_t)H5S_POINT_VERSION_2) { /* Decode size of point info */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 1, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding point info") enc_size = *(pp)++; + } else { /* Skip over the remainder of the header */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, 8, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection headers") pp += 8; enc_size = H5S_SELECT_INFO_ENC_SIZE_4; } @@ -1404,6 +1410,8 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "unknown size of point/offset info for selection") /* Decode the rank of the point selection */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection rank") UINT32DECODE(pp, rank); if (!*space) { @@ -1415,18 +1423,30 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) else /* Verify the rank of the provided dataspace */ if (rank != tmp_space->extent.rank) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, - "rank of serialized selection does not match dataspace") + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "rank of serialized selection does not match dataspace") /* decode the number of points */ switch (enc_size) { case H5S_SELECT_INFO_ENC_SIZE_2: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint16_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding number of points") + UINT16DECODE(pp, num_elem); break; case H5S_SELECT_INFO_ENC_SIZE_4: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding number of points") + UINT32DECODE(pp, num_elem); break; case H5S_SELECT_INFO_ENC_SIZE_8: + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, sizeof(uint64_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, + "buffer overflow while decoding number of points") + UINT64DECODE(pp, num_elem); break; default: @@ -1438,6 +1458,29 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) if (NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information") + /* Determine necessary size of buffer for coordinates */ + size_t enc_type_size = 0; + + switch (enc_size) { + case H5S_SELECT_INFO_ENC_SIZE_2: + enc_type_size = sizeof(uint16_t); + break; + case H5S_SELECT_INFO_ENC_SIZE_4: + enc_type_size = sizeof(uint32_t); + break; + case H5S_SELECT_INFO_ENC_SIZE_8: + enc_type_size = sizeof(uint64_t); + break; + default: + HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "unknown point info size") + break; + } + + size_t coordinate_buffer_requirement = num_elem * rank * enc_type_size; + + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, pp, coordinate_buffer_requirement, p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection coordinates") + /* Retrieve the coordinates from the buffer */ for (tcoord = coord, i = 0; i < num_elem; i++) for (j = 0; j < (unsigned)rank; j++, tcoord++) @@ -1445,11 +1488,9 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) case H5S_SELECT_INFO_ENC_SIZE_2: UINT16DECODE(pp, *tcoord); break; - case H5S_SELECT_INFO_ENC_SIZE_4: UINT32DECODE(pp, *tcoord); break; - case H5S_SELECT_INFO_ENC_SIZE_8: UINT64DECODE(pp, *tcoord); break; @@ -1504,7 +1545,7 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) dataspace they are located within. The list of points is formatted as follows: followed by the next coordinate, etc. until all the point information in the selection have been put into the user's buffer. - The points are returned in the order they will be interated through + The points are returned in the order they will be iterated through when a selection is read/written from/to disk. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS @@ -1578,7 +1619,7 @@ H5S__get_select_elem_pointlist(const H5S_t *space, hsize_t startpoint, hsize_t n dataspace they are located within. The list of points is formatted as follows: followed by the next coordinate, etc. until all the point information in the selection have been put into the user's buffer. - The points are returned in the order they will be interated through + The points are returned in the order they will be iterated through when a selection is read/written from/to disk. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS @@ -1691,9 +1732,9 @@ 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 *offset) { - const hsize_t * pnt; /* Pointer to a selected point's coordinates */ + const hsize_t *pnt; /* Pointer to a selected point's coordinates */ const hssize_t *sel_offset; /* Pointer to the selection's offset */ - const hsize_t * dim_size; /* Pointer to a dataspace's extent */ + const hsize_t *dim_size; /* Pointer to a dataspace's extent */ hsize_t accum; /* Accumulator for dimension sizes */ int i; /* index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1842,7 +1883,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 @@ -1857,7 +1898,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 */ @@ -1882,8 +1923,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 @@ -1895,7 +1936,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 */ @@ -1988,7 +2029,7 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) 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 @@ -2001,7 +2042,7 @@ H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2) 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 */ @@ -2230,8 +2271,8 @@ static herr_t H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset) { const H5S_pnt_node_t *base_node; /* Point node in base space */ - H5S_pnt_node_t * new_node; /* Point node in new space */ - H5S_pnt_node_t * prev_node; /* Previous point node in new space */ + H5S_pnt_node_t *new_node; /* Point node in new space */ + H5S_pnt_node_t *prev_node; /* Previous point node in new space */ unsigned rank_diff; /* Difference in ranks between spaces */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2317,7 +2358,7 @@ H5S__point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of /* Copy over the point's coordinates */ HDmemset(new_node->pnt, 0, sizeof(hsize_t) * rank_diff); H5MM_memcpy(&new_node->pnt[rank_diff], base_node->pnt, - (new_space->extent.rank * sizeof(hsize_t))); + (base_space->extent.rank * sizeof(hsize_t))); /* Keep the order the same when copying */ if (NULL == prev_node) diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 76ed23792c0..c2fd2241d7e 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -73,7 +72,7 @@ typedef struct { /* Irregular hyperslab selection fields */ hsize_t loc_off[H5S_MAX_RANK]; /* Byte offset in buffer, for each dimension's current offset */ H5S_hyper_span_info_t *spans; /* Pointer to copy of the span tree */ - H5S_hyper_span_t * span[H5S_MAX_RANK]; /* Array of pointers to span nodes */ + H5S_hyper_span_t *span[H5S_MAX_RANK]; /* Array of pointers to span nodes */ } H5S_hyper_iter_t; /* "All" selection iteration container */ @@ -191,7 +190,7 @@ typedef struct H5S_sel_iter_op_t { #define H5S_SELECT_SHAPE_SAME(S1, S2) (H5S_select_shape_same(S1, S2)) #define H5S_SELECT_INTERSECT_BLOCK(S, START, END) (H5S_select_intersect_block(S, START, END)) #define H5S_SELECT_RELEASE(S) (H5S_select_release(S)) -#define H5S_SELECT_DESERIALIZE(S, BUF) (H5S_select_deserialize(S, BUF)) +#define H5S_SELECT_DESERIALIZE(S, BUF, BUF_SIZE) (H5S_select_deserialize(S, BUF, BUF_SIZE)) /* Forward declaration of structs used below */ struct H5O_t; @@ -201,7 +200,7 @@ struct H5O_loc_t; typedef struct H5S_t H5S_t; /* Operations on dataspaces */ -H5_DLL H5S_t * H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max); +H5_DLL H5S_t *H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max); H5_DLL herr_t H5S_close(H5S_t *ds); H5_DLL H5S_class_t H5S_get_simple_extent_type(const H5S_t *ds); H5_DLL hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds); @@ -216,7 +215,7 @@ H5_DLL htri_t H5S_set_extent(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hsize_t *max); H5_DLL H5S_t *H5S_create(H5S_class_t type); -H5_DLL herr_t H5S_get_validated_dataspace(hid_t space_id, const H5S_t **space /*out*/); +H5_DLL herr_t H5S_get_validated_dataspace(hid_t space_id, H5S_t **space /*out*/); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]); H5_DLL herr_t H5S_set_version(H5F_t *f, H5S_t *ds); H5_DLL herr_t H5S_encode(H5S_t *obj, unsigned char **p, size_t *nalloc); @@ -230,38 +229,37 @@ H5_DLL htri_t H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2); 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 herr_t H5S_select_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size); 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, hsize_t element_size, + ptrdiff_t *buf_adj); +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); @@ -286,12 +284,11 @@ H5_DLL hsize_t H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *m hbool_t incl_trail); H5_DLL hsize_t H5S_hyper_get_clip_extent_match(const H5S_t *clip_space, const H5S_t *match_space, hsize_t match_clip_size, hbool_t incl_trail); -H5_DLL H5S_t * H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index); +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); @@ -301,7 +298,7 @@ H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter); H5_DLL herr_t H5S_sel_iter_close(H5S_sel_iter_t *sel_iter); #ifdef H5_HAVE_PARALLEL -H5_DLL herr_t H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, +H5_DLL herr_t H5S_mpio_space_type(H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, int *count, hbool_t *is_derived_type, hbool_t do_permute, hsize_t **permute_map, hbool_t *is_permuted); #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 331e5ee8070..72fcc654285 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -21,99 +20,103 @@ #include "H5public.h" #include "H5Ipublic.h" -/* Define atomic datatypes */ +/* Define special dataspaces for dataset I/O operations */ #define H5S_ALL (hid_t)0 -#define H5S_UNLIMITED HSIZE_UNDEF +#define H5S_UNLIMITED HSIZE_UNDEF /**< Value for 'unlimited' dimensions */ -/* Define user-level maximum number of dimensions */ +/** + * The maximum dataspace rank or number of dimensions + */ #define H5S_MAX_RANK 32 /* Flags for selection iterators */ #define H5S_SEL_ITER_GET_SEQ_LIST_SORTED \ - 0x0001 /* Retrieve elements from iterator \ - * in increasing offset order, for \ - * each call to retrieve sequences. \ - * Currently, this only applies to \ - * point selections, as hyperslab \ - * selections are always returned \ - * in increasing offset order. \ - * \ - * Note that the order is only \ - * increasing for each call to \ - * get_seq_list, the next set of \ - * sequences could start with an \ - * earlier offset than the previous \ - * one. \ + 0x0001 /**< Retrieve elements from iterator in increasing offset order, for \ + * each call to retrieve sequences. Currently, this only applies to \ + * point selections, as hyperslab selections are always returned in \ + * increasing offset order. Note that the order is only increasing \ + * for each call to H5Sget_seq_list(), the next set of sequences \ + * could start with an earlier offset than the previous one. \ */ #define H5S_SEL_ITER_SHARE_WITH_DATASPACE \ - 0x0002 /* Don't copy the dataspace \ - * selection when creating the \ - * selection iterator. \ - * \ - * This can improve performance \ - * of creating the iterator, but \ - * the dataspace _MUST_NOT_ be \ - * modified or closed until the \ - * selection iterator is closed \ - * or the iterator's behavior \ - * will be undefined. \ + 0x0002 /**< Don't copy the dataspace selection when creating the selection \ + * iterator. This can improve performance of creating the iterator, \ + * but the dataspace \Bold{MUST NOT} be modified or closed until the \ + * selection iterator is closed or the iterator's behavior will be \ + * undefined. \ */ -/* Different types of dataspaces */ +/** + * Types of dataspaces + */ typedef enum H5S_class_t { - H5S_NO_CLASS = -1, /*error */ - H5S_SCALAR = 0, /*scalar variable */ - H5S_SIMPLE = 1, /*simple dataspace */ - H5S_NULL = 2 /*null dataspace */ + H5S_NO_CLASS = -1, /**< Error */ + H5S_SCALAR = 0, /**< Singleton (scalar) */ + H5S_SIMPLE = 1, /**< Regular grid */ + H5S_NULL = 2 /**< Empty set */ } H5S_class_t; -/* Different ways of combining selections */ +/** + * Different ways of combining selections + */ typedef enum H5S_seloper_t { - H5S_SELECT_NOOP = -1, /* error */ - H5S_SELECT_SET = 0, /* Select "set" operation */ - H5S_SELECT_OR, /* Binary "or" operation for hyperslabs + H5S_SELECT_NOOP = -1, /**< Error */ + H5S_SELECT_SET = 0, /**< Select "set" operation */ + H5S_SELECT_OR, /**< Binary "or" operation for hyperslabs * (add new selection to existing selection) + * \code * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * A or B: CCCCCCCCCCCCCCCC + * \endcode */ - H5S_SELECT_AND, /* Binary "and" operation for hyperslabs + H5S_SELECT_AND, /**< Binary "and" operation for hyperslabs * (only leave overlapped regions in selection) + * \code * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * A and B: CCCC + * \endcode */ - H5S_SELECT_XOR, /* Binary "xor" operation for hyperslabs + H5S_SELECT_XOR, /**< Binary "xor" operation for hyperslabs * (only leave non-overlapped regions in selection) + * \code * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * A xor B: CCCCCC CCCCCC + * \endcode */ - H5S_SELECT_NOTB, /* Binary "not" operation for hyperslabs + H5S_SELECT_NOTB, /**< Binary "not" operation for hyperslabs * (only leave non-overlapped regions in original selection) + * \code * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * A not B: CCCCCC + * \endcode */ - H5S_SELECT_NOTA, /* Binary "not" operation for hyperslabs + H5S_SELECT_NOTA, /**< Binary "not" operation for hyperslabs * (only leave non-overlapped regions in new selection) + * \code * Original region: AAAAAAAAAA * New region: BBBBBBBBBB * B not A: CCCCCC + * \endcode */ - H5S_SELECT_APPEND, /* Append elements to end of point selection */ - H5S_SELECT_PREPEND, /* Prepend elements to beginning of point selection */ - H5S_SELECT_INVALID /* Invalid upper bound on selection operations */ + H5S_SELECT_APPEND, /**< Append elements to end of point selection */ + H5S_SELECT_PREPEND, /**< Prepend elements to beginning of point selection */ + H5S_SELECT_INVALID /**< Invalid upper bound on selection operations */ } H5S_seloper_t; -/* Enumerated type for the type of selection */ +/** + * Selection type + */ typedef enum { - H5S_SEL_ERROR = -1, /* Error */ - H5S_SEL_NONE = 0, /* Nothing selected */ - H5S_SEL_POINTS = 1, /* Points / elements selected */ - H5S_SEL_HYPERSLABS = 2, /* Hyperslab selected */ - H5S_SEL_ALL = 3, /* Entire extent selected */ - H5S_SEL_N /*THIS MUST BE LAST */ + H5S_SEL_ERROR = -1, /**< Error */ + H5S_SEL_NONE = 0, /**< Empty selection */ + H5S_SEL_POINTS = 1, /**< Set of points */ + H5S_SEL_HYPERSLABS = 2, /**< Hyperslab */ + H5S_SEL_ALL = 3, /**< Everything */ + H5S_SEL_N /**< Sentinel \internal THIS MUST BE LAST */ } H5S_sel_type; #ifdef __cplusplus @@ -1314,9 +1317,6 @@ H5_DLL herr_t H5Sset_extent_none(hid_t space_id); * \details H5Sset_extent_simple() sets or resets the size of an existing * dataspace. * - * \p rank is the dimensionality, or number of dimensions, of the - * dataspace. - * * \p dims is an array of size \p rank which contains the new size * of each dimension in the dataspace. \p max is an array of size * \p rank which contains the maximum size of each dimension in @@ -1325,10 +1325,6 @@ H5_DLL herr_t H5Sset_extent_none(hid_t space_id); * Any previous extent is removed from the dataspace, the dataspace * type is set to #H5S_SIMPLE, and the extent is set as specified. * - * Note that a dataset must be chunked if \p dims does not equal - * \p max. - * - * * \version 1.4.0 Fortran subroutine was introduced. * \since 1.0.0 * diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 86e9043b8f1..2a485f5e54b 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -304,7 +303,7 @@ H5S_select_release(H5S_t *ds) *------------------------------------------------------------------------- */ 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 +342,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 */ @@ -378,7 +377,7 @@ H5S_select_serialize(const H5S_t *space, uint8_t **p) hssize_t H5Sget_select_npoints(hid_t spaceid) { - H5S_t * space; /* Dataspace to modify selection of */ + H5S_t *space; /* Dataspace to modify selection of */ hssize_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) @@ -528,11 +527,12 @@ H5S_select_valid(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_deserialize(H5S_t **space, const uint8_t **p) +H5S_select_deserialize(H5S_t **space, const uint8_t **p, const size_t p_size) { - uint32_t sel_type; /* Pointer to the selection type */ - herr_t ret_value = FAIL; /* Return value */ - + uint32_t sel_type; /* Pointer to the selection type */ + herr_t ret_value = FAIL; /* Return value */ + const uint8_t *p_end = *p + p_size - 1; /* Pointer to last valid byte in buffer */ + hbool_t skip = (p_size == SIZE_MAX ? TRUE : FALSE); /* If p_size is unknown, skip buffer checks */ FUNC_ENTER_NOAPI(FAIL) HDassert(space); @@ -540,24 +540,26 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) /* Selection-type specific coding is moved to the callbacks. */ /* Decode selection type */ + if (H5_IS_KNOWN_BUFFER_OVERFLOW(skip, *p, sizeof(uint32_t), p_end)) + HGOTO_ERROR(H5E_DATASPACE, H5E_OVERFLOW, FAIL, "buffer overflow while decoding selection type") UINT32DECODE(*p, sel_type); /* Make routine for selection type */ switch (sel_type) { case H5S_SEL_POINTS: /* Sequence of points selected */ - ret_value = (*H5S_sel_point->deserialize)(space, p); + ret_value = (*H5S_sel_point->deserialize)(space, p, p_size - sizeof(uint32_t), skip); break; case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */ - ret_value = (*H5S_sel_hyper->deserialize)(space, p); + ret_value = (*H5S_sel_hyper->deserialize)(space, p, p_size - sizeof(uint32_t), skip); break; case H5S_SEL_ALL: /* Entire extent selected */ - ret_value = (*H5S_sel_all->deserialize)(space, p); + ret_value = (*H5S_sel_all->deserialize)(space, p, p_size - sizeof(uint32_t), skip); break; case H5S_SEL_NONE: /* Nothing selected */ - ret_value = (*H5S_sel_none->deserialize)(space, p); + ret_value = (*H5S_sel_none->deserialize)(space, p, p_size - sizeof(uint32_t), skip); break; default: @@ -880,7 +882,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 */ @@ -991,7 +993,7 @@ H5S_select_adjust_s(H5S_t *space, const hssize_t *offset) herr_t H5Sselect_adjust(hid_t space_id, const hssize_t *offset) { - H5S_t * space; + H5S_t *space; hsize_t low_bounds[H5S_MAX_RANK]; hsize_t high_bounds[H5S_MAX_RANK]; unsigned u; @@ -1116,7 +1118,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,13 +1499,12 @@ 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 */ - hsize_t * off = NULL; /* Array to store sequence offsets */ - size_t * len = NULL; /* Array to store sequence lengths */ + hsize_t *off = NULL; /* Array to store sequence offsets */ + size_t *len = NULL; /* Array to store sequence lengths */ hssize_t nelmts; /* Number of elements in selection */ hsize_t space_size[H5S_MAX_RANK]; /* Dataspace size */ size_t max_elem; /* Maximum number of elements allowed in sequences */ @@ -1663,7 +1664,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, const H5S_s H5S_sel_type H5Sget_select_type(hid_t space_id) { - H5S_t * space; /* dataspace to modify */ + H5S_t *space; /* dataspace to modify */ H5S_sel_type ret_value; /* Return value */ FUNC_ENTER_API(H5S_SEL_ERROR) @@ -1739,7 +1740,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 +1761,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 +2064,7 @@ H5Sselect_shape_same(hid_t space1_id, hid_t space2_id) 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 */ @@ -2124,7 +2125,7 @@ H5S_select_intersect_block(const H5S_t *space, const hsize_t *start, const hsize htri_t H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *end) { - H5S_t * space; /* Dataspace to query */ + H5S_t *space; /* Dataspace to query */ unsigned u; /* Local index value */ htri_t ret_value = FAIL; /* Return value */ @@ -2171,27 +2172,24 @@ H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *e Note that if m > n, it is possible that the starting point in the buffer associated with the memory dataspace will have to be - adjusted to match the projected dataspace. If the buf parameter - is not NULL, the function must return an adjusted buffer base - address in *adj_buf_ptr. + adjusted to match the projected dataspace. In this case, the amount + of adjustment to be applied to the buffer will be returned via the + buf_adj parameter, if supplied. USAGE htri_t H5S_select_construct_projection(base_space, new_space_ptr, new_space_rank, - buf, - adj_buf_ptr) + element_size, + buf_adj) const H5S_t *base_space; IN: Ptr to Dataspace to project H5S_t ** new_space_ptr; OUT: Ptr to location in which to return the address of the projected space int new_space_rank; IN: Rank of the projected space. - const void * buf; IN: Base address of the buffer - associated with the base space. - May be NULL. - void ** adj_buf_ptr; OUT: If buf != NULL, store the base - address of the section of buf - that is described by *new_space_ptr - in *adj_buf_ptr. + hsize_t element_size; IN: size of each element in the selection + ptrdiff_t buf_adj; OUT: amount of adjustment to be applied + to buffer associated with memory + dataspace RETURNS Non-negative on success/Negative on failure. @@ -2201,9 +2199,6 @@ H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *e projection of the supplied dataspace and associated selection into the specified rank. Return it in *new_space_ptr. - If buf is supplied, computes the base address of the projected - selection in buf, and stores the base address in *adj_buf_ptr. - GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS The selection in the supplied base_space has thickness 1 in all @@ -2214,10 +2209,10 @@ H5Sselect_intersect_block(hid_t space_id, const hsize_t *start, const hsize_t *e REVISION LOG --------------------------------------------------------------------------*/ 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) +H5S_select_construct_projection(H5S_t *base_space, H5S_t **new_space_ptr, unsigned new_space_rank, + hsize_t element_size, ptrdiff_t *buf_adj) { - H5S_t * new_space = NULL; /* New dataspace constructed */ + H5S_t *new_space = NULL; /* New dataspace constructed */ hsize_t base_space_dims[H5S_MAX_RANK]; /* Current dimensions of base dataspace */ hsize_t base_space_maxdims[H5S_MAX_RANK]; /* Maximum dimensions of base dataspace */ int sbase_space_rank; /* Signed # of dimensions of base dataspace */ @@ -2234,7 +2229,6 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, HDassert(new_space_ptr != NULL); HDassert((new_space_rank != 0) || (H5S_GET_SELECT_NPOINTS(base_space) <= 1)); HDassert(new_space_rank <= H5S_MAX_RANK); - HDassert((buf == NULL) || (adj_buf_ptr != NULL)); HDassert(element_size > 0); /* Get the extent info for the base dataspace */ @@ -2247,7 +2241,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, if (new_space_rank == 0) { hssize_t npoints; /* Number of points selected */ - /* Retreve the number of elements selected */ + /* Retrieve the number of elements selected */ if ((npoints = (hssize_t)H5S_GET_SELECT_NPOINTS(base_space)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get number of points selected") HDassert(npoints <= 1); @@ -2316,12 +2310,12 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * true on selections of different rank iff: * * 1) the selection in the lower rank dataspace matches that - * in the dimensions with the fastest changing indicies in + * in the dimensions with the fastest changing indices in * the larger rank dataspace, and * * 2) the selection has thickness 1 in all ranks that appear * only in the higher rank dataspace (i.e. those with - * more slowly changing indicies). + * more slowly changing indices). */ if (new_space_rank > base_space_rank) { hsize_t tmp_dim_size = 1; /* Temporary dimension value, for filling arrays */ @@ -2397,26 +2391,15 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, /* load the address of the new space into *new_space_ptr */ *new_space_ptr = new_space; - /* now adjust the buffer if required */ - if (buf != NULL) { + /* return the buffer adjustment amount if required */ + if (buf_adj != NULL) { if (new_space_rank < base_space_rank) { - /* a bit of pointer magic here: - * - * Since we can't do pointer arithmetic on void pointers, we first - * cast buf to a pointer to byte -- i.e. uint8_t. - * - * We then multiply the projected space element offset we - * calculated earlier by the supplied element size, add this - * value to the type cast buf pointer, cast the result back - * to a pointer to void, and assign the result to *adj_buf_ptr. - */ - *adj_buf_ptr = (const void *)(((const uint8_t *)buf) + - ((size_t)(projected_space_element_offset * element_size))); - } /* end if */ + *buf_adj = (ptrdiff_t)(projected_space_element_offset * element_size); + } else /* No adjustment necessary */ - *adj_buf_ptr = buf; - } /* end if */ + *buf_adj = 0; + } done: /* Cleanup on error */ @@ -2452,12 +2435,12 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, 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 */ - hsize_t * off = NULL; /* Array to store sequence offsets */ - size_t * len = NULL; /* Array to store sequence lengths */ + hsize_t *off = NULL; /* Array to store sequence offsets */ + size_t *len = NULL; /* Array to store sequence lengths */ hssize_t nelmts; /* Number of elements in selection */ size_t max_elem; /* Total number of elements in selection */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2495,7 +2478,7 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b /* Loop, while elements left in selection */ while (max_elem > 0) { size_t nseq; /* Number of sequences generated */ - size_t curr_seq; /* Current sequnce being worked on */ + size_t curr_seq; /* Current sequence being worked on */ size_t nelem; /* Number of elements used in sequences */ /* Get the sequences of bytes */ @@ -2568,12 +2551,11 @@ 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 */ + H5S_t *new_space = NULL; /* New dataspace constructed */ + H5S_t *tmp_src_intersect_space = NULL; /* Temporary SIS converted from points->hyperslabs */ H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */ hbool_t ss_iter_init = FALSE; /* Whether ss_iter has been initialized */ H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */ @@ -2974,7 +2956,7 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) hid_t H5Ssel_iter_create(hid_t space_id, size_t elmt_size, unsigned flags) { - H5S_t * space; /* Dataspace with selection to iterate over */ + H5S_t *space; /* Dataspace with selection to iterate over */ H5S_sel_iter_t *sel_iter; /* Selection iterator created */ hid_t ret_value; /* Return value */ @@ -3114,7 +3096,7 @@ herr_t H5Ssel_iter_reset(hid_t sel_iter_id, hid_t space_id) { H5S_sel_iter_t *sel_iter; - H5S_t * space; + H5S_t *space; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) diff --git a/src/H5Stest.c b/src/H5Stest.c index a85154922e4..acf28decd09 100644 --- a/src/H5Stest.c +++ b/src/H5Stest.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -185,12 +184,13 @@ H5S__check_spans_tail_ptr(const H5S_hyper_span_info_t *span_lst) if (NULL != cur_elem->down) if ((ret_value = H5S__check_spans_tail_ptr(cur_elem->down)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, - "the seletion has inconsistent tail pointers") + "the selection has inconsistent tail pointers") cur_elem = cur_elem->next; } /* end while */ if (actual_tail != span_lst->tail) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the selection has inconsistent tail pointers") done: FUNC_LEAVE_NOAPI(ret_value) @@ -231,7 +231,8 @@ H5S__check_points_tail_ptr(const H5S_pnt_list_t *pnt_lst) cur_elem = cur_elem->next; } /* end while */ if (actual_tail != pnt_lst->tail) - HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, "the seletion has inconsistent tail pointers") + HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, + "the selection has inconsistent tail pointers") done: FUNC_LEAVE_NOAPI(ret_value) @@ -314,7 +315,7 @@ H5S__check_internal_consistency(const H5S_t *space) if ((NULL != hslab) && (NULL != hslab->span_lst)) if (H5S__check_spans_tail_ptr(hslab->span_lst) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, - "the seletion has inconsistent tail pointers") + "the selection has inconsistent tail pointers") } /* end if */ else if (space->select.type->type == H5S_SEL_POINTS) { H5S_pnt_list_t *pnt_lst = space->select.sel_info.pnt_lst; @@ -322,7 +323,7 @@ H5S__check_internal_consistency(const H5S_t *space) if (NULL != pnt_lst) if (H5S__check_points_tail_ptr(pnt_lst) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_INCONSISTENTSTATE, FAIL, - "the seletion has inconsistent tail pointers") + "the selection has inconsistent tail pointers") } /* end else-if */ done: diff --git a/src/H5T.c b/src/H5T.c index c3ca03b48af..4c932f87598 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -350,9 +349,9 @@ static herr_t H5T__close_cb(H5T_t *dt); static H5T_path_t *H5T__path_find_real(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_func_t *conv); static hbool_t H5T__detect_vlen_ref(const H5T_t *dt); -static H5T_t * H5T__initiate_copy(const H5T_t *old_dt); -static H5T_t * H5T__copy_transient(H5T_t *old_dt); -static H5T_t * H5T__copy_all(H5T_t *old_dt); +static H5T_t *H5T__initiate_copy(const H5T_t *old_dt); +static H5T_t *H5T__copy_transient(H5T_t *old_dt); +static H5T_t *H5T__copy_all(H5T_t *old_dt); static herr_t H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo, hbool_t set_memory_type, H5T_copy_func_t copyfn); @@ -422,31 +421,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; @@ -482,21 +479,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; @@ -508,21 +503,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 @@ -590,7 +583,7 @@ static struct { H5T_path_t **path; /*sorted array of path pointers */ int nsoft; /*number of soft conversions defined */ size_t asoft; /*number of soft conversions allocated */ - H5T_soft_t * soft; /*unsorted array of soft conversions */ + H5T_soft_t *soft; /*unsorted array of soft conversions */ } H5T_g; /* Declare the free list for H5T_path_t's */ @@ -649,9 +642,9 @@ H5T_init(void) static herr_t H5T__init_inf(void) { - H5T_t * dst_p; /* Datatype type operate on */ + H5T_t *dst_p; /* Datatype type operate on */ H5T_atomic_t *dst; /* Datatype's atomic info */ - uint8_t * d; /* Pointer to value to set */ + uint8_t *d; /* Pointer to value to set */ size_t half_size; /* Half the type size */ size_t u; /* Local index value */ herr_t ret_value = SUCCEED; /* Return value */ @@ -758,42 +751,40 @@ DESCRIPTION herr_t H5T__init_package(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) */ @@ -841,10 +832,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 @@ -1114,7 +1103,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 |= @@ -1123,7 +1111,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 |= @@ -1506,7 +1493,7 @@ static int H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata) { H5T_t *dt = (H5T_t *)_dt; - int * n = (int *)_udata; + int *n = (int *)_udata; FUNC_ENTER_STATIC_NOERR @@ -1660,31 +1647,29 @@ H5T_top_term_package(void) 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_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; -#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_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; @@ -2079,7 +2064,7 @@ H5Tlock(hid_t type_id) H5T_class_t H5Tget_class(hid_t type_id) { - H5T_t * dt; /* Pointer to datatype */ + H5T_t *dt; /* Pointer to datatype */ H5T_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NO_CLASS) @@ -2709,8 +2694,8 @@ H5T__register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_con herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func) { - H5T_t * src; /*source data type descriptor */ - H5T_t * dst; /*destination data type desc */ + H5T_t *src; /*source data type descriptor */ + H5T_t *dst; /*destination data type desc */ H5T_conv_func_t conv_func; /* Conversion function wrapper */ herr_t ret_value = SUCCEED; /*return value */ @@ -2748,7 +2733,7 @@ H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_c * All arguments are optional. Missing arguments are wild cards. * The special no-op path cannot be removed. * - * Return: Succeess: non-negative + * Return: Success: non-negative * Failure: negative * * Programmer: Robb Matzke @@ -2852,7 +2837,7 @@ H5T__unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, H5T_c * All arguments are optional. Missing arguments are wild cards. * The special no-op path cannot be removed. * - * Return: Succeess: non-negative + * Return: Success: non-negative * * Failure: negative * @@ -2904,7 +2889,7 @@ H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) { - H5T_t * src, *dst; + H5T_t *src, *dst; H5T_path_t *path; H5T_conv_t ret_value; /* Return value */ @@ -2998,7 +2983,7 @@ herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t dxpl_id) { H5T_path_t *tpath; /* type conversion info */ - H5T_t * src, *dst; /* unatomized types */ + H5T_t *src, *dst; /* unatomized types */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -3530,8 +3515,8 @@ static herr_t H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo, hbool_t set_memory_type, H5T_copy_func_t copyfn) { - H5T_t * tmp = NULL; /* Temporary copy of compound field's datatype */ - char * s; /* Temporary copy of compound field name / enum value name */ + H5T_t *tmp = NULL; /* Temporary copy of compound field's datatype */ + char *s; /* Temporary copy of compound field name / enum value name */ unsigned i; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3726,9 +3711,9 @@ H5T__complete_copy(H5T_t *new_dt, const H5T_t *old_dt, H5T_shared_t *reopened_fo H5T_t * H5T_copy(const H5T_t *old_dt, H5T_copy_t method) { - H5T_t * new_dt = NULL; /* New datatype */ + H5T_t *new_dt = NULL; /* New datatype */ H5T_copy_func_t copyfn; /* Pointer to correct copy routine */ - H5T_t * ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -3802,9 +3787,9 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) H5T_t * H5T_copy_reopen(H5T_t *old_dt) { - H5T_t * new_dt = NULL; /* New datatype */ + H5T_t *new_dt = NULL; /* New datatype */ H5T_shared_t *reopened_fo = NULL; /* Pointer to reopened existing named datatype */ - H5T_t * ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -3870,7 +3855,7 @@ H5T_copy_reopen(H5T_t *old_dt) else /* Downgrade immutable datatypes to read-only */ if (H5T_STATE_IMMUTABLE == old_dt->shared->state) - new_dt->shared->state = H5T_STATE_RDONLY; + new_dt->shared->state = H5T_STATE_RDONLY; /* Finish making the copy of the datatype */ if (H5T__complete_copy(new_dt, old_dt, reopened_fo, TRUE, H5T_copy_reopen) < 0) @@ -4190,7 +4175,7 @@ H5T_close(H5T_t *dt) else /* Free object location (i.e. "unhold" the file if appropriate) */ if (H5O_loc_free(&(dt->oloc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "problem attempting to free location") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "problem attempting to free location") } /* end else */ } /* end if */ @@ -4221,7 +4206,7 @@ H5T_close(H5T_t *dt) * * Return: Success: non-negative * - * Failure: nagative + * Failure: negative * * Programmer: Robb Matzke * Tuesday, December 22, 1998 @@ -4315,7 +4300,7 @@ H5T__set_size(H5T_t *dt, size_t size) case H5T_STRING: /* Convert string to variable-length datatype */ if (size == H5T_VARIABLE) { - H5T_t * base = NULL; /* base data type */ + H5T_t *base = NULL; /* base data type */ H5T_cset_t tmp_cset; /* Temp. cset info */ H5T_str_t tmp_strpad; /* Temp. strpad info */ @@ -4954,7 +4939,7 @@ H5T_path_t * H5T_path_find(const H5T_t *src, const H5T_t *dst) { H5T_conv_func_t conv_func; /* Conversion function wrapper */ - H5T_path_t * ret_value = NULL; /* Return value */ + H5T_path_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -5528,7 +5513,7 @@ H5T_oloc(H5T_t *dt) *------------------------------------------------------------------------- */ H5G_name_t * -H5T_nameof(const H5T_t *dt) +H5T_nameof(H5T_t *dt) { H5G_name_t *ret_value = NULL; diff --git a/src/H5TS.c b/src/H5TS.c index 321a83d4af1..309fa2028d3 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -41,7 +40,7 @@ /* Local Typedefs */ /******************/ -/* Cancelability structure */ +/* Cancellability structure */ typedef struct H5TS_cancel_struct { int previous_state; unsigned int cancel_count; @@ -548,9 +547,9 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) * Creates a cancellation counter for a thread if it is the first time * the thread is entering the library. * - * if counter value is zero, then set cancelability type of the thread + * if counter value is zero, then set cancellability type of the thread * to PTHREAD_CANCEL_DISABLE as thread is entering the library and store - * the previous cancelability type into cancellation counter. + * the previous cancellability type into cancellation counter. * * Increase the counter value by 1. * @@ -613,8 +612,8 @@ H5TS_cancel_count_inc(void) * Returns: SUCCEED/FAIL * * Description: - * If counter value is one, then set cancelability type of the thread - * to the previous cancelability type stored in the cancellation counter. + * If counter value is one, then set cancellability type of the thread + * to the previous cancellability type stored in the cancellation counter. * (the thread is leaving the library). * * Decrement the counter value by 1. @@ -658,7 +657,7 @@ H5TS_cancel_count_dec(void) * H5TS_rec_entry_count, or NULL on failure. * * Description: - * Allocate and initalize an instance of H5TS_rec_entry_count. + * Allocate and initialize an instance of H5TS_rec_entry_count. * * Programmer: John Mainzer * August 28, 2020 @@ -824,7 +823,7 @@ H5TS_rw_lock_destroy(H5TS_rw_lock_t *rw_lock) } else { - /* We are commited to the destroy at this point. Set magic + /* We are committed to the destroy at this point. Set magic * to an invalid value, and call the appropriate pthread * destroy routines. Call them all, even if one fails along * the way. diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h index e324b381db2..2116fa1f2a7 100644 --- a/src/H5TSprivate.h +++ b/src/H5TSprivate.h @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -260,7 +259,7 @@ typedef struct H5TS_rw_lock_stats_t { * Structure H5TS_rw_lock_t * * A read / write lock, is a lock that allows either an arbitrary number - * of readers, or a single writer into a critical region. A recurssive + * of readers, or a single writer into a critical region. A recursive * lock is one that allows a thread that already has a lock (be it read or * write) to successfully request the lock again, only dropping the lock * when the number of un-lock calls equals the number of lock calls. @@ -285,7 +284,7 @@ typedef struct H5TS_rw_lock_stats_t { * If this structure is allocated dynamically, remember to set * it to some invalid value before discarding the structure. * - * policy Integer containing a code indicating the precidence policy + * policy Integer containing a code indicating the precedence policy * used by the R/W lock. The supported policies are listed * below: * @@ -362,13 +361,13 @@ typedef struct H5TS_rw_lock_t { * * Structure H5TS_rec_entry_count * - * Strucure associated with the reader_rec_entry_count_key defined in + * Structure associated with the reader_rec_entry_count_key defined in * H5TS_rw_lock_t. * * The primary purpose of this structure is to maintain a count of recursive * locks so that the lock can be dropped when the count drops to zero. * - * Aditional fields are included for purposes of sanity checking. + * Additional fields are included for purposes of sanity checking. * * Individual fields are discussed below. * diff --git a/src/H5Tarray.c b/src/H5Tarray.c index e2f3f01bce2..e042a41d71e 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -84,8 +83,8 @@ hid_t H5Tarray_create2(hid_t base_id, unsigned ndims, const hsize_t dim[/* ndims */]) { - H5T_t * base; /* base datatype */ - H5T_t * dt = NULL; /* new array datatype */ + H5T_t *base; /* base datatype */ + H5T_t *dt = NULL; /* new array datatype */ unsigned u; /* local index variable */ hid_t ret_value; /* return value */ @@ -140,7 +139,7 @@ H5T_t * H5T__array_create(H5T_t *base, unsigned ndims, const hsize_t dim[/* ndims */]) { unsigned u; /* Local index variable */ - H5T_t * ret_value = NULL; /* New array data type */ + H5T_t *ret_value = NULL; /* New array data type */ FUNC_ENTER_PACKAGE @@ -334,8 +333,8 @@ hid_t H5Tarray_create1(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], const int H5_ATTR_UNUSED perm[/* ndims */]) { - H5T_t * base; /* base datatype */ - H5T_t * dt = NULL; /* new array datatype */ + H5T_t *base; /* base datatype */ + H5T_t *dt = NULL; /* new array datatype */ unsigned u; /* local index variable */ hid_t ret_value; /* return value */ diff --git a/src/H5Tbit.c b/src/H5Tbit.c index 9f0c061b37d..c66314578c9 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -228,7 +227,7 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) * Purpose: Return a small bit sequence as a number. Bit vector starts * at OFFSET and is SIZE bits long. * - * Return: The bit sequence interpretted as an unsigned integer + * Return: The bit sequence interpreted as an unsigned integer * *------------------------------------------------------------------------- */ @@ -268,7 +267,6 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) /* Set return value */ ret_value = val; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__bit_get_d() */ @@ -373,7 +371,7 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) * Purpose: Finds the first bit with the specified VALUE within a region * of a bit vector. The region begins at OFFSET and continues * for SIZE bits, but the region can be searched from the least - * significat end toward the most significant end(H5T_BIT_LSB + * significant end toward the most significant end(H5T_BIT_LSB * as DIRECTION), or from the most significant end to the least * significant end(H5T_BIT_MSB as DIRECTION). * @@ -539,7 +537,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) /*------------------------------------------------------------------------- * Function: H5T__bit_dec * - * Purpose: Decrement part of a bit field by substracting 1. The bit + * Purpose: Decrement part of a bit field by subtracting 1. The bit * field starts with bit position START and is SIZE bits long. * * Return: The "borrow-in" value. It's TRUE if underflows, FALSE @@ -565,9 +563,9 @@ H5T__bit_dec(uint8_t *buf, size_t start, size_t size) if ((size + start - 1) / 8 > idx) { /* The bit sequence doesn't end in the same byte as starts */ - /* Example: a sequence like 11000100 and start = 3. We substract 00001000 from + /* Example: a sequence like 11000100 and start = 3. We subtract 00001000 from * it and get 10111100. If a sequence is 00000111, we do right shift for START - * bits and get 00000000. So we need to borrow from higher byte when we substract + * bits and get 00000000. So we need to borrow from higher byte when we subtract * 00001000. */ if (!(buf[idx] >> pos)) @@ -598,7 +596,7 @@ H5T__bit_dec(uint8_t *buf, size_t start, size_t size) else { /* The bit sequence ends in the same byte as starts */ - /* Example: a sequence like 11000100 and pos=3, size=3. We substract 00001000 + /* Example: a sequence like 11000100 and pos=3, size=3. We subtract 00001000 * and get 10111100. A bit is borrowed from 6th bit(buf[idx]>>6=00000010, tmp>>6=00000011, * not equal). We need to put this bit back by increment 1000000. */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 4ee070e427a..df83f0b9d2c 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -94,10 +93,10 @@ H5FL_EXTERN(H5VL_object_t); herr_t H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id) { - void * data = NULL; /* VOL-managed datatype data */ - H5VL_object_t * new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ - H5T_t * dt = NULL; /* High level datatype object that wraps the VOL object */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *data = NULL; /* VOL-managed datatype data */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -258,10 +257,10 @@ H5T__commit_named(const H5G_loc_t *loc, const char *name, H5T_t *dt, hid_t lcpl_ herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) { - void * dt = NULL; /* datatype object created by VOL connector */ - H5VL_object_t * new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ - H5T_t * type = NULL; /* Datatype created */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *dt = NULL; /* datatype object created by VOL connector */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t *type = NULL; /* Datatype created */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -556,8 +555,8 @@ H5T_link(const H5T_t *type, int adjust) hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) { - void * dt = NULL; /* datatype object created by VOL connector */ - H5VL_object_t * vol_obj = NULL; /* object of loc_id */ + void *dt = NULL; /* datatype object created by VOL connector */ + H5VL_object_t *vol_obj = NULL; /* object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -820,13 +819,13 @@ H5T__get_create_plist(const H5T_t *type) H5T_t * H5T__open_name(const H5G_loc_t *loc, const char *name) { - H5T_t * dt = NULL; /* Datatype opened in file */ + H5T_t *dt = NULL; /* Datatype opened in file */ H5G_name_t path; /* Datatype group hier. path */ H5O_loc_t oloc; /* Datatype object location */ H5G_loc_t type_loc; /* Group object for datatype */ H5O_type_t obj_type; /* Type of object at location */ hbool_t obj_found = FALSE; /* Object at 'name' found */ - H5T_t * ret_value = NULL; /* Return value */ + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -887,8 +886,8 @@ H5T_t * H5T_open(const H5G_loc_t *loc) { H5T_shared_t *shared_fo = NULL; - H5T_t * dt = NULL; - H5T_t * ret_value = NULL; /* Return value */ + H5T_t *dt = NULL; + H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1085,9 +1084,9 @@ H5T_t * H5T_construct_datatype(H5VL_object_t *vol_obj) { ssize_t nalloc; - void * buf = NULL; - H5T_t * dt = NULL; /* datatype object from VOL connector */ - H5T_t * ret_value = NULL; + void *buf = NULL; + H5T_t *dt = NULL; /* datatype object from VOL connector */ + H5T_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) @@ -1173,7 +1172,7 @@ H5T_get_actual_type(H5T_t *dt) /*------------------------------------------------------------------------- * Function: H5T_save_refresh_state * - * Purpose: Save state for datatype reconstuction after a refresh. + * Purpose: Save state for datatype reconstruction after a refresh. * * Return: SUCCEED/FAIL * @@ -1213,7 +1212,7 @@ H5T_save_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared) /*------------------------------------------------------------------------- * Function: H5T_restore_refresh_state * - * Purpose: Restore state for datatype reconstuction after a refresh. + * Purpose: Restore state for datatype reconstruction after a refresh. * * Return: SUCCEED/FAIL * diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index e6a0e4efda4..b5bc5177265 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -154,7 +153,7 @@ H5T_get_member_offset(const H5T_t *dt, unsigned membno) H5T_class_t H5Tget_member_class(hid_t type_id, unsigned membno) { - H5T_t * dt; /* Datatype to query */ + H5T_t *dt; /* Datatype to query */ H5T_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NO_CLASS) diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 0c986331c2c..f6ab0d7b183 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -712,11 +711,11 @@ { \ size_t elmtno; /*element number */ \ H5T_CONV_DECL_PREC(PREC) /*declare precision variables, or not */ \ - void * src_buf; /*'raw' source buffer */ \ - void * dst_buf; /*'raw' destination buffer */ \ - ST * src, *s; /*source buffer */ \ - DT * dst, *d; /*destination buffer */ \ - H5T_t * st, *dt; /*datatype descriptors */ \ + void *src_buf; /*'raw' source buffer */ \ + void *dst_buf; /*'raw' destination buffer */ \ + ST *src, *s; /*source buffer */ \ + DT *dst, *d; /*destination buffer */ \ + H5T_t *st, *dt; /*datatype descriptors */ \ ST src_aligned; /*source aligned type */ \ DT dst_aligned; /*destination aligned type */ \ hbool_t s_mv, d_mv; /*move data to align it? */ \ @@ -888,7 +887,17 @@ done: /* Macro defining action on source data which needs to be aligned (before main action) */ #define H5T_CONV_LOOP_PRE_SALIGN(ST) \ { \ - H5MM_memcpy(&src_aligned, src, sizeof(ST)); \ + /* The uint8_t * cast is required to avoid tripping over undefined behavior. \ + * \ + * The typed pointer arrives via a void pointer, which may have any alignment. \ + * We then cast it to a pointer to a type that is assumed to be aligned, which \ + * is undefined behavior (section 6.3.2.3 paragraph 7 of the C99 standard). \ + * In the past this hasn't caused many problems, but in some cases (e.g. \ + * converting long doubles on macOS), an optimizing compiler might do the \ + * wrong thing (in the macOS case, the conversion uses SSE, which has stricter \ + * requirements about alignment). \ + */ \ + H5MM_memcpy(&src_aligned, (const uint8_t *)src, sizeof(ST)); \ } /* Macro defining action on source data which doesn't need to be aligned (before main action) */ @@ -920,7 +929,17 @@ done: /* Macro defining action on destination data which needs to be aligned (after main action) */ #define H5T_CONV_LOOP_POST_DALIGN(DT) \ { \ - H5MM_memcpy(dst, &dst_aligned, sizeof(DT)); \ + /* The uint8_t * cast is required to avoid tripping over undefined behavior. \ + * \ + * The typed pointer arrives via a void pointer, which may have any alignment. \ + * We then cast it to a pointer to a type that is assumed to be aligned, which \ + * is undefined behavior (section 6.3.2.3 paragraph 7 of the C99 standard). \ + * In the past this hasn't caused many problems, but in some cases (e.g. \ + * converting long doubles on macOS), an optimizing compiler might do the \ + * wrong thing (in the macOS case, the conversion uses SSE, which has stricter \ + * requirements about alignment). \ + */ \ + H5MM_memcpy((uint8_t *)dst, &dst_aligned, sizeof(DT)); \ } /* Macro defining action on destination data which doesn't need to be aligned (after main action) */ @@ -1038,10 +1057,10 @@ done: /* Conversion data for H5T__conv_struct() */ typedef struct H5T_conv_struct_t { - int * src2dst; /*mapping from src to dst member num */ - hid_t * src_memb_id; /*source member type ID's */ - hid_t * dst_memb_id; /*destination member type ID's */ - H5T_path_t ** memb_path; /*conversion path for each member */ + int *src2dst; /*mapping from src to dst member num */ + hid_t *src_memb_id; /*source member type ID's */ + hid_t *dst_memb_id; /*destination member type ID's */ + H5T_path_t **memb_path; /*conversion path for each member */ H5T_subset_info_t subset_info; /*info related to compound subsets */ unsigned src_nmembs; /*needed by free function */ } H5T_conv_struct_t; @@ -1050,7 +1069,7 @@ typedef struct H5T_conv_struct_t { typedef struct H5T_enum_struct_t { int base; /*lowest `in' value */ unsigned length; /*num elements in arrays */ - int * src2dst; /*map from src to dst index */ + int *src2dst; /*map from src to dst index */ } H5T_enum_struct_t; /* Conversion data for the hardware conversion functions */ @@ -1157,8 +1176,8 @@ H5T__conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmt size_t H5_ATTR_UNUSED bkg_stride, void *_buf, void H5_ATTR_UNUSED *background) { uint8_t *buf = (uint8_t *)_buf; - H5T_t * src = NULL; - H5T_t * dst = NULL; + H5T_t *src = NULL; + H5T_t *dst = NULL; size_t i; herr_t ret_value = SUCCEED; /* Return value */ @@ -1566,8 +1585,8 @@ H5T__conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, s size_t H5_ATTR_UNUSED bkg_stride, void *_buf, void H5_ATTR_UNUSED *background) { uint8_t *buf = (uint8_t *)_buf; - H5T_t * src = NULL; - H5T_t * dst = NULL; + H5T_t *src = NULL; + H5T_t *dst = NULL; size_t i; size_t j, md; herr_t ret_value = SUCCEED; /* Return value */ @@ -1661,17 +1680,17 @@ herr_t H5T__conv_b_b(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 *background) { - uint8_t * buf = (uint8_t *)_buf; - H5T_t * src = NULL, *dst = NULL; /*source and dest datatypes */ + uint8_t *buf = (uint8_t *)_buf; + H5T_t *src = NULL, *dst = NULL; /*source and dest datatypes */ ssize_t direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t olap; /*num overlapping elements */ size_t half_size; /*1/2 of total size for swapping*/ - uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t dbuf[256] = {0}; /*temp destination buffer */ size_t msb_pad_offset; /*offset for dest MSB padding */ size_t i; - uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t *src_rev = NULL; /*order-reversed source buffer */ H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ H5T_conv_ret_t except_ret; /*return of callback function */ hbool_t reverse; /*if reverse the order of destination */ @@ -1908,8 +1927,8 @@ H5T__conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz static H5T_conv_struct_t * H5T__conv_struct_free(H5T_conv_struct_t *priv) { - int * src2dst = priv->src2dst; - hid_t * src_memb_id = priv->src_memb_id, *dst_memb_id = priv->dst_memb_id; + int *src2dst = priv->src2dst; + hid_t *src_memb_id = priv->src_memb_id, *dst_memb_id = priv->dst_memb_id; unsigned i; FUNC_ENTER_STATIC_NOERR @@ -1982,7 +2001,7 @@ static herr_t H5T__conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) { H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); - int * src2dst = NULL; + int *src2dst = NULL; unsigned src_nmembs, dst_nmembs; unsigned i, j; herr_t ret_value = SUCCEED; /* Return value */ @@ -2201,14 +2220,14 @@ herr_t H5T__conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg) { - uint8_t * buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ - uint8_t * bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ - uint8_t * xbuf = buf, *xbkg = bkg; /*temp pointers into buf and bkg*/ - H5T_t * src = NULL; /*source datatype */ - H5T_t * dst = NULL; /*destination datatype */ - int * src2dst = NULL; /*maps src member to dst member */ - H5T_cmemb_t * src_memb = NULL; /*source struct member descript.*/ - H5T_cmemb_t * dst_memb = NULL; /*destination struct memb desc. */ + uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ + uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ + uint8_t *xbuf = buf, *xbkg = bkg; /*temp pointers into buf and bkg*/ + H5T_t *src = NULL; /*source datatype */ + H5T_t *dst = NULL; /*destination datatype */ + int *src2dst = NULL; /*maps src member to dst member */ + H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ + H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ ssize_t src_delta; /*source stride */ ssize_t bkg_delta; /*background stride */ @@ -2428,15 +2447,15 @@ herr_t H5T__conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg) { - uint8_t * buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ - uint8_t * bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ - uint8_t * xbuf = NULL; /*temporary pointer into `buf' */ - uint8_t * xbkg = NULL; /*temporary pointer into `bkg' */ - H5T_t * src = NULL; /*source datatype */ - H5T_t * dst = NULL; /*destination datatype */ - int * src2dst = NULL; /*maps src member to dst member */ - H5T_cmemb_t * src_memb = NULL; /*source struct member descript.*/ - H5T_cmemb_t * dst_memb = NULL; /*destination struct memb desc. */ + uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ + uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ + uint8_t *xbuf = NULL; /*temporary pointer into `buf' */ + uint8_t *xbkg = NULL; /*temporary pointer into `bkg' */ + H5T_t *src = NULL; /*source datatype */ + H5T_t *dst = NULL; /*destination datatype */ + int *src2dst = NULL; /*maps src member to dst member */ + H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ + H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ size_t elmtno; /*element counter */ size_t copy_size; /*size of element for copying */ @@ -2675,7 +2694,7 @@ H5T__conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) H5T_enum_struct_t *priv = NULL; /*private conversion data */ int n; /*src value cast as native int */ int domain[2] = {0, 0}; /*min and max source values */ - int * map = NULL; /*map from src value to dst idx */ + int *map = NULL; /*map from src value to dst idx */ unsigned length; /*nelmts in map array */ unsigned i, j; /*counters */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2753,7 +2772,7 @@ H5T__conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) HDassert(domain[1] >= domain[0]); length = (unsigned)(domain[1] - domain[0]) + 1; if (src->shared->u.enumer.nmembs < 2 || - (double)length / src->shared->u.enumer.nmembs < (double)(1.2f)) { + (double)length / src->shared->u.enumer.nmembs < (double)(1.2F)) { priv->base = domain[0]; priv->length = length; if (NULL == (map = (int *)H5MM_malloc(length * sizeof(int)))) @@ -2815,9 +2834,9 @@ herr_t H5T__conv_enum(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) { - uint8_t * buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ - H5T_t * src = NULL, *dst = NULL; /*src and dst datatypes */ - uint8_t * s = NULL, *d = NULL; /*src and dst BUF pointers */ + uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ + H5T_t *src = NULL, *dst = NULL; /*src and dst datatypes */ + uint8_t *s = NULL, *d = NULL; /*src and dst BUF pointers */ ssize_t src_delta, dst_delta; /*conversion strides */ int n; /*src value cast as native int */ H5T_enum_struct_t *priv = (H5T_enum_struct_t *)(cdata->priv); @@ -3013,8 +3032,8 @@ H5T__conv_enum_numeric(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne size_t H5_ATTR_UNUSED buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *_buf, void H5_ATTR_UNUSED *bkg) { - H5T_t * src, *dst; /*src and dst datatypes */ - H5T_t * src_parent; /*parent type for src */ + H5T_t *src, *dst; /*src and dst datatypes */ + H5T_t *src_parent; /*parent type for src */ hid_t src_parent_id = -1; /*ID for parent of the source */ H5T_path_t *tpath; /* Conversion information */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3104,24 +3123,24 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si size_t bkg_stride, void *buf, void *bkg) { H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */ - H5T_path_t * tpath = NULL; /* Type conversion path */ + H5T_path_t *tpath = NULL; /* Type conversion path */ hbool_t noop_conv = FALSE; /* Flag to indicate a noop conversion */ hbool_t write_to_file = FALSE; /* Flag to indicate writing to file */ htri_t parent_is_vlen; /* Flag to indicate parent is vlen datatyp */ size_t bg_seq_len = 0; /* The number of elements in the background sequence */ hid_t tsrc_id = -1, tdst_id = -1; /*temporary type atoms */ - H5T_t * src = NULL; /*source datatype */ - H5T_t * dst = NULL; /*destination datatype */ - uint8_t * s = NULL; /*source buffer */ - uint8_t * d = NULL; /*destination buffer */ - uint8_t * b = NULL; /*background buffer */ + H5T_t *src = NULL; /*source datatype */ + H5T_t *dst = NULL; /*destination datatype */ + uint8_t *s = NULL; /*source buffer */ + uint8_t *d = NULL; /*destination buffer */ + uint8_t *b = NULL; /*background buffer */ ssize_t s_stride, d_stride; /*src and dst strides */ ssize_t b_stride; /*bkg stride */ size_t safe; /*how many elements are safe to process in each pass */ size_t src_base_size, dst_base_size; /*source & destination base size*/ - void * conv_buf = NULL; /*temporary conversion buffer */ + void *conv_buf = NULL; /*temporary conversion buffer */ size_t conv_buf_size = 0; /*size of conversion buffer in bytes */ - void * tmp_buf = NULL; /*temporary background buffer */ + void *tmp_buf = NULL; /*temporary background buffer */ size_t tmp_buf_size = 0; /*size of temporary bkg buffer */ hbool_t nested = FALSE; /*flag of nested VL case */ size_t elmtno; /*element number counter */ @@ -3406,8 +3425,8 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, si /* For nested VL case, free leftover heap objects from the deeper level if the * length of new data elements is shorter than the old data elements.*/ if (nested && seq_len < bg_seq_len) { - const uint8_t *tmp; - size_t u; + uint8_t *tmp; + size_t u; /* Sanity check */ HDassert(write_to_file); @@ -3477,14 +3496,14 @@ H5T__conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, s { H5T_path_t *tpath; /* Type conversion path */ hid_t tsrc_id = -1, tdst_id = -1; /*temporary type atoms */ - H5T_t * src = NULL; /*source datatype */ - H5T_t * dst = NULL; /*destination datatype */ - uint8_t * sp, *dp; /*source and dest traversal ptrs */ + H5T_t *src = NULL; /*source datatype */ + H5T_t *dst = NULL; /*destination datatype */ + uint8_t *sp, *dp; /*source and dest traversal ptrs */ ssize_t src_delta, dst_delta; /*source & destination stride */ int direction; /*direction of traversal */ size_t elmtno; /*element number counter */ unsigned u; /* local index variable */ - void * bkg_buf = NULL; /*temporary background buffer */ + void *bkg_buf = NULL; /*temporary background buffer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3625,15 +3644,15 @@ herr_t H5T__conv_ref(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg) { - H5T_t * src = NULL; /* source datatype */ - H5T_t * dst = NULL; /* destination datatype */ + H5T_t *src = NULL; /* source datatype */ + H5T_t *dst = NULL; /* destination datatype */ uint8_t *s = NULL; /* source buffer */ uint8_t *d = NULL; /* destination buffer */ uint8_t *b = NULL; /* background buffer */ ssize_t s_stride, d_stride; /* src and dst strides */ ssize_t b_stride; /* bkg stride */ size_t safe; /* how many elements are safe to process in each pass */ - void * conv_buf = NULL; /* temporary conversion buffer */ + void *conv_buf = NULL; /* temporary conversion buffer */ size_t conv_buf_size = 0; /* size of conversion buffer in bytes */ size_t elmtno; /* element number counter */ herr_t ret_value = SUCCEED; /* return value */ @@ -3835,15 +3854,15 @@ herr_t H5T__conv_i_i(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_t * src = NULL; /*source datatype */ - H5T_t * dst = NULL; /*destination datatype */ + H5T_t *src = NULL; /*source datatype */ + H5T_t *dst = NULL; /*destination datatype */ ssize_t src_delta, dst_delta; /*source & destination stride */ int direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t half_size; /*half the type size */ size_t olap; /*num overlapping elements */ - uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t *src_rev = NULL; /*order-reversed source buffer */ uint8_t dbuf[64] = {0}; /*temp destination buffer */ size_t first; ssize_t sfirst; /*a signed version of `first' */ @@ -4274,8 +4293,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { /* Traversal-related variables */ - H5T_t * src_p; /*source datatype */ - H5T_t * dst_p; /*destination datatype */ + H5T_t *src_p; /*source datatype */ + H5T_t *dst_p; /*destination datatype */ H5T_atomic_t src; /*atomic source info */ H5T_atomic_t dst; /*atomic destination info */ ssize_t src_delta, dst_delta; /*source & destination stride */ @@ -4285,8 +4304,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz size_t tsize; /*type size for swapping bytes */ size_t olap; /*num overlapping elements */ ssize_t bitno = 0; /*bit number */ - uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t *src_rev = NULL; /*order-reversed source buffer */ uint8_t dbuf[64] = {0}; /*temp destination buffer */ uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ @@ -4859,15 +4878,15 @@ herr_t H5T__conv_s_s(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_t * src = NULL; /*source datatype */ - H5T_t * dst = NULL; /*destination datatype */ + H5T_t *src = NULL; /*source datatype */ + H5T_t *dst = NULL; /*destination datatype */ ssize_t src_delta, dst_delta; /*source & destination stride */ int direction; /*direction of traversal */ size_t elmtno; /*element number */ size_t olap; /*num overlapping elements */ size_t nchars = 0; /*number of characters copied */ uint8_t *s, *sp, *d, *dp; /*src and dst traversal pointers*/ - uint8_t *dbuf = NULL; /*temp buf for overlap convers. */ + uint8_t *dbuf = NULL; /*temp buf for overlap converts. */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -5077,7 +5096,7 @@ H5T__conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz break; default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown converson command") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command") } /* end switch */ done: @@ -7009,14 +7028,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 +7068,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 +7088,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 +7108,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 @@ -7153,7 +7164,7 @@ H5T__conv_schar_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7213,7 +7224,7 @@ H5T__conv_uchar_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7273,7 +7284,7 @@ H5T__conv_short_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7333,7 +7344,7 @@ H5T__conv_ushort_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t n * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7393,7 +7404,7 @@ H5T__conv_int_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelm * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7453,7 +7464,7 @@ H5T__conv_uint_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nel * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7513,7 +7524,7 @@ H5T__conv_long_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nel * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7573,7 +7584,7 @@ H5T__conv_ulong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7633,7 +7644,7 @@ H5T__conv_llong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7695,7 +7706,7 @@ H5T__conv_ullong_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t n * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7805,7 +7816,7 @@ H5T__conv_double_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7827,7 +7838,7 @@ H5T__conv_ldouble_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t n * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7937,7 +7948,7 @@ H5T__conv_double_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t n * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -7959,7 +7970,7 @@ H5T__conv_ldouble_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t n * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -8069,7 +8080,7 @@ H5T__conv_double_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nel * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -8091,7 +8102,7 @@ H5T__conv_ldouble_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nel * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -8201,7 +8212,7 @@ H5T__conv_double_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -8223,7 +8234,7 @@ H5T__conv_ldouble_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t ne * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -8333,7 +8344,7 @@ H5T__conv_double_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t n * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -8357,7 +8368,7 @@ H5T__conv_ldouble_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t n * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu - * Tuesday, Febuary 1, 2005 + * Tuesday, February 1, 2005 * *------------------------------------------------------------------------- */ @@ -8391,8 +8402,8 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { /* Traversal-related variables */ - H5T_t * src_p; /*source datatype */ - H5T_t * dst_p; /*destination datatype */ + H5T_t *src_p; /*source datatype */ + H5T_t *dst_p; /*destination datatype */ H5T_atomic_t src; /*atomic source info */ H5T_atomic_t dst; /*atomic destination info */ int direction; /*forward or backward traversal */ @@ -8400,15 +8411,15 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz size_t half_size; /*half the type size */ size_t tsize; /*type size for swapping bytes */ size_t olap; /*num overlapping elements */ - uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t *src_rev = NULL; /*order-reversed source buffer */ uint8_t dbuf[64] = {0}; /*temp destination buffer */ uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ /* Conversion-related variables */ hssize_t expo; /*source exponent */ hssize_t sign; /*source sign bit value */ - uint8_t * int_buf = NULL; /*buffer for temporary value */ + uint8_t *int_buf = NULL; /*buffer for temporary value */ size_t buf_size; /*buffer size for temporary value */ size_t i; /*miscellaneous counters */ size_t first; /*first bit(MSB) in an integer */ @@ -9017,8 +9028,8 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) { /* Traversal-related variables */ - H5T_t * src_p; /*source datatype */ - H5T_t * dst_p; /*destination datatype */ + H5T_t *src_p; /*source datatype */ + H5T_t *dst_p; /*destination datatype */ H5T_atomic_t src; /*atomic source info */ H5T_atomic_t dst; /*atomic destination info */ int direction; /*forward or backward traversal */ @@ -9026,8 +9037,8 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz size_t half_size; /*half the type size */ size_t tsize; /*type size for swapping bytes */ size_t olap; /*num overlapping elements */ - uint8_t * s, *sp, *d, *dp; /*source and dest traversal ptrs*/ - uint8_t * src_rev = NULL; /*order-reversed source buffer */ + uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ + uint8_t *src_rev = NULL; /*order-reversed source buffer */ uint8_t dbuf[64] = {0}; /*temp destination buffer */ uint8_t tmp1, tmp2; /*temp variables for swapping bytes*/ @@ -9037,7 +9048,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz size_t sign; /*source sign bit value */ hbool_t is_max_neg; /*source is maximal negative value*/ hbool_t do_round; /*whether there is roundup */ - uint8_t * int_buf = NULL; /*buffer for temporary value */ + uint8_t *int_buf = NULL; /*buffer for temporary value */ size_t buf_size; /*buffer size for temporary value */ size_t i; /*miscellaneous counters */ size_t first; /*first bit(MSB) in an integer */ @@ -9482,7 +9493,7 @@ H5T__reverse_order(uint8_t *rev, uint8_t *s, size_t size, H5T_order_t order) herr_t H5T_reclaim(hid_t type_id, H5S_t *space, void *buf) { - H5T_t * type; /* Datatype */ + H5T_t *type; /* Datatype */ H5S_sel_iter_op_t dset_op; /* Operator for iteration */ H5T_vlen_alloc_info_t vl_alloc_info; /* VL allocation info */ herr_t ret_value = FAIL; /* Return value */ diff --git a/src/H5Tcset.c b/src/H5Tcset.c index dd145c97e88..b1948d67b10 100644 --- a/src/H5Tcset.c +++ b/src/H5Tcset.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -42,7 +41,7 @@ H5T_cset_t H5Tget_cset(hid_t type_id) { - H5T_t * dt; + H5T_t *dt; H5T_cset_t ret_value; FUNC_ENTER_API(H5T_CSET_ERROR) diff --git a/src/H5Tdbg.c b/src/H5Tdbg.c index 613aa603a8d..181b40ee6b6 100644 --- a/src/H5Tdbg.c +++ b/src/H5Tdbg.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 116d34cfce6..d9e98a31392 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -98,10 +97,10 @@ H5FL_EXTERN(H5VL_object_t); herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) { - void * data = NULL; /* VOL-managed datatype data */ - H5VL_object_t * new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ - H5T_t * dt = NULL; /* High level datatype object that wraps the VOL object */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + void *data = NULL; /* VOL-managed datatype data */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -163,8 +162,8 @@ H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) hid_t H5Topen1(hid_t loc_id, const char *name) { - void * dt = NULL; /* Datatype object created by VOL connector */ - H5VL_object_t * vol_obj = NULL; /* Object of loc_id */ + void *dt = NULL; /* Datatype object created by VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ diff --git a/src/H5Tenum.c b/src/H5Tenum.c index 2843ac579fd..c1602794f47 100644 --- a/src/H5Tenum.c +++ b/src/H5Tenum.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -25,7 +24,7 @@ #include "H5Tpkg.h" /*data-type functions */ /* Static local functions */ -static char * H5T__enum_nameof(const H5T_t *dt, const void *value, char *name /*out*/, size_t size); +static char *H5T__enum_nameof(const H5T_t *dt, const void *value, char *name /*out*/, size_t size); static herr_t H5T__enum_valueof(const H5T_t *dt, const char *name, void *value /*out*/); /*------------------------------------------------------------------------- @@ -193,7 +192,7 @@ H5T__enum_insert(const H5T_t *dt, const char *name, const void *value) /* Increase table sizes */ if (dt->shared->u.enumer.nmembs >= dt->shared->u.enumer.nalloc) { - char ** names; + char **names; uint8_t *values; unsigned n = MAX(32, 2 * dt->shared->u.enumer.nalloc); @@ -357,11 +356,11 @@ H5Tenum_nameof(hid_t type, const void *value, char *name /*out*/, size_t size) static char * H5T__enum_nameof(const H5T_t *dt, const void *value, char *name /*out*/, size_t size) { - H5T_t * copied_dt = NULL; /* Do sorting in copied datatype */ + H5T_t *copied_dt = NULL; /* Do sorting in copied datatype */ unsigned lt, md = 0, rt; /* Indices for binary search */ int cmp = (-1); /* Comparison result */ hbool_t alloc_name = FALSE; /* Whether name has been allocated */ - char * ret_value = NULL; /* Return value */ + char *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -490,7 +489,7 @@ H5T__enum_valueof(const H5T_t *dt, const char *name, void *value /*out*/) { unsigned lt, md = 0, rt; /*indices for binary search */ int cmp = (-1); /*comparison result */ - H5T_t * copied_dt = NULL; /*do sorting in copied datatype */ + H5T_t *copied_dt = NULL; /*do sorting in copied datatype */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Tfields.c b/src/H5Tfields.c index baeae6d446a..9317ab9cb55 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -12,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Module Info: This module contains commond functionality for fields in + * Module Info: This module contains command functionality for fields in * enumerated & compound datatypes in the H5T interface. */ @@ -121,7 +120,7 @@ char * H5Tget_member_name(hid_t type_id, unsigned membno) { H5T_t *dt = NULL; - char * ret_value; + char *ret_value; FUNC_ENTER_API(NULL) H5TRACE2("*s", "iIu", type_id, membno); @@ -215,7 +214,7 @@ H5T__get_member_name(H5T_t const *dt, unsigned membno) int H5Tget_member_index(hid_t type_id, const char *name) { - H5T_t * dt = NULL; + H5T_t *dt = NULL; int ret_value = FAIL; unsigned i; diff --git a/src/H5Tfixed.c b/src/H5Tfixed.c index 9527a5ad206..9bf7da340de 100644 --- a/src/H5Tfixed.c +++ b/src/H5Tfixed.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -40,7 +39,7 @@ H5T_sign_t H5Tget_sign(hid_t type_id) { - H5T_t * dt = NULL; + H5T_t *dt = NULL; H5T_sign_t ret_value; FUNC_ENTER_API(H5T_SGN_ERROR) diff --git a/src/H5Tfloat.c b/src/H5Tfloat.c index b3fa724e5f1..a90b257de23 100644 --- a/src/H5Tfloat.c +++ b/src/H5Tfloat.c @@ -1,6 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 * @@ -233,7 +232,7 @@ H5Tset_ebias(hid_t type_id, size_t ebias) H5T_norm_t H5Tget_norm(hid_t type_id) { - H5T_t * dt; /* Datatype */ + H5T_t *dt; /* Datatype */ H5T_norm_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_NORM_ERROR) @@ -315,7 +314,7 @@ H5Tset_norm(hid_t type_id, H5T_norm_t norm) H5T_pad_t H5Tget_inpad(hid_t type_id) { - H5T_t * dt; /* Datatype */ + H5T_t *dt; /* Datatype */ H5T_pad_t ret_value; /* Return value */ FUNC_ENTER_API(H5T_PAD_ERROR) diff --git a/src/H5Tmodule.h b/src/H5Tmodule.h index c489edc56c3..590a60c1684 100644 --- a/src/H5Tmodule.h +++ b/src/H5Tmodule.h @@ -29,55 +29,3899 @@ #define H5_MY_PKG_ERR H5E_DATATYPE #define H5_MY_PKG_INIT YES +/** \page H5T_UG HDF5 Datatypes + * + * \section sec_datatype HDF5 Datatypes + * HDF5 datatypes describe the element type of HDF5 datasets and attributes. + * There's a large set of predefined datatypes, but users may find it useful + * to define new datatypes through a process called \Emph{derivation}. + * + * The element type is automatically persisted as part of the HDF5 metadata of + * attributes and datasets. Additionally, datatype definitions can be persisted + * to HDF5 files and linked to groups as HDF5 datatype objects or so-called + * \Emph{committed datatypes}. + * + * \subsection subsec_datatype_intro Introduction and Definitions + * + * An HDF5 dataset is an array of data elements, arranged according to the specifications + * of the dataspace. In general, a data element is the smallest addressable unit of storage + * in the HDF5 file. (Compound datatypes are the exception to this rule.) The HDF5 datatype + * defines the storage format for a single data element. See the figure below. + * + * The model for HDF5 attributes is extremely similar to datasets: an attribute has a dataspace + * and a data type, as shown in the figure below. The information in this chapter applies to both + * datasets and attributes. + * + * + * + * + * + *
    + * \image html Dtypes_fig1.gif "Datatypes, dataspaces, and datasets" + *
    + * + * Abstractly, each data element within the dataset is a sequence of bits, interpreted as a single + * value from a set of values (for example, a number or a character). For a given datatype, there is a + * standard or convention for representing the values as bits, and when the bits are represented in a + * particular storage the bits are laid out in a specific storage scheme such as 8-bit bytes with a + * specific ordering and alignment of bytes within the storage array. + * + * HDF5 datatypes implement a flexible, extensible, and portable mechanism for specifying and + * discovering the storage layout of the data elements, determining how to interpret the elements + * (for example, as floating point numbers), and for transferring data from different compatible + * layouts. + * + * An HDF5 datatype describes one specific layout of bits. A dataset has a single datatype which + * applies to every data element. When a dataset is created, the storage datatype is defined. After + * the dataset or attribute is created, the datatype cannot be changed. + * \li The datatype describes the storage layout of a singledata element + * \li All elements of the dataset must have the same type + * \li The datatype of a dataset is immutable + * + * When data is transferred (for example, a read or write), each end point of the transfer has a + * datatype, which describes the correct storage for the elements. The source and destination may + * have different (but compatible) layouts, in which case the data elements are automatically + * transformed during the transfer. + * + * HDF5 datatypes describe commonly used binary formats for numbers (integers + * and floating point) and characters (ASCII). A given computing architecture and programming language + * supports certain number and character representations. For example, a computer may support 8-, + * 16-, 32-, and 64-bit signed integers, stored in memory in little-endian byte order. These would + * presumably correspond to the C programming language types \Emph{char}, \Emph{short}, + * \Emph{int}, and \Emph{long}. + * + * When reading and writing from memory, the HDF5 library must know the appropriate datatype + * that describes the architecture specific layout. The HDF5 library provides the platform + * independent \Emph{NATIVE} types, which are mapped to an appropriate datatype for each platform. + * So the type #H5T_NATIVE_INT is an alias for the appropriate descriptor for each platform. + * + * Data in memory has a datatype: + * \li The storage layout in memory is architecture-specific + * \li The HDF5 \Emph{NATIVE} types are predefined aliases for the architecture-specific memory layout + * \li The memory datatype need not be the same as the stored datatype of the dataset + * + * In addition to numbers and characters, an HDF5 datatype can describe more abstract classes of + * types including enumerations, strings, bit strings, and references (pointers to objects in the HDF5 + * file). HDF5 supports several classes of composite datatypes which are combinations of one or + * more other datatypes. In addition to the standard predefined datatypes, users can define new + * datatypes within the datatype classes. + * + * The HDF5 datatype model is very general and flexible: + * \li For common simple purposes, only predefined types will be needed + * \li Datatypes can be combined to create complex structured datatypes + * \li If needed, users can define custom atomic datatypes + * \li Committed datatypes can be shared by datasets or attributes + * + * \subsection subsec_datatype_model Datatype Model + * The HDF5 library implements an object-oriented model of datatypes. HDF5 datatypes are + * organized as a logical set of base types, or datatype classes. Each datatype class defines + * a format for representing logical values as a sequence of bits. For example the #H5T_INTEGER + * class is a format for representing twos complement integers of various sizes. + * + * A datatype class is defined as a set of one or more datatype properties. A datatype property is + * a property of the bit string. The datatype properties are defined by the logical model of the + * datatype class. For example, the integer class (twos complement integers) has properties such as + * “signed or unsignedâ€, “lengthâ€, and “byte-orderâ€. The float class (IEEE floating point numbers) + * has these properties, plus “exponent bitsâ€, “exponent signâ€, etc. + * + * A datatype is derived from one datatype class: a given datatype has a specific value for the + * datatype properties defined by the class. For example, for 32-bit signed integers, stored + * big-endian, the HDF5 datatype is a sub-type of integer with the properties set to + * signed=1, size=4(bytes), and byte-order=BE. + * + * The HDF5 datatype API (H5T functions) provides methods to create datatypes of different + * datatype classes, to set the datatype properties of a new datatype, and to discover the datatype + * properties of an existing datatype. + * + * The datatype for a dataset is stored in the HDF5 file as part of the metadata for the dataset. + * A datatype can be shared by more than one dataset in the file if the datatype is saved to the + * file with a name. This shareable datatype is known as a committed datatype. In the past, + * this kind of datatype was called a named datatype. + * + * When transferring data (for example, a read or write), the data elements of the source and + * destination storage must have compatible types. As a general rule, data elements with the same + * datatype class are compatible while elements from different datatype classes are not compatible. + * When transferring data of one datatype to another compatible datatype, the HDF5 Library uses + * the datatype properties of the source and destination to automatically transform each data + * element. For example, when reading from data stored as 32-bit signed integers, big + * endian into 32-bit signed integers, little-endian, the HDF5 Library will automatically swap the + * bytes. + * + * Thus, data transfer operations (\ref H5Dread, \ref H5Dwrite, \ref H5Aread, \ref H5Awrite) require + * a datatype for both the source and the destination. + * + * + * + * + * + *
    + * \image html Dtypes_fig2.gif "The datatype model" + *
    + * + * The HDF5 library defines a set of predefined datatypes, corresponding to commonly used + * storage formats, such as twos complement integers, IEEE Floating point numbers, etc., 4- + * and 8-byte sizes, big-endian and little-endian byte orders. In addition, a user can derive types with + * custom values for the properties. For example, a user program may create a datatype to describe + * a 6-bit integer, or a 600-bit floating point number. + * + * In addition to atomic datatypes, the HDF5 library supports composite datatypes. A composite + * datatype is an aggregation of one or more datatypes. Each class of composite datatypes has + * properties that describe the organization of the composite datatype. See the figure below. + * Composite datatypes include: + * \li Compound datatypes: structured records + * \li Array: a multidimensional array of a datatype + * \li Variable-length: a one-dimensional array of a datatype + * + * + * + * + * + *
    + * \image html Dtypes_fig3.gif "Composite datatypes" + *
    + * + * \subsubsection subsubsec_datatype_model_class Datatype Classes and Properties + * The figure below shows the HDF5 datatype classes. Each class is defined to have a set of + * properties which describe the layout of the data element and the interpretation of the bits. The + * table below lists the properties for the datatype classes. + * + * + * + * + * + *
    + * \image html Dtypes_fig4.gif "Datatype classes" + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Datatype classes and their properties
    + * Class + * + * Description + * + * Properties + * + * Notes + *
    + * Integer + * + * Twos complement integers + * + * Size (bytes), precision (bits), offset (bits), pad, byte order, signed/unsigned + * + *
    + * Float + * + * Floating Point numbers + * + * Size (bytes), precision (bits), offset (bits), pad, byte order, sign position, + * exponent position, exponent size (bits), exponent sign, exponent bias, mantissa position, + * mantissa (size) bits, mantissa sign, mantissa normalization, internal padding + * + * See IEEE 754 for a definition of these properties. These properties describe + * non-IEEE 754 floating point formats as well. + *
    + * Character + * + * Array of 1-byte character encoding + * + * Size (characters), Character set, byte order, pad/no pad, pad character + * + * Currently, ASCII and UTF-8 are supported. + *
    + * Bitfield + * + * String of bits + * + * Size (bytes), precision (bits), offset (bits), pad, byte order + * + * A sequence of bit values packed into one or more bytes. + *
    + * Opaque + * + * Uninterpreted data + * + * Size (bytes), precision (bits), offset (bits), pad, byte order, tag + * + * A sequence of bytes, stored and retrieved as a block. + * The ‘tag’ is a string that can be used to label the value. + *
    + * Enumeration + * + * A list of discrete values, with symbolic names in the form of strings. + * + * Number of elements, element names, element values + * + * Enumeration is a list of pairs (name, value). The name is a string; the + * value is an unsigned integer. + *
    + * Reference + * + * Reference to object or region within the HDF5 file + * + * + * + * @see H5R + *
    + * Array + * + * Array (1-4 dimensions) of data elements + * + * Number of dimensions, dimension sizes, base datatype + * + * The array is accessed atomically: no selection or sub-setting. + *
    + * Variable-length + * + * A variable-length 1-dimensional array of data elements + * + * Current size, base type + * + * + *
    + * Compound + * + * A Datatype of a sequence of Datatypes + * + * Number of members, member names, member types, member offset, member class, + * member size, byte order + * + * + *
    + * + * \subsubsection subsubsec_datatype_model_predefine Predefined Datatypes + * The HDF5 library predefines a modest number of commonly used datatypes. These types have + * standard symbolic names of the form H5T_arch_base where arch is an architecture name and + * base is a programming type name Table 2. New types can be derived from the predefined + * types by copying the predefined type \ref H5Tcopy() and then modifying the result. + * + * The base name of most types consists of a letter to indicate the class Table 3, a precision in + * bits, and an indication of the byte order Table 4. + * + * Table 5 shows examples of predefined datatypes. The full list can be found in the + * \ref PDT section of the \ref RM. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 2. Architectures used in predefined datatypes
    + * Architecture Name + * + * Description + *
    + * IEEE + * + * IEEE-754 standard floating point types in various byte orders. + *
    + * STD + * + * This is an architecture that contains semi-standard datatypes like signed + * two’s complement integers, unsigned integers, and bitfields in various + * byte orders. + *
    + * C
    FORTRAN + *
    + * Types which are specific to the C or Fortran programming languages + * are defined in these architectures. For instance, #H5T_C_S1 defines a + * base string type with null termination which can be used to derive string + * types of other lengths. + *
    + * NATIVE + * + * This architecture contains C-like datatypes for the machine on which + * the library was compiled. The types were actually defined by running + * the H5detect program when the library was compiled. In order to be + * portable, applications should almost always use this architecture + * to describe things in memory. + *
    + * CRAY + * + * Cray architectures. These are word-addressable, big-endian systems + * with non-IEEE floating point. + *
    + * INTEL + * + * All Intel and compatible CPU’s. + * These are little-endian systems with IEEE floating-point. + *
    + * MIPS + * + * All MIPS CPU’s commonly used in SGI systems. These are big-endian + * systems with IEEE floating-point. + *
    + * ALPHA + * + * All DEC Alpha CPU’s, little-endian systems with IEEE floating-point. + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 3. Base types
    + * Base + * + * Description + *
    + * B + * + * Bitfield + *
    + * F + * + * Floating point + *
    + * I + * + * Signed integer + *
    + * R + * + * References + *
    + * S + * + * Character string + *
    + * U + * + * Unsigned integer + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 4. Byte order
    + * Order + * + * Description + *
    + * BE + * + * Big-endian + *
    + * LE + * + * Little-endian + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 5. Some predefined datatypes
    + * Example + * + * Description + *
    + * #H5T_IEEE_F64LE + * + * Eight-byte, little-endian, IEEE floating-point + *
    + * #H5T_IEEE_F32BE + * + * Four-byte, big-endian, IEEE floating point + *
    + * #H5T_STD_I32LE + * + * Four-byte, little-endian, signed two’s complement integer + *
    + * #H5T_STD_U16BE + * + * Two-byte, big-endian, unsigned integer + *
    + * #H5T_C_S1 + * + * One-byte,null-terminated string of eight-bit characters + *
    + * #H5T_INTEL_B64 + * + * Eight-byte bit field on an Intel CPU + *
    + * #H5T_STD_REF_OBJ + * + * Reference to an entire object in a file + *
    + * + * The HDF5 library predefines a set of \Emph{NATIVE} datatypes which are similar to C type names. + * The native types are set to be an alias for the appropriate HDF5 datatype for each platform. For + * example, #H5T_NATIVE_INT corresponds to a C int type. On an Intel based PC, this type is the same as + * #H5T_STD_I32LE, while on a MIPS system this would be equivalent to #H5T_STD_I32BE. Table 6 shows + * examples of \Emph{NATIVE} types and corresponding C types for a common 32-bit workstation. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 6. Native and 32-bit C datatypes
    + * Example + * + * Corresponding C Type + *
    + * #H5T_NATIVE_CHAR + * + * char + *
    + * #H5T_NATIVE_SCHAR + * + * signed char + *
    + * #H5T_NATIVE_UCHAR + * + * unsigned char + *
    + * #H5T_NATIVE_SHORT + * + * short + *
    + * #H5T_NATIVE_USHORT + * + * unsigned short + *
    + * #H5T_NATIVE_INT + * + * int + *
    + * #H5T_NATIVE_UINT + * + * unsigned + *
    + * #H5T_NATIVE_LONG + * + * long + *
    + * #H5T_NATIVE_ULONG + * + * unsigned long + *
    + * #H5T_NATIVE_LLONG + * + * long long + *
    + * #H5T_NATIVE_ULLONG + * + * unsigned long long + *
    + * #H5T_NATIVE_FLOAT + * + * float + *
    + * #H5T_NATIVE_DOUBLE + * + * double + *
    + * #H5T_NATIVE_LDOUBLE + * + * long double + *
    + * #H5T_NATIVE_HSIZE + * + * hsize_t + *
    + * #H5T_NATIVE_HSSIZE + * + * hssize_t + *
    + * #H5T_NATIVE_HERR + * + * herr_t + *
    + * #H5T_NATIVE_HBOOL + * + * hbool_t + *
    + * #H5T_NATIVE_B8 + * + * 8-bit unsigned integer or 8-bit buffer in memory + *
    + * #H5T_NATIVE_B16 + * + * 16-bit unsigned integer or 16-bit buffer in memory + *
    + * #H5T_NATIVE_B32 + * + * 32-bit unsigned integer or 32-bit buffer in memory + *
    + * #H5T_NATIVE_B64 + * + * 64-bit unsigned integer or 64-bit buffer in memory + *
    + * + * \subsection subsec_datatype_usage How Datatypes are Used + * + * \subsubsection subsubsec_datatype_usage_object The Datatype Object and the HDF5 Datatype API + * The HDF5 library manages datatypes as objects. The HDF5 datatype API manipulates the + * datatype objects through C function calls. New datatypes can be created from scratch or + * copied from existing datatypes. When a datatype is no longer needed its resources should be released by + * calling \ref H5Tclose(). + * + * The datatype object is used in several roles in the HDF5 data model and library. Essentially, a + * datatype is used whenever the form at of data elements is needed. There are four major uses of + * datatypes in the HDF5 library: at dataset creation, during data transfers, when discovering the + * contents of a file, and for specifying user-defined datatypes. See the table below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 7. Datatype uses
    + * Use + * + * Description + *
    + * Dataset creation + * + * The datatype of the data elements must be declared when the dataset is created. + *
    + * Dataset transfer + * + * The datatype (format) of the data elements must be defined for both the source and destination. + *
    + * Discovery + * + * The datatype of a dataset can be interrogated to retrieve a complete description of the storage layout. + *
    + * Creating user-defined datatypes + * + * Users can define their own datatypes by creating datatype objects and setting their properties. + *
    + * + * \subsubsection subsubsec_datatype_usage_create Dataset Creation + * All the data elements of a dataset have the same datatype. When a dataset is created, the datatype + * for the data elements must be specified. The datatype of a dataset can never be changed. The + * example below shows the use of a datatype to create a dataset called “/dsetâ€. In this example, the + * dataset will be stored as 32-bit signed integers in big-endian order. + * + * Using a datatype to create a dataset + * \code + * hid_t dt; + * + * dt = H5Tcopy(H5T_STD_I32BE); + * dataset_id = H5Dcreate(file_id, “/dsetâ€, dt, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * \endcode + * + * \subsubsection subsubsec_datatype_usage_transfer Data Transfer (Read and Write) + * Probably the most common use of datatypes is to write or read data from a dataset or attribute. In + * these operations, each data element is transferred from the source to the destination (possibly + * rearranging the order of the elements). Since the source and destination do not need to be + * identical (in other words, one is disk and the other is memory), the transfer requires + * both the format of the source element and the destination element. Therefore, data transfers use two + * datatype objects, for the source and destination. + * + * When data is written, the source is memory and the destination is disk (file). The memory + * datatype describes the format of the data element in the machine memory, and the file datatype + * describes the desired format of the data element on disk. Similarly, when reading, the source + * datatype describes the format of the data element on disk, and the destination datatype describes + * the format in memory. + * + * In the most common cases, the file datatype is the datatype specified when + * the dataset was + * created, and the memory datatype should be the appropriate \Emph{NATIVE} type. + * The examples below show samples of writing data to and reading data from a dataset. The data + * in memory is declared C type ‘int’, and the datatype #H5T_NATIVE_INT corresponds to this + * type. The datatype of the dataset should be of datatype class #H5T_INTEGER. + * + * Writing to a dataset + * \code + * int dset_data[DATA_SIZE]; + * + * status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data); + * \endcode + * + * Reading from a dataset + * \code + * int dset_data[DATA_SIZE]; + * + * status = H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data); + * \endcode + * + * \subsubsection subsubsec_datatype_usage_discover Discovery of Data Format + * The HDF5 Library enables a program to + * determine the datatype class and properties for any + * datatype. In order to discover the storage format of data in a dataset, the datatype is obtained, and + * the properties are determined by queries to the datatype object. The example below shows code + * that analyzes the datatype for an integer and prints out a description of its storage properties + * (byte order, signed, size). + * + * Discovering datatype properties + * \code + * switch (H5Tget_class(type)) { + * case H5T_INTEGER: + * ord = H5Tget_order(type); + * sgn = H5Tget_sign(type); + * printf(“Integer ByteOrder= â€); + * switch (ord) { + * case H5T_ORDER_LE: + * printf(“LEâ€); + * break; + * case H5T_ORDER_BE: + * printf(“BEâ€); + * break; + * } + * printf(“ Sign= â€); + * switch (sgn) { + * case H5T_SGN_NONE: + * printf(“falseâ€); + * break; + * case H5T_SGN_2: + * printf(“trueâ€); + * break; + * } + * printf(“ Size= â€); + * sz = H5Tget_size(type); + * printf(“%dâ€, sz); + * printf(“\nâ€); + * break; + * case H5T_???? + * ... + * break; + * } + * \endcode + * + * \subsubsection subsubsec_datatype_usage_user Creating and Using Userâ€defined Datatypes + * Most programs will primarily use the predefined datatypes described above, possibly in + * composite data types such as compound or array datatypes. However, the HDF5 datatype model + * is extremely general; a user program can define a great variety of atomic datatypes (storage + * layouts). In particular, the datatype properties can define signed and unsigned integers of any + * size and byte order, and floating point numbers with different formats, size, and byte order. The + * HDF5 datatype API provides methods to set these properties. + * + * User-defined types can be used to define the layout of data in memory; examples might match + * some platform specific number format or application defined bit-field. The user-defined type can + * also describe data in the file such as an application-defined format. The user-defined types can be + * translated to and from standard types of the same class, as described above. + * + * \subsection subsec_datatype_function Datatype Function Summaries + * @see H5T reference manual provides a reference list of datatype functions, the H5T APIs. + * + * \subsection subsec_datatype_program Programming Model for Datatypes + * The HDF5 Library implements an object-oriented model of datatypes. HDF5 datatypes are + * organized as a logical set of base types, or datatype classes. The HDF5 Library manages + * datatypes as objects. The HDF5 datatype API manipulates the datatype objects through C + * function calls. The figure below shows the abstract view of the datatype object. The table below + * shows the methods (C functions) that operate on datatype objects. New datatypes can be created + * from scratch or copied from existing datatypes. + * + * + * + * + * + *
    + * \image html Dtypes_fig5.gif "The datatype object" + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 8. General operations on datatype objects
    + * API Function + * + * Description + *
    + * \ref hid_t \ref H5Tcreate (\ref H5T_class_t class, size_t size) + * + * Create a new datatype object of datatype class . The following datatype classes care supported + * with this function: + * \li #H5T_COMPOUND + * \li #H5T_OPAQUE + * \li #H5T_ENUM + * \li Other datatypes are created with \ref H5Tcopy(). + *
    + * \ref hid_t \ref H5Tcopy (\ref hid_t type) + * + * Obtain a modifiable transient datatype which is a copy of type. If type is a dataset identifier + * then the type returned is a modifiable transient copy of the datatype of the specified dataset. + *
    + * \ref hid_t \ref H5Topen (\ref hid_t location, const char *name, #H5P_DEFAULT) + * + * Open a committed datatype. The committed datatype returned by this function is read-only. + *
    + * \ref htri_t \ref H5Tequal (\ref hid_t type1, \ref hid_t type2) + * + * Determines if two types are equal. + *
    + * \ref herr_t \ref H5Tclose (\ref hid_t type) + * + * Releases resources associated with a datatype obtained from \ref H5Tcopy, \ref H5Topen, or + * \ref H5Tcreate. It is illegal to close an immutable transient datatype (for example, predefined types). + *
    + * \ref herr_t \ref H5Tcommit (\ref hid_t location, const char *name, hid_t type, + * #H5P_DEFAULT, #H5P_DEFAULT, #H5P_DEFAULT) + * + * Commit a transient datatype (not immutable) to a file to become a committed datatype. Committed + * datatypes can be shared. + *
    + * \ref htri_t \ref H5Tcommitted (\ref hid_t type) + * + * Test whether the datatype is transient or committed (named). + *
    + * \ref herr_t \ref H5Tlock (\ref hid_t type) + * + * Make a transient datatype immutable (read-only and not closable). Predefined types are locked. + *
    + * + * In order to use a datatype, the object must be created (\ref H5Tcreate), or a reference obtained by + * cloning from an existing type (\ref H5Tcopy), or opened (\ref H5Topen). In addition, a reference to the + * datatype of a dataset or attribute can be obtained with \ref H5Dget_type or \ref H5Aget_type. For + * composite datatypes a reference to the datatype for members or base types can be obtained + * (\ref H5Tget_member_type, \ref H5Tget_super). When the datatype object is no longer needed, the + * reference is discarded with \ref H5Tclose. + * + * Two datatype objects can be tested to see if they are the same with \ref H5Tequal. This function + * returns true if the two datatype references refer to the same datatype object. However, if two + * datatype objects define equivalent datatypes (the same datatype class and datatype properties), + * they will not be considered ‘equal’. + * + * A datatype can be written to the file as a first class object (\ref H5Tcommit). This is a committed + * datatype and can be used in thesame way as any other datatype. + * + * \subsubsection subsubsec_datatype_program_discover Discovery of Datatype Properties + * Any HDF5 datatype object can be queried to discover all of its datatype properties. For each + * datatype class, there are a set of API functions to retrieve the datatype properties for this class. + * + *

    Properties of Atomic Datatypes

    + * Table 9 lists the functions to discover the properties of atomic datatypes. Table 10 lists the + * queries relevant to specific numeric types. Table 11 gives the properties for atomic string + * datatype, and Table 12 gives the property of the opaque datatype. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 9. Functions to discover properties of atomic datatypes
    + * API Function + * + * Description + *
    + * \ref H5T_class_t \ref H5Tget_class (\ref hid_t type) + * + * The datatype class: #H5T_INTEGER, #H5T_FLOAT, #H5T_STRING, #H5T_BITFIELD, #H5T_OPAQUE, #H5T_COMPOUND, + * #H5T_REFERENCE, #H5T_ENUM, #H5T_VLEN, #H5T_ARRAY + *
    + * size_t \ref H5Tget_size (\ref hid_t type) + * + * The total size of the element in bytes, including padding which may appear on either side of the + * actual value. + *
    + * \ref H5T_order_t \ref H5Tget_order (\ref hid_t type) + * + * The byte order describes how the bytes of the datatype are laid out in memory. If the lowest memory + * address contains the least significant byte of the datum then it is said to be little-endian or + * #H5T_ORDER_LE. If the bytes are in the opposite order then they are said to be big-endianor #H5T_ORDER_BE. + *
    + * size_t \ref H5Tget_precision (\ref hid_t type) + * + * The precision property identifies the number of significant bits of a datatype and the offset property + * (defined below) identifies its location. Some datatypes occupy more bytes than what is needed to store + * the value. For instance, a short on a Cray is 32 significant bits in an eight-byte field. + *
    + * int \ref H5Tget_offset (\ref hid_t type) + * + * The offset property defines the bit location of the least significant bit of a bit field whose length + * is precision. + *
    + * \ref herr_t \ref H5Tget_pad (\ref hid_t type, \ref H5T_pad_t *lsb, \ref H5T_pad_t *msb) + * + * Padding is the bits of a data element which are not significant as defined by the precision and offset + * properties. Padding in the low-numbered bits is lsb padding and padding in the high-numbered bits is msb + * padding. Padding bits can be set to zero (#H5T_PAD_ZERO) or one (#H5T_PAD_ONE). + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 10. Functions to discover properties of atomic datatypes
    + * API Function + * + * Description + *
    + * \ref H5T_sign_t \ref H5Tget_sign (\ref hid_t type) + * + * (INTEGER)Integer data can be signed two’s complement (#H5T_SGN_2) or unsigned (#H5T_SGN_NONE). + *
    + * \ref herr_t \ref H5Tget_fields (\ref hid_t type, size_t *spos, size_t *epos, size_t *esize, + * size_t*mpos, size_t *msize) + * + * (FLOAT)A floating-point data element has bit fields which are the exponent and mantissa as well as a + * mantissa sign bit. These properties define the location (bit position of least significant bit of the + * field) and size (in bits) of each field. The sign bit is always of length one and none of the fields + * are allowed to overlap. + *
    + * size_t \ref H5Tget_ebias (\ref hid_t type) + * + * (FLOAT)A floating-point data element has bit fields which are the exponent and + * mantissa as well as a mantissa sign bit. These properties define the location (bit + * position of least significant bit of the field) and size (in bits) of + * each field. The sign bit is always of length one and none of the + * fields are allowed to overlap. + *
    + * \ref H5T_norm_t \ref H5Tget_norm (\ref hid_t type) + * + * (FLOAT)This property describes the normalization method of the mantissa. + *
    • #H5T_NORM_MSBSET: the mantissa is shifted left (if non-zero) until the first bit + * after the radix point is set and the exponent is adjusted accordingly. All bits of the + * mantissa after the radix point are stored.
    • + *
    • #H5T_NORM_IMPLIED: the mantissa is shifted left \(if non-zero) until the first + * bit after the radix point is set and the exponent is adjusted accordingly. The first + * bit after the radix point is not stored since it’s always set.
    • + *
    • #H5T_NORM_NONE: the fractional part of the mantissa is stored without normalizing it.
    + *
    + * \ref H5T_pad_t \ref H5Tget_inpad (\ref hid_t type) + * + * (FLOAT)If any internal bits (that is, bits between the sign bit, the mantissa field, + * and the exponent field but within the precision field) are unused, then they will be + * filled according to the value of this property. The padding can be: + * #H5T_PAD_BACKGROUND, #H5T_PAD_ZERO,or #H5T_PAD_ONE. + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 11. Functions to discover properties of atomic string datatypes
    + * API Function + * + * Description + *
    + * \ref H5T_cset_t \ref H5Tget_cset (\ref hid_t type) + * + * Two character sets are currently supported: + * ASCII (#H5T_CSET_ASCII) and UTF-8 (#H5T_CSET_UTF8). + *
    + * \ref H5T_str_t \ref H5Tget_strpad (\ref hid_t type) + * + * The string datatype has a fixed length, but the string may be shorter than the length. + * This property defines the storage mechanism for the left over bytes. The options are: + * \li #H5T_STR_NULLTERM + * \li #H5T_STR_NULLPAD + * \li #H5T_STR_SPACEPAD. + *
    + * + * + * + * + * + * + * + * + * + * + * + *
    Table 12. Functions to discover properties of atomic opaque datatypes
    + * API Function + * + * Description + *
    + * char* \ref H5Tget_tag(\ref hid_t type_id) + * + * A user-defined string. + *
    + * + *

    Properties of Composite Datatypes

    + * The composite datatype classes can also be analyzed to discover their datatype properties and the + * datatypes that are members or base types of the composite datatype. The member or base type + * can, in turn, be analyzed. The table below lists the functions that can access the datatype + * properties of the different composite datatypes. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 13. Functions to discover properties of composite datatypes
    + * API Function + * + * Description + *
    + * int \ref H5Tget_nmembers(\ref hid_t type_id) + * + * (COMPOUND)The number of fields in the compound datatype. + *
    + * \ref H5T_class_t \ref H5Tget_member_class (\ref hid_t cdtype_id, unsigned member_no) + * + * (COMPOUND)The datatype class of compound datatype member member_no. + *
    + * char* \ref H5Tget_member_name (\ref hid_t type_id, unsigned field_idx) + * + * (COMPOUND)The name of field field_idx of a compound datatype. + *
    + * size_t \ref H5Tget_member_offset (\ref hid_t type_id, unsigned memb_no) + * + * (COMPOUND)The byte offset of the beginning of a field within a compound datatype. + *
    + * \ref hid_t \ref H5Tget_member_type (\ref hid_t type_id, unsigned field_idx) + * + * (COMPOUND)The datatype of the specified member. + *
    + * int \ref H5Tget_array_ndims (\ref hid_t adtype_id) + * + * (ARRAY)The number of dimensions (rank) of the array datatype object. + *
    + * int \ref H5Tget_array_dims (\ref hid_t adtype_id, hsize_t *dims[]) + * + * (ARRAY)The sizes of the dimensions and the dimension permutations of the array datatype object. + *
    + * \ref hid_t \ref H5Tget_super(\ref hid_t type) + * + * (ARRAY, VL, ENUM)The base datatype from which the datatype type is derived. + *
    + * \ref herr_t \ref H5Tenum_nameof(\ref hid_t type, const void *value, char *name, size_t size) + * + * (ENUM)The symbol name that corresponds to the specified value of the enumeration datatype. + *
    + * \ref herr_t \ref H5Tenum_valueof(\ref hid_t type, const char *name, void *value) + * + * (ENUM)The value that corresponds to the specified name of the enumeration datatype. + *
    + * \ref herr_t \ref H5Tget_member_value (\ref hid_t type unsigned memb_no, void *value) + * + * (ENUM)The value of the enumeration datatype member memb_no. + *
    + * + * \subsubsection subsubsec_datatype_program_define Definition of Datatypes + * The HDF5 library enables user programs to create and modify datatypes. The essential steps are: + *
    • 1. Create a new datatype object of a specific composite datatype class, or copy an existing + * atomic datatype object
    • + *
    • 2. Set properties of the datatype object
    • + *
    • 3. Use the datatype object
    • + *
    • 4. Close the datatype object
    + * + * To create a user-defined atomic datatype, the procedure is to clone a predefined datatype of the + * appropriate datatype class (\ref H5Tcopy), and then set the datatype properties appropriate to the + * datatype class. The table below shows how to create a datatype to describe a 1024-bit unsigned + * integer. + * + * Create a new datatype + * \code + * hid_t new_type = H5Tcopy (H5T_NATIVE_INT); + * + * H5Tset_precision(new_type, 1024); + * H5Tset_sign(new_type, H5T_SGN_NONE); + * \endcode + * + * Composite datatypes are created with a specific API call for each datatype class. The table below + * shows the creation method for each datatype class. A newly created datatype cannot be used until the + * datatype properties are set. For example, a newly created compound datatype has no members and cannot + * be used. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 14. Functions to create each datatype class
    + * Datatype Class + * + * Function to Create + *
    + * COMPOUND + * + * #H5Tcreate + *
    + * OPAQUE + * + * #H5Tcreate + *
    + * ENUM + * + * #H5Tenum_create + *
    + * ARRAY + * + * #H5Tarray_create + *
    + * VL + * + * #H5Tvlen_create + *
    + * + * Once the datatype is created and the datatype properties set, the datatype object can be used. + * + * Predefined datatypes are defined by the library during initialization using the same mechanisms + * as described here. Each predefined datatype is locked (\ref H5Tlock), so that it cannot be changed or + * destroyed. User-defined datatypes may also be locked using \ref H5Tlock. + * + *

    User-defined Atomic Datatypes

    + * Table 15 summarizes the API methods that set properties of atomic types. Table 16 shows + * properties specific to numeric types, Table 17 shows properties specific to the string datatype + * class. Note that offset, pad, etc. do not apply to strings. Table 18 shows the specific property of + * the OPAQUE datatype class. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 15. API methods that set properties of atomic datatypes
    + * Functions + * + * Description + *
    + * \ref herr_t \ref H5Tset_size (\ref hid_t type, size_t size) + * + * Set the total size of the element in bytes. This includes padding which may appear on either + * side of the actual value. If this property is reset to a smaller value which would cause the + * significant part of the data to extend beyond the edge of the datatype, then the offset property + * is decremented a bit at a time. If the offset reaches zero and the significant part of the data + * still extends beyond the edge of the datatype then the precision property is decremented a bit at + * a time. Decreasing the size of a datatype may fail if the #H5T_FLOAT bit fields would extend beyond + * the significant part of the type. + *
    + * \ref herr_t \ref H5Tset_order (\ref hid_t type, \ref H5T_order_t order) + * + * Set the byte order to little-endian (#H5T_ORDER_LE) or big-endian (#H5T_ORDER_BE). + *
    + * \ref herr_t \ref H5Tset_precision (\ref hid_t type, size_t precision) + * + * Set the number of significant bits of a datatype. The offset property (defined below) identifies + * its location. The size property defined above represents the entire size (in bytes) of the datatype. + * If the precision is decreased then padding bits are inserted on the MSB side of the significant + * bits (this will fail for #H5T_FLOAT types if it results in the sign,mantissa, or exponent bit field + * extending beyond the edge of the significant bit field). On the other hand, if the precision is + * increased so that it “hangs over†the edge of the total size then the offset property is decremented + * a bit at a time. If the offset reaches zero and the significant bits still hang over the edge, then + * the total size is increased a byte at a time. + *
    + * \ref herr_t \ref H5Tset_offset (\ref hid_t type, size_t offset) + * + * Set the bit location of the least significant bit of a bit field whose length is precision. The + * bits of the entire data are numbered beginning at zero at the least significant bit of the least + * significant byte (the byte at the lowest memory address for a little-endian type or the byte at + * the highest address for a big-endian type). The offset property defines the bit location of the + * least significant bit of a bit field whose length is precision. If the offset is increased so the + * significant bits “hang over†the edge of the datum, then the size property is automatically incremented. + *
    + * \ref herr_t \ref H5Tset_pad (\ref hid_t type, \ref H5T_pad_t lsb, \ref H5T_pad_t msb) + * + * Set the padding to zeros (#H5T_PAD_ZERO) or ones (#H5T_PAD_ONE). Padding is the bits of a + * data element which are not significant as defined by the precision and offset properties. Padding + * in the low-numbered bits is lsb padding and padding in the high-numbered bits is msb padding. + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 16. API methods that set properties of numeric datatypes
    + * Functions + * + * Description + *
    + * \ref herr_t \ref H5Tset_sign (\ref hid_t type, \ref H5T_sign_t sign) + * + * (INTEGER)Integer data can be signed two’s complement (#H5T_SGN_2) or unsigned (#H5T_SGN_NONE). + *
    + * \ref herr_t \ref H5Tset_fields (\ref hid_t type, size_t spos, size_t epos, size_t esize, + * size_t mpos, size_t msize) + * + * (FLOAT)Set the properties define the location (bit position of least significant bit of the field) + * and size (in bits) of each field. The sign bit is always of length one and none of the fields are + * allowed to overlap. + *
    + * \ref herr_t \ref H5Tset_ebias (\ref hid_t type, size_t ebias) + * + * (FLOAT)The exponent is stored as a non-negative value which is ebias larger than the true exponent. + *
    + * \ref herr_t \ref H5Tset_norm (\ref hid_t type, \ref H5T_norm_t norm) + * + * (FLOAT)This property describes the normalization method of the mantissa. + *
    • #H5T_NORM_MSBSET: the mantissa is shifted left (if non-zero) until the first bit + * after theradix point is set and the exponent is adjusted accordingly. All bits of the + * mantissa after the radix point are stored.
    • + *
    • #H5T_NORM_IMPLIED: the mantissa is shifted left (if non-zero) until the first bit + * after the radix point is set and the exponent is adjusted accordingly. The first bit after + * the radix point is not stored since it is always set.
    • + *
    • #H5T_NORM_NONE: the fractional part of the mantissa is stored without normalizing it.
    + *
    + * \ref herr_t \ref H5Tset_inpad (\ref hid_t type, \ref H5T_pad_t inpad) + * + * (FLOAT) +If any internal bits (that is, bits between the sign bit, the mantissa field, +and the exponent field but within the precision field) are unused, then they will be +filled according to the value of this property. The padding can be: + * \li #H5T_PAD_BACKGROUND + * \li #H5T_PAD_ZERO + * \li #H5T_PAD_ONE + *
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 17. API methods that set properties of string datatypes
    + * Functions + * + * Description + *
    + * \ref herr_t \ref H5Tset_size (\ref hid_t type, size_t size) + * + * Set the length of the string, in bytes. The precision is automatically set to 8*size. + *
    + * \ref herr_t \ref H5Tset_precision (\ref hid_t type, size_t precision) + * + * The precision must be a multiple of 8. + *
    + * \ref herr_t \ref H5Tset_cset (\ref hid_t type_id, \ref H5T_cset_t cset) + * + * Two character sets are currently supported: + * \li ASCII (#H5T_CSET_ASCII) + * \li UTF-8 (#H5T_CSET_UTF8). + *
    + * \ref herr_t \ref H5Tset_strpad (\ref hid_t type_id, H5T_str_t strpad) + * + * The string datatype has a fixed length, but the string may be shorter than the length. This + * property defines the storage mechanism for the left over bytes. The method used to store + * character strings differs with the programming language: + * \li C usually null terminates strings + * \li Fortran left-justifies and space-pads strings + * + * Valid string padding values, as passed in the parameter strpad, are as follows: + * \li #H5T_STR_NULLTERM: Null terminate (as C does) + * \li #H5T_STR_NULLPAD: Pad with zeros + * \li #H5T_STR_SPACEPAD: Pad with spaces (as FORTRAN does) + *
    + * + * + * + * + * + * + * + * + * + * + * + *
    Table 18. API methods that set properties of opaque datatypes
    + * Functions + * + * Description + *
    + * \ref herr_t \ref H5Tset_tag (\ref hid_t type_id, const char *tag) + * + * Tags the opaque datatype type_id with an ASCII identifier tag. + *
    + * + *

    Examples

    + * The example below shows how to create a 128-bit little-endian signed integer type. Increasing + * the precision of a type automatically increases the total size. Note that the proper + * procedure is to begin from a type of the intended datatype class which in this case is a + * NATIVE INT. + * + * Create a new 128-bit little-endian signed integer datatype + * \code + * hid_t new_type = H5Tcopy (H5T_NATIVE_INT); + * H5Tset_precision (new_type, 128); + * H5Tset_order (new_type, H5T_ORDER_LE); + * \endcode + * + * The figure below shows the storage layout as the type is defined. The \ref H5Tcopy creates a + * datatype that is the same as #H5T_NATIVE_INT. In this example, suppose this is a 32-bit + * big-endian number (Figure a). The precision is set to 128 bits, which automatically extends + * the size to 8 bytes (Figure b). Finally, the byte order is set to little-endian (Figure c). + * + * + * + * + * + *
    + * \image html Dtypes_fig6.gif "The storage layout for a new 128-bit little-endian signed integer datatype" + *
    + * + * The significant bits of a data element can be offset from the beginning of the memory for that + * element by an amount of padding. The offset property specifies the number of bits of padding + * that appear to the “right of†the value. The table and figure below show how a 32-bit unsigned + * integer with 16-bits of precision having the value 0x1122 will be laid out in memory. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Table 19. Memory Layout for a 32-bit unsigned integer
    + * Byte Position + * + * Big-Endian
    Offset=0 + *
    + * Big-Endian
    Offset=16 + *
    + * Little-Endian
    Offset=0 + *
    + * Little-Endian
    Offset=16 + *
    + * 0: + * + * [pad] + * + * [0x11] + * + * [0x22] + * + * [pad] + *
    + * 1: + * + * [pad] + * + * [0x22] + * + * [0x11] + * + * [pad] + *
    + * 2: + * + * [0x11] + * + * [pad] + * + * [pad] + * + * [0x22] + *
    + * 3: + * + * [0x22] + * + * [pad] + * + * [pad] + * + * [0x11] + *
    + * + * + * + * + * + *
    + * \image html Dtypes_fig7.gif "Memory Layout for a 32-bit unsigned integer" + *
    + * + * If the offset is incremented then the total size is incremented also if necessary to prevent + * significant bits of the value from hanging over the edge of the datatype. + * + * The bits of the entire data are numbered beginning at zero at the least significant bit of the least + * significant byte (the byte at the lowest memory address for a little-endian type or the byte at the + * highest address for a big-endian type). The offset property defines the bit location of the least + * significant bit of a bit field whose length is precision. If the offset is increased so the significant + * bits “hang over†the edge of the datum, then the size property is automatically incremented. + * + * To illustrate the properties of the integer datatype class, the example below shows how to create + * a user-defined datatype that describes a 24-bit signed integer that starts on the third bit of a 32-bit + * word. The datatype is specialized from a 32-bit integer, the precision is set to 24 bits, and the + * offset is set to 3. + * + * A user-defined datatype with a 24-bit signed integer + * \code + * hid_t dt; + * + * dt = H5Tcopy(H5T_SDT_I32LE); + * H5Tset_precision(dt, 24); + * H5Tset_offset(dt,3); + * H5Tset_pad(dt, H5T_PAD_ZERO, H5T_PAD_ONE); + * \endcode + * + * The figure below shows the storage layout for a data element. Note that the unused bits in the + * offset will be set to zero and the unused bits at the end will be set to one, as specified in the + * \ref H5Tset_pad call. + * + * + * + * + *
    + * \image html Dtypes_fig8.gif "A user-defined integer datatype with a range of -1,048,583 to 1,048,584" + *
    + * + * To illustrate a user-defined floating point number, the example below shows how to create a 24-bit + * floating point number that starts 5 bits into a 4 byte word. The floating point number is defined to + * have a mantissa of 19 bits (bits 5-23), an exponent of 3 bits (25-27), and the sign bit is bit 28. + * (Note that this is an illustration of what can be done and is not necessarily a floating point + * format that a user would require.) + * + * A user-defined datatype with a 24-bit floating point datatype + * \code + * hid_t dt; + * + * dt = H5Tcopy(H5T_SDT_F32LE); + * H5Tset_precision(dt, 24); + * H5Tset_fields (dt, 28, 25, 3, 5, 19); + * H5Tset_pad(dt, H5T_PAD_ZERO, H5T_PAD_ONE); + * H5Tset_inpad(dt, H5T_PAD_ZERO); + * \endcode + * + * + * + * + * + *
    + * \image html Dtypes_fig9.gif "A user-defined floating point datatype" + *
    + * The figure above shows the storage layout of a data element for this datatype. Note that there is + * an unused bit (24) between the mantissa and the exponent. This bit is filled with the inpad value + * which in this case is 0. + * + * The sign bit is always of length one and none of the fields are allowed to overlap. When + * expanding a floating-point type one should set the precision first; when decreasing the size one + * should set the field positions and sizes first. + * + *

    Composite Datatypes

    + * All composite datatypes must be user-defined; there are no predefined composite datatypes. + * + *

    Compound Datatypes

    + * The subsections below describe how to create a compound datatype and how to write and read + * data of a compound datatype. + * + *

    Defining Compound Datatypes

    + * + * Compound datatypes are conceptually similar to a C struct or Fortran derived types. The + * compound datatype defines a contiguous sequence of bytes, which are formatted using one up to + * 2^16 datatypes (members). A compound datatype may have any number of members, in any + * order, and the members may have any datatype, including compound. Thus, complex nested + * compound datatypes can be created. The total size of the compound datatype is greater than or + * equal to the sum of the size of its members, up to a maximum of 2^32 bytes. HDF5 does not + * support datatypes with distinguished records or the equivalent of C unions or Fortran + * EQUIVALENCE statements. + * + * Usually a C struct or Fortran derived type will be defined to hold a data point in memory, and the + * offsets of the members in memory will be the offsets of the struct members from the beginning + * of an instance of the struct. The HDF5 C library provides a macro #HOFFSET (s,m)to calculate + * the member’s offset. The HDF5 Fortran applications have to calculate offsets by using sizes of + * members datatypes and by taking in consideration the order of members in the Fortran derived type. + * \code + * HOFFSET(s,m) + * \endcode + * This macro computes the offset of member m within a struct s + * \code + * offsetof(s,m) + * \endcode + * This macro defined in stddef.h does exactly the same thing as the HOFFSET()macro. + * + * Note for Fortran users: Offsets of Fortran structure members correspond to the offsets within a + * packed datatype (see explanation below) stored in an HDF5 file. + * + * Each member of a compound datatype must have a descriptive name which is the key used to + * uniquely identify the member within the compound datatype. A member name in an HDF5 + * datatype does not necessarily have to be the same as the name of the member in the C struct or + * Fortran derived type, although this is often the case. Nor does one need to define all members of + * the C struct or Fortran derived type in the HDF5 compound datatype (or vice versa). + * + * Unlike atomic datatypes which are derived from other atomic datatypes, compound datatypes are + * created from scratch. First, one creates an empty compound datatype and specifies its total size. + * Then members are added to the compound datatype in any order. Each member type is inserted + * at a designated offset. Each member has a name which is the key used to uniquely identify the + * member within the compound datatype. + * + * The example below shows a way of creating an HDF5 C compound datatype to describe a + * complex number. This is a structure with two components, “real†and “imaginaryâ€, and each + * component is a double. An equivalent C struct whose type is defined by the complex_tstruct is + * shown. + * + * A compound datatype for complex numbers in C + * \code + * typedef struct { + * double re; //real part + * double im; //imaginary part + * } complex_t; + * + * hid_t complex_id = H5Tcreate (H5T_COMPOUND, sizeof (complex_t)); + * H5Tinsert (complex_id, “realâ€, HOFFSET(complex_t,re), + * H5T_NATIVE_DOUBLE); + * H5Tinsert (complex_id, “imaginaryâ€, HOFFSET(complex_t,im), + * H5T_NATIVE_DOUBLE); + * \endcode + * + * The example below shows a way of creating an HDF5 Fortran compound datatype to describe a + * complex number. This is a Fortran derived type with two components, “real†and “imaginaryâ€, + * and each component is DOUBLE PRECISION. An equivalent Fortran TYPE whose type is defined + * by the TYPE complex_t is shown. + * + * A compound datatype for complex numbers in Fortran + * \code + * TYPE complex_t + * DOUBLE PRECISION re ! real part + * DOUBLE PRECISION im; ! imaginary part + * END TYPE complex_t + * + * CALL h5tget_size_f(H5T_NATIVE_DOUBLE, re_size, error) + * CALL h5tget_size_f(H5T_NATIVE_DOUBLE, im_size, error) + * complex_t_size = re_size + im_size + * CALL h5tcreate_f(H5T_COMPOUND_F, complex_t_size, type_id) + * offset = 0 + * CALL h5tinsert_f(type_id, “realâ€, offset, H5T_NATIVE_DOUBLE, error) + * offset = offset + re_size + * CALL h5tinsert_f(type_id, “imaginaryâ€, offset, H5T_NATIVE_DOUBLE, error) + * \endcode + * + * Important Note: The compound datatype is created with a size sufficient to hold all its members. + * In the C example above, the size of the C struct and the #HOFFSET macro are used as a + * convenient mechanism to determine the appropriate size and offset. Alternatively, the size and + * offset could be manually determined: the size can be set to 16 with “real†at offset 0 and + * “imaginary†at offset 8. However, different platforms and compilers have different sizes for + * “double†and may have alignment restrictions which require additional padding within the + * structure. It is much more portable to use the #HOFFSET macro which assures that the values will + * be correct for any platform. + * + * The figure below shows how the compound datatype would be laid out assuming that + * NATIVE_DOUBLE are 64-bit numbers and that there are no alignment requirements. The total + * size of the compound datatype will be 16 bytes, the “real†component will start at byte 0, and + * “imaginary†will start at byte 8. + * + * + * + * + * + *
    + * \image html Dtypes_fig10.gif "Layout of a compound datatype" + *
    + * + * The members of a compound datatype may be any HDF5 datatype including the compound, + * array, and variable-length (VL) types. The figure and example below show the memory layout + * and code which creates a compound datatype composed of two complex values, and each + * complex value is also a compound datatype as in the figure above. + * + * + * + * + * + *
    + * \image html Dtypes_fig11.gif "Layout of a compound datatype nested in a compound datatype" + *
    + * + * Code for a compound datatype nested in a compound datatype + * \code + * typedef struct { + * complex_t x; + * complex_t y; + * } surf_t; + * + * hid_t complex_id, surf_id; // hdf5 datatypes + * + * complex_id = H5Tcreate (H5T_COMPOUND, sizeof(complex_t)); + * H5Tinsert (complex_id, “reâ€, HOFFSET(complex_t, re), H5T_NATIVE_DOUBLE); + * H5Tinsert (complex_id, “imâ€, HOFFSET(complex_t, im), H5T_NATIVE_DOUBLE); + * + * surf_id = H5Tcreate (H5T_COMPOUND, sizeof(surf_t)); + * H5Tinsert (surf_id, “xâ€, HOFFSET(surf_t, x), complex_id); + * H5Tinsert (surf_id, “yâ€, HOFFSET(surf_t, y), complex_id); + * \endcode + * + * Note that a similar result could be accomplished by creating a compound datatype and inserting + * four fields. See the figure below. This results in the same layout as the figure above. The difference + * would be how the fields are addressed. In the first case, the real part of ‘y’ is called ‘y.re’; + * in the second case it is ‘y-re’. + * + * Another compound datatype nested in a compound datatype + * \code + * typedef struct { + * complex_t x; + * complex_t y; + * } surf_t; + * + * hid_t surf_id = H5Tcreate (H5T_COMPOUND, sizeof(surf_t)); + * H5Tinsert (surf_id, “x-reâ€, HOFFSET(surf_t, x.re), H5T_NATIVE_DOUBLE); + * H5Tinsert (surf_id, “x-imâ€, HOFFSET(surf_t, x.im), H5T_NATIVE_DOUBLE); + * H5Tinsert (surf_id, “y-reâ€, HOFFSET(surf_t, y.re), H5T_NATIVE_DOUBLE); + * H5Tinsert (surf_id, “y-imâ€, HOFFSET(surf_t, y.im), H5T_NATIVE_DOUBLE); + * \endcode + * + * The members of a compound datatype do not always fill all the bytes. The #HOFFSET macro + * assures that the members will be laid out according to the requirements of the platform and + * language. The example below shows an example of a C struct which requires extra bytes of + * padding on many platforms. The second element, ‘b’, is a 1-byte character followed by an 8 byte + * double, ‘c’. On many systems, the 8-byte value must be stored on a 4-or 8-byte boundary. This + * requires the struct to be larger than the sum of the size of its elements. + * + * In the example below, sizeof and #HOFFSET are used to assure that the members are inserted at + * the correct offset to match the memory conventions of the platform. The figure below shows how + * this data element would be stored in memory, assuming the double must start on a 4-byte + * boundary. Notice the extra bytes between ‘b’ and ‘c’. + * + * A compound datatype that requires padding + * \code + * typedef struct { + * int a; + * char b; + * double c; + * } s1_t; + * + * hid_t s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); + * H5Tinsert (s1_tid, “x-imâ€, HOFFSET(s1_t, a), H5T_NATIVE_INT); + * H5Tinsert (s1_tid, “y-reâ€, HOFFSET(s1_t, b), H5T_NATIVE_CHAR); + * H5Tinsert (s1_tid, “y-imâ€, HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); + * \endcode + * + * + * + * + * + *
    + * \image html Dtypes_fig12.gif "Memory layout of a compound datatype that requires padding" + *
    + * + * However, data stored on disk does not require alignment, so unaligned versions of compound + * data structures can be created to improve space efficiency on disk. These unaligned compound + * datatypes can be created by computing offsets by hand to eliminate inter-member padding, or the + * members can be packed by calling #H5Tpack (which modifies a datatype directly, so it is usually + * preceded by a call to #H5Tcopy). + * + * The example below shows how to create a disk version of the compound datatype from the + * figure above in order to store data on disk in as compact a form as possible. Packed compound + * datatypes should generally not be used to describe memory as they may violate alignment + * constraints for the architecture being used. Note also that using a packed datatype for disk + * storage may involve a higher data conversion cost. + * + * Create a packed compound datatype in C + * \code + * hid_t s2_tid = H5Tcopy (s1_tid); + * H5Tpack (s2_tid); + * \endcode + * + * The example below shows the sequence of Fortran calls to create a packed compound datatype. + * An HDF5 Fortran compound datatype never describes a compound datatype in memory and + * compound data is ALWAYS written by fields as described in the next section. Therefore packing + * is not needed unless the offset of each consecutive member is not equal to the sum of the sizes of + * the previous members. + * + * Create a packed compound datatype in Fortran + * \code + * CALL h5tcopy_f(s1_id, s2_id, error) + * CALL h5tpack_f(s2_id, error) + * \endcode + * + *

    Creating and Writing Datasets with Compound Datatypes

    + * + * Creating datasets with compound datatypes is similar to creating datasets with any other HDF5 + * datatypes. But writing and reading may be different since datasets that have compound datatypes + * can be written or read by a field (member) or subsets of fields (members). The compound + * datatype is the only composite datatype that supports “sub-setting†by the elements the datatype + * is built from. + * + * The example below shows a C example of creating and writing a dataset with a compound + * datatype. + * + * + * Create and write a dataset with a compound datatype in C + * \code + * typedef struct s1_t { + * int a; + * float b; + * double c; + * } s1_t; + * + * s1_t data[LENGTH]; + * + * // Initialize data + * for (i = 0; i < LENGTH; i++) { + * data[i].a = i; + * data[i].b = i*i; + * data[i].c = 1./(i+1); + * } + * + * ... + * + * s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); + * H5Tinsert(s1_tid, “a_nameâ€, HOFFSET(s1_t, a), H5T_NATIVE_INT); + * H5Tinsert(s1_tid, “b_nameâ€, HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); + * H5Tinsert(s1_tid, “c_nameâ€, HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); + * + * ... + * + * dataset_id = H5Dcreate(file_id, “SDScompound.h5â€, s1_t, + * space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * H5Dwrite (dataset_id, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + * \endcode + * + * The example below shows the content of the file written on a little-endian machine. + * Create and write a little-endian dataset with a compound datatype in C + * \code + * HDF5 “SDScompound.h5†{ + * GROUP “/†{ + * DATASET “ArrayOfStructures†{ + * DATATYPE H5T_COMPOUND { + * H5T_STD_I32LE “a_nameâ€; + * H5T_IEEE_F32LE “b_nameâ€; + * H5T_IEEE_F64LE “c_nameâ€; + * } + * DATASPACE SIMPLE { ( 3 ) / ( 3 ) } + * DATA { + * (0): { + * 0, + * 0, + * 1 + * }, + * (1): { + * 0, + * 1, + * 0.5 + * }, + * (2): { + * 0, + * 4, + * 0.333333 + * } + * } + * } + * } + * } + * \endcode + * + * It is not necessary to write the whole data at once. Datasets with compound datatypes can be + * written by field or by subsets of fields. In order to do this one has to remember to set the transfer + * property of the dataset using the H5Pset_preserve call and to define the memory datatype that + * corresponds to a field. The example below shows how float and double fields are written to the + * dataset. + * + * Writing floats and doubles to a dataset + * \code + * typedef struct sb_t { + * float b; + * double c; + * } sb_t; + * + * typedef struct sc_t { + * float b; + * double c; + * } sc_t; + * sb_t data1[LENGTH]; + * sc_t data2[LENGTH]; + * + * // Initialize data + * for (i = 0; i < LENGTH; i++) { + * data1.b = i * i; + * data2.c = 1./(i + 1); + * } + * + * ... + * + * // Create dataset as in example 15 + * + * ... + * + * // Create memory datatypes corresponding to float + * // and double datatype fields + * + * sb_tid = H5Tcreate (H5T_COMPOUND, sizeof(sb_t)); + * H5Tinsert(sb_tid, “b_nameâ€, HOFFSET(sb_t, b), H5T_NATIVE_FLOAT); + * sc_tid = H5Tcreate (H5T_COMPOUND, sizeof(sc_t)); + * H5Tinsert(sc_tid, “c_nameâ€, HOFFSET(sc_t, c), H5T_NATIVE_DOUBLE); + * + * ... + * + * // Set transfer property + * xfer_id = H5Pcreate(H5P_DATASET_XFER); + * H5Pset_preserve(xfer_id, 1); + * H5Dwrite (dataset_id, sb_tid, H5S_ALL, H5S_ALL, xfer_id, data1); + * H5Dwrite (dataset_id, sc_tid, H5S_ALL, H5S_ALL, xfer_id, data2); + * \endcode + * + * The figure below shows the content of the file written on a little-endian machine. Only float and + * double fields are written. The default fill value is used to initialize the unwritten integer field. + * Writing floats and doubles to a dataset on a little-endian system + * \code + * HDF5 “SDScompound.h5†{ + * GROUP “/†{ + * DATASET “ArrayOfStructures†{ + * DATATYPE H5T_COMPOUND { + * H5T_STD_I32LE “a_nameâ€; + * H5T_IEEE_F32LE “b_nameâ€; + * H5T_IEEE_F64LE “c_nameâ€; + * } + * DATASPACE SIMPLE { ( 3 ) / ( 3 ) } + * DATA { + * (0): { + * 0, + * 0, + * 1 + * }, + * (1): { + * 0, + * 1, + * 0.5 + * }, + * (2): { + * 0, + * 4, + * 0.333333 + * } + * } + * } + * } + * } + * \endcode + * + * The example below contains a Fortran example that creates and writes a dataset with a + * compound datatype. As this example illustrates, writing and reading compound datatypes in + * Fortran is always done by fields. The content of the written file is the same as shown in the + * example above. + * Create and write a dataset with a compound datatype in Fortran + * \code + * ! One cannot write an array of a derived datatype in + * ! Fortran. + * TYPE s1_t + * INTEGER a + * REAL b + * DOUBLE PRECISION c + * END TYPE s1_t + * TYPE(s1_t) d(LENGTH) + * ! Therefore, the following code initializes an array + * ! corresponding to each field in the derived datatype + * ! and writesthose arrays to the dataset + * + * INTEGER, DIMENSION(LENGTH) :: a + * REAL, DIMENSION(LENGTH) :: b + * DOUBLE PRECISION, DIMENSION(LENGTH) :: c + * + * ! Initialize data + * do i = 1, LENGTH + * a(i) = i-1 + * b(i) = (i-1) * (i-1) + * c(i) = 1./i + * enddo + * + * ... + * + * ! Set dataset transfer property to preserve partially + * ! initialized fields during write/read to/from dataset + * ! with compound datatype. + * ! + * CALL h5pcreate_f(H5P_DATASET_XFER_F, plist_id, error) + * CALL h5pset_preserve_f(plist_id, .TRUE., error) + * + * ... + * + * ! + * ! Create compound datatype. + * ! + * ! First calculate total size by calculating sizes of + * ! each member + * ! + * CALL h5tget_size_f(H5T_NATIVE_INTEGER, type_sizei, error) + * CALL h5tget_size_f(H5T_NATIVE_REAL, type_sizer, error) + * CALL h5tget_size_f(H5T_NATIVE_DOUBLE, type_sized, error) + * type_size = type_sizei + type_sizer + type_sized + * CALL h5tcreate_f(H5T_COMPOUND_F, type_size, dtype_id, error) + * ! + * ! Insert members + * ! + * ! + * ! INTEGER member + * ! + * offset = 0 + * CALL h5tinsert_f(dtype_id, “a_nameâ€, offset, H5T_NATIVE_INTEGER, error) + * ! + * ! REAL member + * ! + * offset = offset + type_sizei + * CALL h5tinsert_f(dtype_id, “b_nameâ€, offset, H5T_NATIVE_REAL, error) + * ! + * ! DOUBLE PRECISION member + * ! + * offset = offset + type_sizer + * CALL h5tinsert_f(dtype_id, “c_nameâ€, offset, H5T_NATIVE_DOUBLE, error) + * ! + * ! Create the dataset with compound datatype. + * ! + * CALL h5dcreate_f(file_id, dsetname, dtype_id, dspace_id, &dset_id, error, H5P_DEFAULT_F, + * H5P_DEFAULT_F, H5P_DEFAULT_F) + * ! + * + * ... + * + * ! Create memory types. We have to create a compound + * ! datatype for each member we want to write. + * ! + * CALL h5tcreate_f(H5T_COMPOUND_F, type_sizei, dt1_id, error) + * offset = 0 + * CALL h5tinsert_f(dt1_id, “a_nameâ€, offset, H5T_NATIVE_INTEGER, error) + * ! + * CALL h5tcreate_f(H5T_COMPOUND_F, type_sizer, dt2_id, error) + * offset = 0 + * CALL h5tinsert_f(dt2_id, “b_nameâ€, offset, H5T_NATIVE_REAL, error) + * ! + * CALL h5tcreate_f(H5T_COMPOUND_F, type_sized, dt3_id, error) + * offset = 0 + * CALL h5tinsert_f(dt3_id, “c_nameâ€, offset, H5T_NATIVE_DOUBLE, error) + * ! + * ! Write data by fields in the datatype. Fields order + * ! is not important. + * ! + * CALL h5dwrite_f(dset_id, dt3_id, c, data_dims, error, xfer_prp = plist_id) + * CALL h5dwrite_f(dset_id, dt2_id, b, data_dims, error, xfer_prp = plist_id) + * CALL h5dwrite_f(dset_id, dt1_id, a, data_dims, error, xfer_prp = plist_id) + * \endcode + * + *

    Reading Datasets with Compound Datatypes

    + * + * Reading datasets with compound datatypes may be a challenge. For general applications there is + * no way to know a priori the corresponding C structure. Also, C structures cannot be allocated on + * the fly during discovery of the dataset’s datatype. For general C, C++, Fortran and Java + * application the following steps will be required to read and to interpret data from the dataset with + * compound datatype: + * \li 1. Get the identifier of the compound datatype in the file with the #H5Dget_type call + * \li 2. Find the number of the compound datatype members with the #H5Tget_nmembers call + * \li 3. Iterate through compound datatype members + *
    • Get member class with the #H5Tget_member_class call
    • + *
    • Get member name with the #H5Tget_member_name call
    • + *
    • Check class type against predefined classes + *
      • #H5T_INTEGER
      • + *
      • #H5T_FLOAT
      • + *
      • #H5T_STRING
      • + *
      • #H5T_BITFIELD
      • + *
      • #H5T_OPAQUE
      • + *
      • #H5T_COMPOUND
      • + *
      • #H5T_REFERENCE
      • + *
      • #H5T_ENUM
      • + *
      • #H5T_VLEN
      • + *
      • #H5T_ARRAY
      + *
    • + *
    • If class is #H5T_COMPOUND, then go to step 2 and repeat all steps under step 3. If + * class is not #H5T_COMPOUND, then a member is of an atomic class and can be read + * to a corresponding buffer after discovering all necessary information specific to each + * atomic type (for example, size of the integer or floats, super class for enumerated and + * array datatype, and its sizes)
    + * + * The examples below show how to read a dataset with a known compound datatype. + * + * The first example below shows the steps needed to read data of a known structure. First, build a + * memory datatype the same way it was built when the dataset was created, and then second use + * the datatype in an #H5Dread call. + * + * Read a dataset using a memory datatype + * \code + * typedef struct s1_t { + * int a; + * float b; + * double c; + * } s1_t; + * + * s1_t *data; + * + * ... + * + * s1_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); + * H5Tinsert(s1_tid, “a_nameâ€, HOFFSET(s1_t, a), H5T_NATIVE_INT); + * H5Tinsert(s1_tid, “b_nameâ€, HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); + * H5Tinsert(s1_tid, “c_nameâ€, HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); + * + * ... + * + * dataset_id = H5Dopen(file_id, “SDScompound.h5â€, H5P_DEFAULT); + * + * ... + * + * data = (s1_t *) malloc (sizeof(s1_t)*LENGTH); + * H5Dread(dataset_id, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + * \endcode + * + * Instead of building a memory datatype, the application could use the + * #H5Tget_native_type function. See the example below. + * + * Read a dataset using H5Tget_native_type + * \code + * typedef struct s1_t { + * int a; + * float b; + * double c; + * } s1_t; + * + * s1_t *data; + * hid_t file_s1_t, mem_s1_t; + * + * ... + * + * dataset_id = H5Dopen(file_id, “SDScompound.h5â€, H5P_DEFAULT); + * // Discover datatype in the file + * file_s1_t = H5Dget_type(dataset_id); + * // Find corresponding memory datatype + * mem_s1_t = H5Tget_native_type(file_s1_t, H5T_DIR_DEFAULT); + * + * ... + * + * data = (s1_t *) malloc (sizeof(s1_t)*LENGTH); + * H5Dread (dataset_id,mem_s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + * \endcode + * + * The example below shows how to read just one float member of a compound datatype. + * + * Read one floating point member of a compound datatype + * \code + * typedef struct sf_t { + * float b; + * } sf_t; + * + * sf_t *data; + * + * ... + * + * sf_tid = H5Tcreate(H5T_COMPOUND, sizeof(sf_t)); + * H5Tinsert(sf_tid, “b_nameâ€, HOFFSET(sf_t, b), H5T_NATIVE_FLOAT); + * + * ... + * + * dataset_id = H5Dopen(file_id, “SDScompound.h5â€, H5P_DEFAULT); + * + * ... + * + * data = (sf_t *) malloc (sizeof(sf_t) * LENGTH); + * H5Dread(dataset_id, sf_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + * \endcode + * + * The example below shows how to read float and double members of a compound datatype into a + * structure that has those fields in a different order. Please notice that #H5Tinsert calls can be used + * in an order different from the order of the structure’s members. + * + * Read float and double members of a compound datatype + * \code + * typedef struct sdf_t { + * double c; + * float b; + * } sdf_t; + * + * sdf_t *data; + * + * ... + * + * sdf_tid = H5Tcreate(H5T_COMPOUND, sizeof(sdf_t)); + * H5Tinsert(sdf_tid, “b_nameâ€, HOFFSET(sdf_t, b), H5T_NATIVE_FLOAT); + * H5Tinsert(sdf_tid, “c_nameâ€, HOFFSET(sdf_t, c), H5T_NATIVE_DOUBLE); + * + * ... + * + * dataset_id = H5Dopen(file_id, “SDScompound.h5â€, H5P_DEFAULT); + * + * ... + * + * data = (sdf_t *) malloc (sizeof(sdf_t) * LENGTH); + * H5Dread(dataset_id, sdf_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + * \endcode + * + *

    Array

    + * + * Many scientific datasets have multiple measurements for each point in a space. There are several + * natural ways to represent this data, depending on the variables and how they are used in + * computation. See the table and the figure below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Representing data with multiple measurements
    + *

    Storage Strategy

    + *
    + *

    Stored as

    + *
    + *

    Remarks

    + *
    Multiple planes + * + * Several datasets with identical dataspaces + * + * This is optimal when variables are accessed individually, or when often uses only selected + * variables. + *
    + * Additional dimension + * + * One dataset, the last “dimension†is a vec-tor of variables + * + * This can give good performance, although selecting only a few variables may be slow. This may + * not reflect the science. + *
    + * Record with multiple values + * + * One dataset with compound datatype + * + * This enables the variables to be read all together or selected. Also handles “vectors†of + * heterogeneous data. + *
    + * Vector or Tensor value + * + * One dataset, each data element is a small array of values. + * + * This uses the same amount of space as the previous two, and may represent the science model + * better. + *
    + * + * + * + * + * + * + * + * + * + * + * + *
    Figure 13 Representing data with multiple measurements
    + * \image html Dtypes_fig13a.gif + * + * \image html Dtypes_fig13b.gif + *
    + * \image html Dtypes_fig13c.gif + * + * \image html Dtypes_fig13d.gif + *
    + * + * The HDF5 #H5T_ARRAY datatype defines the data element to be a homogeneous, multi-dimensional array. + * See Figure 13 above. The elements of the array can be any HDF5 datatype + * (including compound and array), and the size of the datatype is the total size of the array. A + * dataset of array datatype cannot be subdivided for I/O within the data element: the entire array of + * the data element must be transferred. If the data elements need to be accessed separately, for + * example, by plane, then the array datatype should not be used. The table below shows + * advantages and disadvantages of various storage methods. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Storage method advantages and disadvantages
    + *

    Method

    + *
    + *

    Advantages

    + *
    + *

    Disadvantages

    + *
    + * Multiple Datasets + * + * Easy to access each plane, can select any plane(s) + * + * Less efficient to access a ‘column’ through the planes + *
    + * N+1 Dimension + * + * All access patterns supported + * + * Must be homogeneous datatype
    + * The added dimension may not make sense in the scientific model + *
    + * Compound Datatype + * + * Can be heterogeneous datatype + * + * Planes must be named, selection is by plane
    + * Not a natural representation for a matrix + *
    + * Array + * + * A natural representation for vector or tensor data + * + * Cannot access elements separately (no access by plane) + *
    + * + * An array datatype may be multi-dimensional with 1 to #H5S_MAX_RANK(the maximum rank + * of a dataset is currently 32) dimensions. The dimensions can be any size greater than 0, but + * unlimited dimensions are not supported (although the datatype can be a variable-length datatype). + * + * An array datatype is created with the #H5Tarray_create call, which specifies the number of + * dimensions, the size of each dimension, and the base type of the array. The array datatype can + * then be used in any way that any datatype object is used. The example below shows the creation + * of a datatype that is a two-dimensional array of native integers, and this is then used to create a + * dataset. Note that the dataset can be a dataspace that is any number and size of dimensions. The figure + * below shows the layout in memory assuming that the native integers are 4 bytes. Each + * data element has 6 elements, for a total of 24 bytes. + * + * Create a two-dimensional array datatype + * \code + * hid_t file, dataset; + * hid_t datatype, dataspace; + * hsize_t adims[] = {3, 2}; + * + * datatype = H5Tarray_create(H5T_NATIVE_INT, 2, adims, NULL); + * + * dataset = H5Dcreate(file, datasetname, datatype, + * dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * \endcode + * + * + * + * + * + *
    + * \image html Dtypes_fig14.gif "Memory layout of a two-dimensional array datatype" + *
    + * + * @anchor h4_vlen_datatype

    Variable-length Datatypes

    + * + * A variable-length (VL) datatype is a one-dimensional sequence of a datatype which are not fixed + * in length from one dataset location to another. In other words, each data element may have a + * different number of members. Variable-length datatypes cannot be divided;the entire data + * element must be transferred. + * + * VL datatypes are useful to the scientific community in many different ways, possibly including: + *
      + *
    • Ragged arrays: Multi-dimensional ragged arrays can be implemented with the last (fastest changing) + * dimension being ragged by using a VL datatype as the type of the element stored. + *
    • + *
    • Fractal arrays: A nested VL datatype can be used to implement ragged arrays of ragged arrays, to + * whatever nesting depth is required for the user. + *
    • + *
    • Polygon lists: A common storage requirement is to efficiently store arrays of polygons with + * different numbers of vertices. A VL datatype can be used to efficiently and succinctly describe + * an array of polygons with different numbers of vertices. + *
    • + *
    • Character strings: Perhaps the most common use of VL datatypes will be to store C-like VL + * character strings in dataset elements or as attributes of objects. + *
    • + *
    • Indices (for example, of objects within a file): An array of VL object references could be used + * as an index to all the objects in a file which contain a particular sequence of dataset values. + *
    • + *
    • Object Tracking: An array of VL dataset region references can be used as a method of tracking + * objects or features appearing in a sequence of datasets. + *
    • + *
    + * + * A VL datatype is created by calling #H5Tvlen_create which specifies the base datatype. The first + * example below shows an example of code that creates a VL datatype of unsigned integers. Each + * data element is a one-dimensional array of zero or more members and is stored in the + * hvl_t structure. See the second example below. + * + * Create a variable-length datatype of unsigned integers + * \code + * tid1 = H5Tvlen_create (H5T_NATIVE_UINT); + * + * dataset=H5Dcreate(fid1,“Dataset1â€, tid1, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * \endcode + * + * Data element storage for members of the VL datatype + * \code + * typedef struct + * { + * size_t len; // Length of VL data + * //(in base type units) + * void *p; // Pointer to VL data + * } hvl_t; + * \endcode + * + * The first example below shows how the VL data is written. For each of the 10 data elements, a + * length and data buffer must be allocated. Below the two examples is a figure that shows how the + * data is laid out in memory. + * + * An analogous procedure must be used to read the data. See the second example below. An + * appropriate array of vl_t must be allocated, and the data read. It is then traversed one data + * element at a time. The #H5Dvlen_reclaim call frees the data buffer for the buffer. With each + * element possibly being of different sequence lengths for a dataset with a VL datatype, the + * memory for the VL datatype must be dynamically allocated. Currently there are two methods of + * managing the memory for VL datatypes: the standard C malloc/free memory allocation routines + * or a method of calling user-defined memory management routines to allocate or free memory + * (set with #H5Pset_vlen_mem_manager). Since the memory allocated when reading (or writing) + * may be complicated to release, the #H5Dvlen_reclaim function is provided to traverse a memory + * buffer and free the VL datatype information without leaking memory. + * + * Write VL data + * \code + * hvl_t wdata[10]; // Information to write + * + * // Allocate and initialize VL data to write + * for(i = 0; i < 10; i++) { + * wdata[i].p = malloc((i + 1) * sizeof(unsigned int)); + * wdata[i].len = i + 1; + * for(j = 0; j < (i + 1); j++) + * ((unsigned int *)wdata[i].p)[j]=i * 10 + j; + * } + * ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + * \endcode + * + * Read VL data + * \code + * hvl_t rdata[SPACE1_DIM1]; + * ret = H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, xfer_pid, rdata); + * + * for(i = 0; i < SPACE1_DIM1; i++) { + * printf(“%d: len %d â€,rdata[i].len); + * for(j = 0; j < rdata[i].len; j++) { + * printf(“ value: %u\nâ€,((unsigned int *)rdata[i].p)[j]); + * } + * } + * ret = H5Dvlen_reclaim(tid1, sid1, xfer_pid, rdata); + * \endcode + * + * + * + * + * + *
    + * \image html Dtypes_fig15.gif "Memory layout of a VL datatype" + *
    + * + * The user program must carefully manage these relatively complex data structures. The + * #H5Dvlen_reclaim function performs a standard traversal, freeing all the data. This function + * analyzes the datatype and dataspace objects, and visits each VL data element, recursing through + * nested types. By default, the system free is called for the pointer in each vl_t. Obviously, this + * call assumes that all of this memory was allocated with the system malloc. + * + * The user program may specify custom memory manager routines, one for allocating and one for + * freeing. These may be set with the #H5Pset_vlen_mem_manager, and must have the following + * prototypes: + *
      + *
    • + * \code + * typedef void *(*H5MM_allocate_t)(size_t size, void *info); + * \endcode + *
    • + *
    • + * \code + * typedef void (*H5MM_free_t)(void *mem, void *free_info); + * \endcode + *
    • + *
    + * The utility function #H5Dvlen_get_buf_size checks the number of bytes required to store the VL + * data from the dataset. This function analyzes the datatype and dataspace object to visit all the VL + * data elements, to determine the number of bytes required to store the data for the in the + * destination storage (memory). The size value is adjusted for data conversion and alignment in the + * destination. + * + * \subsection subsec_datatype_other Other Non-numeric Datatypes + * Several datatype classes define special types of objects. + * + * \subsubsection subsubsec_datatype_other_strings Strings + * Text data is represented by arrays of characters, called strings. Many programming languages + * support different conventions for storing strings, which may be fixed or variable-length, and may + * have different rules for padding unused storage. HDF5 can represent strings in several ways. See + * the figure below. + * + * The strings to store are “Four score†and “lazy programmers.†+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    A string stored as one-character elements in a one-dimensional array
    + * a) #H5T_NATIVE_CHAR: The dataset is a one-dimensional array with 29 elements, and each element + * is a single character. + *
    + * \image html Dtypes_fig16a.gif + *
    + * b) Fixed-length string: The dataset is a one-dimensional array with two elements, and each + * element is 20 characters. + *
    + * \image html Dtypes_fig16b.gif + *
    + * c) Variable-length string: The dataset is a one-dimensional array with two elements, and each + * element is a variable-length string. This is the same result when stored as a fixed-length + * string except that the first element of the array will need only 11 bytes for storage instead of 20. + *
    + * \image html Dtypes_fig16c.gif + *
    + * \image html Dtypes_fig16d.gif + *
    + * + * First, a dataset may have a dataset with datatype #H5T_NATIVE_CHAR with each character of + * the string as an element of the dataset. This will store an unstructured block of text data, but + * gives little indication of any structure in the text. See item a in the figure above. + * + * A second alternative is to store the data using the datatype class #H5T_STRING with each + * element a fixed length. See item b in the figure above. In this approach, each element might be a + * word or a sentence, addressed by the dataspace. The dataset reserves space for the specified + * number of characters, although some strings may be shorter. This approach is simple and usually + * is fast to access, but can waste storage space if the length of the Strings varies. + * + * A third alternative is to use a variable-length datatype. See item c in the figure above. This can + * be done using the standard mechanisms described above. The program would use vl_t structures + * to write and read the data. + * + * A fourth alternative is to use a special feature of the string datatype class to set the size of the + * datatype to #H5T_VARIABLE. See item c in the figure above. The example below shows a + * declaration of a datatype of type #H5T_C_S1 which is set to #H5T_VARIABLE. The HDF5 + * Library automatically translates between this and the vl_t structure. Note: the #H5T_VARIABLE + * size can only be used with string datatypes. + * Set the string datatype size to H5T_VARIABLE + * \code + * tid1 = H5Tcopy (H5T_C_S1); + * ret = H5Tset_size (tid1, H5T_VARIABLE); + * \endcode + * + * Variable-length strings can be read into C strings (in other words, pointers to zero terminated + * arrays of char). See the example below. + * Read variable-length strings into C strings + * \code + * char *rdata[SPACE1_DIM1]; + * + * ret = H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, xfer_pid, rdata); + * + * for(i = 0; i < SPACE1_DIM1; i++) { + * printf(“%d: len: %d, str is: %s\nâ€, i, strlen(rdata[i]), rdata[i]); + * } + * + * ret = H5Dvlen_reclaim(tid1, sid1, xfer_pid, rdata); + * \endcode + * + * \subsubsection subsubsec_datatype_other_refs Reference + * In HDF5, objects (groups, datasets, and committed datatypes) are usually accessed by name. + * There is another way to access stored objects - by reference. There are two reference datatypes: + * object reference and region reference. Object reference objects are created with #H5Rcreate and + * other calls (cross reference). These objects can be stored and retrieved in a dataset as elements + * with reference datatype. The first example below shows an example of code that creates + * references to four objects, and then writes the array of object references to a dataset. The second + * example below shows a dataset of datatype reference being read and one of the reference objects + * being dereferenced to obtain an object pointer. + * + * In order to store references to regions of a dataset, the datatype should be #H5T_STD_REF_DSETREG. + * Note that a data element must be either an object reference or a region reference: these are + * different types and cannot be mixed within a single array. + * + * A reference datatype cannot be divided for I/O: an element is read or written completely. + * + * Create object references and write to a dataset + * \code + * dataset= H5Dcreate (fid1, “Dataset3â€, H5T_STD_REF_OBJ, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * + * // Create reference to dataset + * ret = H5Rcreate(&wbuf[0], fid1,“/Group1/Dataset1â€, H5R_OBJECT, -1); + * + * // Create reference to dataset + * ret = H5Rcreate(&wbuf[1], fid1, “/Group1/Dataset2â€, H5R_OBJECT, -1); + * + * // Create reference to group + * ret = H5Rcreate(&wbuf[2], fid1, “/Group1â€, H5R_OBJECT, -1); + * + * // Create reference to committed datatype + * ret = H5Rcreate(&wbuf[3], fid1, “/Group1/Datatype1â€, H5R_OBJECT, -1); + * + * // Write selection to disk + * ret=H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + * \endcode + * + * Read a dataset with a reference datatype + * \code + * rbuf = malloc(sizeof(hobj_ref_t)*SPACE1_DIM1); + * + * // Read selection from disk + * ret=H5Dread(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); + * + * // Open dataset object + * dset2 = H5Rdereference(dataset, H5R_OBJECT, &rbuf[0]); + * \endcode + * + * \subsubsection subsubsec_datatype_other_enum ENUM + * The enum datatype implements a set of (name, value) pairs, similar to C/C++ enum. The values + * are currently limited to native integer datatypes. Each name can be the name of only one value, + * and each value can have only one name. + * + * The data elements of the ENUMERATION are stored according to the datatype. An example + * would be as an array of integers. The example below shows an example of how to create an + * enumeration with five elements. The elements map symbolic names to 2-byte integers. See the + * table below. + * Create an enumeration with five elements + * \code + * hid_t hdf_en_colors; + * short val; + * + * hdf_en_colors = H5Tcreate(H5T_ENUM, sizeof(short)); + * H5Tenum_insert(hdf_en_colors, “REDâ€, (val=0, &val)); + * H5Tenum_insert(hdf_en_colors, “GREENâ€, (val=1, &val)); + * H5Tenum_insert(hdf_en_colors, “BLUEâ€, (val=2, &val)); + * H5Tenum_insert(hdf_en_colors, “WHITEâ€, (val=3, &val)); + * H5Tenum_insert(hdf_en_colors, “BLACKâ€, (val=4, &val)); + * H5Dcreate(fileid, datasetname, hdf_en_colors, spaceid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * \endcode + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    An enumeration with five elements
    NameValue
    RED0
    GREEN1
    BLUE2
    WHITE3
    BLACK4
    + * + * The figure below shows how an array of eight values might be stored. Conceptually, the array is + * an array of symbolic names [BLACK, RED, WHITE, BLUE, ...] See item a in the figure below. + * These are stored as the values and are short integers. So, the first 2 bytes are the value associated + * with “BLACKâ€, which is the number 4, and so on. See item b in the figure below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Storing an enum array
    + * a) Logical data to be written - eight elements + *
    + * \image html Dtypes_fig17a.gif + *
    + * b) The storage layout. Total size of the array is 16 bytes, 2 bytes per element. + *
    + * \image html Dtypes_fig17b.gif + *
    + * + * The order that members are inserted into an enumeration type is unimportant; the important part + * is the associations between the symbol names and the values. Thus, two enumeration datatypes + * will be considered equal if and only if both types have the same symbol/value associations and + * both have equal underlying integer datatypes. Type equality is tested with the H5Tequal + * function. + * + * If a particular architecture type is required, a little-endian or big-endian datatype for example, + * use a native integer datatype as the ENUM base datatype and use #H5Tconvert on values as they + * are read from or written to a dataset. + * + * \subsubsection subsubsec_datatype_other_opaque Opaque + * In some cases, a user may have data objects that should be stored and retrieved as blobs with no + * attempt to interpret them. For example, an application might wish to store an array of encrypted + * certificates which are 100 bytes long. + * + * While an arbitrary block of data may always be stored as bytes, characters, integers, or whatever, + * this might mislead programs about the meaning of the data. The opaque datatype defines data + * elements which are uninterpreted by HDF5. The opaque data may be labeled with + * #H5Tset_tag with a string that might be used by an application. For example, the encrypted + * certificates might have a tag to indicate the encryption and the certificate standard. + * + * \subsubsection subsubsec_datatype_other_bitfield Bitfield + * Some data is represented as bits, where the number of bits is not an integral byte and the bits are + * not necessarily interpreted as a standard type. Some examples might include readings from + * machine registers (for example, switch positions), a cloud mask, or data structures with several + * small integers that should be store in a single byte. + * + * This data could be stored as integers, strings, or enumerations. However, these storage methods + * would likely result in considerable wasted space. For example, storing a cloud mask with one + * byte per value would use up to eight times the space of a packed array of bits. + * + * The HDF5 bitfield datatype class defines a data element that is a contiguous sequence of bits, + * which are stored on disk in a packed array. The programming model is the same as for unsigned + * integers: the datatype object is created by copying a predefined datatype, and then the precision, + * offset, and padding are set. + * + * While the use of the bitfield datatype will reduce storage space substantially, there will still be + * wasted space if the bitfield as a whole does not match the 1-, 2-, 4-, or 8-byte unit in which it is + * written. The remaining unused space can be removed by applying the N-bit filter to the dataset + * containing the bitfield data. For more information, see "Using the N-bit Filter." + * + * \subsection subsec_datatype_fill Fill Values + * The “fill value†for a dataset is the specification of the default value assigned to data elements + * that have not yet been written. In the case of a dataset with an atomic datatype, the fill value is a + * single value of the appropriate datatype, such as ‘0’ or ‘-1.0’. In the case of a dataset with a + * composite datatype, the fill value is a single data element of the appropriate type. For example, + * for an array or compound datatype, the fill value is a single data element with values for all the + * component elements of the array or compound datatype. + * + * The fill value is set (permanently) when the dataset is created. The fill value is set in the dataset + * creation properties in the #H5Dcreate call. Note that the #H5Dcreate call must also include the + * datatype of the dataset, and the value provided for the fill value will be interpreted as a single + * element of this datatype. The example below shows code which creates a dataset of integers with + * fill value -1. Any unwritten data elements will be set to -1. + * + * Create a dataset with a fill value of -1 + * \code + * hid_t plist_id; + * int filler; + * + * filler = -1; + * plist_id = H5Pcreate(H5P_DATASET_CREATE); + * H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &filler); + * + * // Create the dataset with fill value ‘-1’. + * dataset_id = H5Dcreate(file_id, “/dsetâ€, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, plist_id, + * H5P_DEFAULT); + * \endcode + * + * Create a fill value for a compound datatype + * \code + * typedef struct s1_t { + * int a; + * char b; + * double c; + * } s1_t; + * s1_t filler; + * + * s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); + * H5Tinsert(s1_tid, “a_nameâ€, HOFFSET(s1_t, a), H5T_NATIVE_INT); + * H5Tinsert(s1_tid, “b_nameâ€, HOFFSET(s1_t, b), H5T_NATIVE_CHAR); + * H5Tinsert(s1_tid, “c_nameâ€, HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); + * + * filler.a = -1; + * filler.b = ‘*’; + * filler.c = -2.0; + * plist_id = H5Pcreate(H5P_DATASET_CREATE); + * H5Pset_fill_value(plist_id, s1_tid, &filler); + * + * // Create the dataset with fill value + * // (-1, ‘*’, -2.0). + * dataset = H5Dcreate(file, datasetname, s1_tid, space, H5P_DEFAULT, plist_id, H5P_DEFAULT); + * \endcode + * + * The code above shows how to create a fill value for a compound datatype. The procedure is the + * same as the previous example except the filler must be a structure with the correct fields. Each + * field is initialized to the desired fill value. + * + * The fill value for a dataset can be retrieved by reading the dataset creation properties of the + * dataset and then by reading the fill value with #H5Pget_fill_value. The data will be read into + * memory using the storage layout specified by the datatype. This transfer will convert data in the + * same way as #H5Dread. The example below shows how to get the fill value from the dataset + * created in the example "Create a dataset with a fill value of -1". + * + * Retrieve a fill value + * \code + * hid_t plist2; + * int filler; + * + * dataset_id = H5Dopen(file_id, “/dsetâ€, H5P_DEFAULT); + * plist2 = H5Dget_create_plist(dataset_id); + * + * H5Pget_fill_value(plist2, H5T_NATIVE_INT, &filler); + * + * // filler has the fill value, ‘-1’ + * \endcode + * + * A similar procedure is followed for any datatype. The example below shows how to read the fill + * value for the compound datatype created in an example above. Note that the program must pass + * an element large enough to hold a fill value of the datatype indicated by the argument to + * #H5Pget_fill_value. Also, the program must understand the datatype in order to interpret its + * components. This may be difficult to determine without knowledge of the application that + * created the dataset. + * + * Read the fill value for a compound datatype + * \code + * char *fillbuf; + * int sz; + * + * dataset = H5Dopen( file, DATASETNAME, H5P_DEFAULT); + * + * s1_tid = H5Dget_type(dataset); + * + * sz = H5Tget_size(s1_tid); + * + * fillbuf = (char *)malloc(sz); + * + * plist_id = H5Dget_create_plist(dataset); + * + * H5Pget_fill_value(plist_id, s1_tid, fillbuf); + * + * printf(“filler.a: %d\nâ€,((s1_t *) fillbuf)->a); + * printf(“filler.b: %c\nâ€,((s1_t *) fillbuf)->b); + * printf(“filler.c: %f\nâ€,((s1_t *) fillbuf)->c); + * \endcode + * + * \subsection subsec_datatype_complex Complex Combinations of Datatypes + * Several composite datatype classes define collections of other datatypes, including other + * composite datatypes. In general, a datatype can be nested to any depth, with any combination of + * datatypes. + * + * For example, a compound datatype can have members that are other compound datatypes, arrays, + * VL datatypes. An array can be an array of array, an array of compound, or an array of VL. And a + * VL datatype can be a variable-length array of compound, array, or VL datatypes. + * + * These complicated combinations of datatypes form a logical tree, with a single root datatype, and + * leaves which must be atomic datatypes (predefined or user-defined). The figure below shows an + * example of a logical tree describing a compound datatype constructed from different datatypes. + * + * Recall that the datatype is a description of the layout of storage. The complicated compound + * datatype is constructed from component datatypes, each of which describes the layout of part of + * the storage. Any datatype can be used as a component of a compound datatype, with the + * following restrictions: + *
    • 1. No byte can be part of more than one component datatype (in other words, the fields cannot + * overlap within the compound datatype)
    • + *
    • 2. The total size of the components must be less than or equal to the total size of the compound + * datatype
    + * These restrictions are essentially the rules for C structures and similar record types familiar from + * programming languages. Multiple typing, such as a C union, is not allowed in HDF5 datatypes. + * + * + * + * + * + *
    + * \image html Dtypes_fig18.gif "A compound datatype built with different datatypes" + *
    + * + * \subsubsection subsubsec_datatype_complex_create Creating a Complicated Compound Datatype + * To construct a complicated compound datatype, each component is constructed, and then added + * to the enclosing datatype description. The example below shows how to create a compound + * datatype with four members: + * \li “T1â€, a compound datatype with three members + * \li “T2â€, a compound datatype with two members + * \li “T3â€, a one-dimensional array of integers + * \li “T4â€, a string + * + * Below the example code is a figure that shows this datatype as a logical tree. The output of the + * h5dump utility is shown in the example below the figure. + * + * Each datatype is created as a separate datatype object. Figure "The storage layout for the + * four member datatypes" below shows the storage layout + * for the four individual datatypes. Then the datatypes are inserted into the outer datatype at an + * appropriate offset. Figure "The storage layout of the combined four members" below shows the + * resulting storage layout. The combined record is 89 bytes long. + * + * The Dataset is created using the combined compound datatype. The dataset is declared to be a 4 + * by 3 array of compound data. Each data element is an instance of the 89-byte compound + * datatype. Figure "The layout of the dataset" below shows the layout of the dataset, and expands + * one of the elements to show the relative position of the component data elements. + * + * Each data element is a compound datatype, which can be written or read as a record, or each + * field may be read or written individually. The first field (“T1â€) is itself a compound datatype + * with three fields (“T1.aâ€, “T1.bâ€, and “T1.câ€). “T1†can be read or written as a record, or + * individual fields can be accessed. Similarly, the second filed is a compound datatype with two + * fields (“T2.f1â€, “T2.f2â€). + * + * The third field (“T3â€) is an array datatype. Thus, “T3†should be accessed as an array of 40 + * integers. Array data can only be read or written as a single element, so all 40 integers must be + * read or written to the third field. The fourth field (“T4â€) is a single string of length 25. + * + * Create a compound datatype with four members + * \code + * typedef struct s1_t { + * int a; + * char b; + * double c; + * } s1_t; + * typedef struct s2_t { + * float f1; + * float f2; + * } s2_t; + * hid_t s1_tid, s2_tid, s3_tid, s4_tid, s5_tid; + * + * // Create a datatype for s1 + * s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); + * H5Tinsert(s1_tid, “a_nameâ€, HOFFSET(s1_t, a), H5T_NATIVE_INT); + * H5Tinsert(s1_tid, “b_nameâ€, HOFFSET(s1_t, b), H5T_NATIVE_CHAR); + * H5Tinsert(s1_tid, “c_nameâ€, HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); + * + * // Create a datatype for s2. + * s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)); + * H5Tinsert(s2_tid, “f1â€, HOFFSET(s2_t, f1), H5T_NATIVE_FLOAT); + * H5Tinsert(s2_tid, “f2â€, HOFFSET(s2_t, f2), H5T_NATIVE_FLOAT); + * + * // Create a datatype for an Array of integers + * s3_tid = H5Tarray_create(H5T_NATIVE_INT, RANK, dim); + * + * // Create a datatype for a String of 25 characters + * s4_tid = H5Tcopy(H5T_C_S1); + * H5Tset_size(s4_tid, 25); + * + * // Create a compound datatype composed of one of each of these types. + * // The total size is the sum of the size of each. + * sz = H5Tget_size(s1_tid) + H5Tget_size(s2_tid) + H5Tget_size(s3_tid) + H5Tget_size(s4_tid); + * s5_tid = H5Tcreate (H5T_COMPOUND, sz); + * + * // Insert the component types at the appropriate offsets. + * H5Tinsert(s5_tid, “T1â€, 0, s1_tid); + * H5Tinsert(s5_tid, “T2â€, sizeof(s1_t), s2_tid); + * H5Tinsert(s5_tid, “T3â€, sizeof(s1_t) + sizeof(s2_t), s3_tid); + * H5Tinsert(s5_tid, “T4â€, (sizeof(s1_t) + sizeof(s2_t) + H5Tget_size(s3_tid)), s4_tid); + * + * // Create the dataset with this datatype. + * dataset = H5Dcreate(file, DATASETNAME, s5_tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * \endcode + * + * + * + * + * + *
    + * \image html Dtypes_fig19.gif "Logical tree for the compound datatype with four members" + *
    + * + * Output from h5dump for the compound datatype + * \code + * DATATYPE H5T_COMPOUND { + * H5T_COMPOUND { + * H5T_STD_I32LE “a_nameâ€; + * H5T_STD_I8LE “b_nameâ€; + * H5T_IEEE_F64LE “c_nameâ€; + * } “T1â€; + * H5T_COMPOUND { + * H5T_IEEE_F32LE “f1â€; + * H5T_IEEE_F32LE “f2â€; + * } “T2â€; + * H5T_ARRAY { [10] H5T_STD_I32LE } “T3â€; + * H5T_STRING { + * STRSIZE 25; + * STRPAD H5T_STR_NULLTERM; + * CSET H5T_CSET_ASCII; + * CTYPE H5T_C_S1; + * } “T4â€; + * } + * \endcode + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    The storage layout for the four member datatypes
    + * a) Compound type ‘s1_t’, size 16 bytes. + *
    + * \image html Dtypes_fig20a.gif + *
    + * b) Compound type ‘s2_t’, size 8 bytes. + *
    + * \image html Dtypes_fig20b.gif + *
    + * c) Array type ‘s3_tid’, 40 integers, total size 40 bytes. + *
    + * \image html Dtypes_fig20c.gif + *
    + * d) String type ‘s4_tid’, size 25 bytes. + *
    + * \image html Dtypes_fig20d.gif + *
    + * + * + * + * + * + *
    + * \image html Dtypes_fig21.gif "The storage layout of the combined four members" + *
    + * + * \li A 4 x 3 array of Compound Datatype + * \li Element [1,1] expanded + * + * + * + * + *
    + * \image html Dtypes_fig22.gif "The layout of the dataset" + *
    + * + * \subsubsection subsubsec_datatype_complex_analyze Analyzing and Navigating a Compound Datatype + * A complicated compound datatype can be analyzed piece by piece to discover the exact storage + * layout. In the example above, the outer datatype is analyzed to discover that it is a compound + * datatype with four members. Each member is analyzed in turn to construct a complete map of the + * storage layout. + * + * The example below shows an example of code that partially analyzes a nested compound + * datatype. The name and overall offset and size of the component datatype is discovered, and then + * its type is analyzed depending on the datatype class. Through this method, the complete storage + * layout can be discovered. + * + * Output from h5dump for the compound datatype + * \code + * s1_tid = H5Dget_type(dataset); + * + * if (H5Tget_class(s1_tid) == H5T_COMPOUND) { + * printf(“COMPOUND DATATYPE {\nâ€); + * sz = H5Tget_size(s1_tid); + * nmemb = H5Tget_nmembers(s1_tid); + * printf(“ %d bytes\nâ€,sz); + * printf(“ %d members\nâ€,nmemb); + * for (i =0; i < nmemb; i++) { + * s2_tid = H5Tget_member_type(s1_tid, i); + * if (H5Tget_class(s2_tid) == H5T_COMPOUND) { + * // recursively analyze the nested type. + * } + * else if (H5Tget_class(s2_tid) == H5T_ARRAY) { + * sz2 = H5Tget_size(s2_tid); + * printf(“ %s: NESTED ARRAY DATATYPE offset %d size %d + * {\nâ€, H5Tget_member_name(s1_tid, i), H5Tget_member_offset(s1_tid, i), sz2); + * H5Tget_array_dims(s2_tid, dim); + * s3_tid = H5Tget_super(s2_tid); + * // Etc., analyze the base type of the array + * } + * else { + * // analyze a simple type + * printf(“ %s: type code %d offset %d size %d\nâ€, H5Tget_member_name(s1_tid, i), + * H5Tget_class(s2_tid), H5Tget_member_offset(s1_tid, i), H5Tget_size(s2_tid)); + * } + * // and so on.... + * \endcode + * + * \subsection subsec_datatype_life Life Cycle of the Datatype Object + * Application programs access HDF5 datatypes through identifiers. Identifiers are obtained by + * creating a new datatype or by copying or opening an existing datatype. The identifier can be used + * until it is closed or until the library shuts down. See items a and b in the figure below. By default, + * a datatype is transient, and it disappears when it is closed. + * + * When a dataset or attribute is created (#H5Dcreate or #H5Acreate), its datatype is stored in the + * HDF5 file as part of the dataset or attribute object. See item c in the figure below. Once an object + * created, its datatype cannot be changed or deleted. The datatype can be accessed by calling + * #H5Dget_type, #H5Aget_type, #H5Tget_super, or #H5Tget_member_type. See item d in the figure + * below. These calls return an identifier to a transient copy of the datatype of the dataset or + * attribute unless the datatype is a committed datatype. + * Note that when an object is created, the stored datatype is a copy of the transient datatype. If two + * objects are created with the same datatype, the information is stored in each object with the same + * effect as if two different datatypes were created and used. + * + * A transient datatype can be stored using #H5Tcommit in the HDF5 file as an independent, named + * object, called a committed datatype. Committed datatypes were formerly known as named + * datatypes. See item e in the figure below. Subsequently, when a committed datatype is opened + * with #H5Topen (item f), or is obtained with #H5Tget_member_type or similar call (item k), the return + * is an identifier to a transient copy of the stored datatype. The identifier can be used in the + * same way as other datatype identifiers except that the committed datatype cannot be modified. When a + * committed datatype is copied with #H5Tcopy, the return is a new, modifiable, transient datatype + * object (item f). + * + * When an object is created using a committed datatype (#H5Dcreate, #H5Acreate), the stored + * datatype is used without copying it to the object. See item j in the figure below. In this case, if + * multiple objects are created using the same committed datatype, they all share the exact same + * datatype object. This saves space and makes clear that the datatype is shared. Note that a + * committed datatype can be shared by objects within the same HDF5 file, but not by objects in + * other files. For more information on copying committed datatypes to other HDF5 files, see the + * “Copying Committed Datatypes with H5Ocopy†topic in the “Additional Resources†chapter. + * + * A committed datatype can be deleted from the file by calling #H5Ldelete which replaces + * #H5Gunlink. See item i in the figure below. If one or more objects are still using the datatype, the + * committed datatype cannot be accessed with #H5Topen, but will not be removed from the file + * until it is no longer used. #H5Tget_member_type and similar calls will return a transient copy of the + * datatype. + * + * + * + * + * + *
    + * \image html Dtypes_fig23.gif "Life cycle of a datatype" + *
    + * + * Transient datatypes are initially modifiable. Note that when a datatype is copied or when it is + * written to the file (when an object is created) or the datatype is used to create a composite + * datatype, a copy of the current state of the datatype is used. If the datatype is then modified, the + * changes have no effect on datasets, attributes, or datatypes that have already been created. See + * the figure below. + * + * A transient datatype can be made read-only (#H5Tlock). Note that the datatype is still transient, + * and otherwise does not change. A datatype that is immutable is read-only but cannot be closed + * except when the entire library is closed. The predefined types such as #H5T_NATIVE_INT are + * immutable transient types. + * + * + * + * + * + *
    + * \image html Dtypes_fig24.gif "Transient datatype states: modifiable, read-only, and immutable" + *
    + * + * To create two or more datasets that share a common datatype, first commit the datatype, and then + * use that datatype to create the datasets. See the example below. + * Create a shareable datatype + * \code + * hid_t t1 = ...some transient type...; + * H5Tcommit (file, “shared_typeâ€, t1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * hid_t dset1 = H5Dcreate (file, “dset1â€, t1, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * hid_t dset2 = H5Dcreate (file, “dset2â€, t1, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * + * hid_t dset1 = H5Dopen (file, “dset1â€, H5P_DEFAULT); + * hid_t t2 = H5Dget_type (dset1); + * hid_t dset3 = H5Dcreate (file, “dset3â€, t2, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * hid_t dset4 = H5Dcreate (file, “dset4â€, t2, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + * \endcode + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Datatype APIs
    FunctionDescription
    + * \code + * hid_t H5Topen (hid_t location, const char *name) + * \endcode + * + * A committed datatype can be opened by calling this function, which returns a datatype identifier. + * The identifier should eventually be released by calling #H5Tclose() to release resources. The + * committed datatype returned by this function is read-only or a negative value is returned for failure. + * The location is either a file or group identifier. + *
    + * \code + * herr_t H5Tcommit (hid_t location, const char *name, hid_t type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) + * \endcode + * + * A transient datatype (not immutable) can be written to a file and turned into a committed datatype by + * calling this function. The location is either a file or group identifier and when combined with name + * refers to a new committed datatype. + *
    + * \code + * htri_t H5Tcommitted (hid_t type) + * \endcode + * + * A type can be queried to determine if it is a committed type or a transient type. If this function + * returns a positive value then the type is committed. Datasets which return committed datatypes with + * #H5Dget_type() are able to share the datatype with other datasets in the same file. + *
    + * + * \subsection subsec_datatype_transfer Data Transfer: Datatype Conversion and Selection + * When data is transferred (write or read), the storage layout of the data elements may be different. + * For example, an integer might be stored on disk in big-endian byte order and read into memory + * with little-endian byte order. In this case, each data element will be transformed by the HDF5 + * Library during the data transfer. + * + * The conversion of data elements is controlled by specifying the datatype of the source and + * specifying the intended datatype of the destination. The storage format on disk is the datatype + * specified when the dataset is created. The datatype of memory must be specified in the library + * call. + * + * In order to be convertible, the datatype of the source and destination must have the same + * datatype class (with the exception of enumeration type). Thus, integers can be converted to other + * integers, and floats to other floats, but integers cannot (yet) be converted to floats. For each + * atomic datatype class, the possible conversions are defined. An enumeration datatype can be + * converted to an integer or a floating-point number datatype. + * + * Basically, any datatype can be converted to another datatype of the same datatype class. The + * HDF5 Library automatically converts all properties. If the destination is too small to hold the + * source value then an overflow or underflow exception occurs. If a handler is defined with the + * #H5Pset_type_conv_cb function, it will be called. Otherwise, a default action will be performed. + * The table below summarizes the default actions. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Default actions for datatype conversion exceptions
    Datatype ClassPossible ExceptionsDefault Action
    IntegerSize, offset, pad
    FloatSize, offset, pad, ebits
    StringSizeTruncates, zero terminate if required.
    EnumerationNo fieldAll bits set
    + * + * For example, when reading data from a dataset, the source datatype is the datatype set when the + * dataset was created, and the destination datatype is the description of the storage layout in + * memory. The destination datatype must be specified in the #H5Dread call. The example below + * shows an example of reading a dataset of 32-bit integers. The figure below the example shows + * the data transformation that is performed. + * Specify the destination datatype with H5Dread + * \code + * // Stored as H5T_STD_BE32 + * // Use the native memory order in the destination + * mem_type_id = H5Tcopy(H5T_NATIVE_INT); + * status = H5Dread(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); + * \endcode + * + * + * + * + * + * + *
    Layout of a datatype conversion
    + * \image html Dtypes_fig25a.gif
    + * \image html Dtypes_fig25b.gif
    + * \image html Dtypes_fig25c.gif + *
    + * + * One thing to note in the example above is the use of the predefined native datatype + * #H5T_NATIVE_INT. Recall that in this example, the data was stored as a 4-bytes in big-endian + * order. The application wants to read this data into an array of integers in memory. Depending on + * the system, the storage layout of memory might be either big or little-endian, so the data may + * need to be transformed on some platforms and not on others. The #H5T_NATIVE_INT type is set + * by the HDF5 Library to be the correct type to describe the storage layout of the memory on the + * system. Thus, the code in the example above will work correctly on any platform, performing a + * transformation when needed. + * + * There are predefined native types for most atomic datatypes, and these can be combined in + * composite datatypes. In general, the predefined native datatypes should always be used for data + * stored in memory. + * Predefined native datatypes describe the storage properties of memory. + * + * + * + * + * + *
    + * \image html Dtypes_fig26.gif "An enum datatype conversion" + *
    + * + * Create an aligned and packed compound datatype + * \code + * // Stored as H5T_STD_BE32 + * // Use the native memory order in the destination + * mem_type_id = H5Tcopy(H5T_NATIVE_INT); + * status = H5Dread(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); + * \endcode + * + * + * + * + * + *
    + * \image html Dtypes_fig27.gif "Alignment of a compound datatype" + *
    + * + * Transfer some fields of a compound datatype + * \code + * // Stored as H5T_STD_BE32 + * // Use the native memory order in the destination + * mem_type_id = H5Tcopy(H5T_NATIVE_INT); + * status = H5Dread(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf); + * \endcode + * + * + * + * + * + *
    + * \image html Dtypes_fig28.gif "Layout when an element is skipped" + *
    + * + * \subsection subsec_datatype_text Text Descriptions of Datatypes: Conversion to and from + * + * HDF5 provides a means for generating a portable and human-readable text description of a + * datatype and for generating a datatype from such a text description. This capability is particularly + * useful for creating complex datatypes in a single step, for creating a text description of a datatype + * for debugging purposes, and for creating a portable datatype definition that can then be used to + * recreate the datatype on many platforms or in other applications. + * + * These tasks are handled by two functions provided in the HDF5 Lite high-level library: + * \li #H5LTtext_to_dtype Creates an HDF5 datatype in a single step. + * \li #H5LTdtype_to_text Translates an HDF5 datatype into a text description. + * + * Note that this functionality requires that the HDF5 High-Level Library (H5LT) be installed. + * + * While #H5LTtext_to_dtype can be used to generate any sort of datatype, it is particularly useful + * for complex datatypes. + * + * #H5LTdtype_to_text is most likely to be used in two sorts of situations: when a datatype must be + * closely examined for debugging purpose or to create a portable text description of the datatype + * that can then be used to recreate the datatype on other platforms or in other applications. + * + * These two functions work for all valid HDF5 datatypes except time, bitfield, and reference + * datatypes. + * + * The currently supported text format used by #H5LTtext_to_dtype and #H5LTdtype_to_text is the + * data description language (DDL) and conforms to the \ref DDLBNF110. The portion of the + * \ref DDLBNF110 that defines HDF5 datatypes appears below. + * The definition of HDF5 datatypes from the HDF5 DDL + * \code + * ::= | | | + * + * ::= | |